scripts
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
namespace UnityEngine.Networking.PlayerConnection
|
||||
{
|
||||
// Token: 0x020004CC RID: 1228
|
||||
[Serializable]
|
||||
public class PlayerConnection : ScriptableObject, IEditorPlayerConnection
|
||||
{
|
||||
// Token: 0x17000D8A RID: 3466
|
||||
// (get) Token: 0x06003BD6 RID: 15318 RVA: 0x00069198 File Offset: 0x00067398
|
||||
public static PlayerConnection instance
|
||||
{
|
||||
get
|
||||
{
|
||||
PlayerConnection playerConnection;
|
||||
if (PlayerConnection.s_Instance == null)
|
||||
{
|
||||
playerConnection = PlayerConnection.CreateInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
playerConnection = PlayerConnection.s_Instance;
|
||||
}
|
||||
return playerConnection;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000D8B RID: 3467
|
||||
// (get) Token: 0x06003BD7 RID: 15319 RVA: 0x000691D0 File Offset: 0x000673D0
|
||||
public bool isConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetConnectionNativeApi().IsConnected();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06003BD8 RID: 15320 RVA: 0x000691F0 File Offset: 0x000673F0
|
||||
private static PlayerConnection CreateInstance()
|
||||
{
|
||||
PlayerConnection.s_Instance = ScriptableObject.CreateInstance<PlayerConnection>();
|
||||
PlayerConnection.s_Instance.hideFlags = HideFlags.HideAndDontSave;
|
||||
return PlayerConnection.s_Instance;
|
||||
}
|
||||
|
||||
// Token: 0x06003BD9 RID: 15321 RVA: 0x00069220 File Offset: 0x00067420
|
||||
public void OnEnable()
|
||||
{
|
||||
if (!this.m_IsInitilized)
|
||||
{
|
||||
this.m_IsInitilized = true;
|
||||
this.GetConnectionNativeApi().Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06003BDA RID: 15322 RVA: 0x00069248 File Offset: 0x00067448
|
||||
private IPlayerEditorConnectionNative GetConnectionNativeApi()
|
||||
{
|
||||
return PlayerConnection.connectionNative ?? new PlayerConnectionInternal();
|
||||
}
|
||||
|
||||
// Token: 0x06003BDB RID: 15323 RVA: 0x00069270 File Offset: 0x00067470
|
||||
public void Register(Guid messageId, UnityAction<MessageEventArgs> callback)
|
||||
{
|
||||
if (messageId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentException("Cant be Guid.Empty", "messageId");
|
||||
}
|
||||
if (!this.m_PlayerEditorConnectionEvents.messageTypeSubscribers.Any<PlayerEditorConnectionEvents.MessageTypeSubscribers>())
|
||||
{
|
||||
this.GetConnectionNativeApi().RegisterInternal(messageId);
|
||||
}
|
||||
this.m_PlayerEditorConnectionEvents.AddAndCreate(messageId).AddListener(callback);
|
||||
}
|
||||
|
||||
// Token: 0x06003BDC RID: 15324 RVA: 0x000692D4 File Offset: 0x000674D4
|
||||
public void Unregister(Guid messageId, UnityAction<MessageEventArgs> callback)
|
||||
{
|
||||
this.m_PlayerEditorConnectionEvents.UnregisterManagedCallback(messageId, callback);
|
||||
if (!this.m_PlayerEditorConnectionEvents.messageTypeSubscribers.Any((PlayerEditorConnectionEvents.MessageTypeSubscribers x) => x.MessageTypeId == messageId))
|
||||
{
|
||||
this.GetConnectionNativeApi().UnregisterInternal(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06003BDD RID: 15325 RVA: 0x00069338 File Offset: 0x00067538
|
||||
public void RegisterConnection(UnityAction<int> callback)
|
||||
{
|
||||
foreach (int num in this.m_connectedPlayers)
|
||||
{
|
||||
callback(num);
|
||||
}
|
||||
this.m_PlayerEditorConnectionEvents.connectionEvent.AddListener(callback);
|
||||
}
|
||||
|
||||
// Token: 0x06003BDE RID: 15326 RVA: 0x000693AC File Offset: 0x000675AC
|
||||
public void RegisterDisconnection(UnityAction<int> callback)
|
||||
{
|
||||
this.m_PlayerEditorConnectionEvents.disconnectionEvent.AddListener(callback);
|
||||
}
|
||||
|
||||
// Token: 0x06003BDF RID: 15327 RVA: 0x000693C0 File Offset: 0x000675C0
|
||||
public void Send(Guid messageId, byte[] data)
|
||||
{
|
||||
if (messageId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentException("Cant be Guid.Empty", "messageId");
|
||||
}
|
||||
this.GetConnectionNativeApi().SendMessage(messageId, data, 0);
|
||||
}
|
||||
|
||||
// Token: 0x06003BE0 RID: 15328 RVA: 0x000693F4 File Offset: 0x000675F4
|
||||
public void DisconnectAll()
|
||||
{
|
||||
this.GetConnectionNativeApi().DisconnectAll();
|
||||
}
|
||||
|
||||
// Token: 0x06003BE1 RID: 15329 RVA: 0x00069404 File Offset: 0x00067604
|
||||
[RequiredByNativeCode]
|
||||
private static void MessageCallbackInternal(IntPtr data, ulong size, ulong guid, string messageId)
|
||||
{
|
||||
byte[] array = null;
|
||||
if (size > 0UL)
|
||||
{
|
||||
array = new byte[size];
|
||||
Marshal.Copy(data, array, 0, (int)size);
|
||||
}
|
||||
PlayerConnection.instance.m_PlayerEditorConnectionEvents.InvokeMessageIdSubscribers(new Guid(messageId), array, (int)guid);
|
||||
}
|
||||
|
||||
// Token: 0x06003BE2 RID: 15330 RVA: 0x00069448 File Offset: 0x00067648
|
||||
[RequiredByNativeCode]
|
||||
private static void ConnectedCallbackInternal(int playerId)
|
||||
{
|
||||
PlayerConnection.instance.m_connectedPlayers.Add(playerId);
|
||||
PlayerConnection.instance.m_PlayerEditorConnectionEvents.connectionEvent.Invoke(playerId);
|
||||
}
|
||||
|
||||
// Token: 0x06003BE3 RID: 15331 RVA: 0x00069470 File Offset: 0x00067670
|
||||
[RequiredByNativeCode]
|
||||
private static void DisconnectedCallback(int playerId)
|
||||
{
|
||||
PlayerConnection.instance.m_PlayerEditorConnectionEvents.disconnectionEvent.Invoke(playerId);
|
||||
}
|
||||
|
||||
// Token: 0x040011F8 RID: 4600
|
||||
internal static IPlayerEditorConnectionNative connectionNative;
|
||||
|
||||
// Token: 0x040011F9 RID: 4601
|
||||
[SerializeField]
|
||||
private PlayerEditorConnectionEvents m_PlayerEditorConnectionEvents = new PlayerEditorConnectionEvents();
|
||||
|
||||
// Token: 0x040011FA RID: 4602
|
||||
[SerializeField]
|
||||
private List<int> m_connectedPlayers = new List<int>();
|
||||
|
||||
// Token: 0x040011FB RID: 4603
|
||||
private bool m_IsInitilized;
|
||||
|
||||
// Token: 0x040011FC RID: 4604
|
||||
private static PlayerConnection s_Instance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user