mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-19 21:40:18 +00:00
cleanup
This commit is contained in:
parent
a814c418a7
commit
f726e651b8
@ -75,15 +75,6 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Moved to NetworkMigrationManager.")]
|
||||
public PeerInfoMessage[] peers
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal int hostId
|
||||
{
|
||||
get
|
||||
|
@ -450,9 +450,6 @@ namespace QuantumUNET
|
||||
|
||||
public virtual void TransportReceive(byte[] bytes, int numBytes, int channelId) => HandleBytes(bytes, numBytes, channelId);
|
||||
|
||||
[Obsolete("TransportRecieve has been deprecated. Use TransportReceive instead (UnityUpgradable) -> TransportReceive(*)", false)]
|
||||
public virtual void TransportRecieve(byte[] bytes, int numBytes, int channelId) => TransportReceive(bytes, numBytes, channelId);
|
||||
|
||||
public virtual bool TransportSend(byte[] bytes, int numBytes, int channelId, out byte error) => NetworkTransport.Send(hostId, connectionId, channelId, bytes, numBytes, out error);
|
||||
|
||||
internal void AddOwnedObject(QSBNetworkIdentity obj)
|
||||
|
@ -34,19 +34,6 @@ namespace QuantumUNET
|
||||
}
|
||||
manager.networkAddress = GUI.TextField(new Rect(num + 100, num2, 95f, 20f), manager.networkAddress);
|
||||
num2 += 24;
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
GUI.Box(new Rect(num, num2, 200f, 25f), "( WebGL cannot be server )");
|
||||
num2 += 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUI.Button(new Rect(num, num2, 200f, 20f), "LAN Server Only"))
|
||||
{
|
||||
manager.StartServer();
|
||||
}
|
||||
num2 += 24;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -103,14 +90,6 @@ namespace QuantumUNET
|
||||
}
|
||||
num2 += 24;
|
||||
}
|
||||
if (!QSBNetworkServer.active && !manager.IsClientConnected() && flag)
|
||||
{
|
||||
num2 += 10;
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
GUI.Box(new Rect(num - 5, num2, 220f, 25f), "(WebGL cannot use Match Maker)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,9 @@ namespace QuantumUNET
|
||||
{
|
||||
public class QSBNetworkReader
|
||||
{
|
||||
public QSBNetworkReader()
|
||||
{
|
||||
m_buf = new QSBNetBuffer();
|
||||
Initialize();
|
||||
}
|
||||
private QSBNetBuffer m_buf;
|
||||
private static byte[] s_StringReaderBuffer;
|
||||
private static Encoding s_Encoding;
|
||||
|
||||
public QSBNetworkReader(QSBNetworkWriter writer)
|
||||
{
|
||||
@ -34,69 +32,51 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
|
||||
public uint Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_buf.Position;
|
||||
}
|
||||
}
|
||||
public uint Position => m_buf.Position;
|
||||
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_buf.Length;
|
||||
}
|
||||
}
|
||||
public int Length => m_buf.Length;
|
||||
|
||||
public void SeekZero()
|
||||
{
|
||||
m_buf.SeekZero();
|
||||
}
|
||||
public void SeekZero() => m_buf.SeekZero();
|
||||
|
||||
internal void Replace(byte[] buffer)
|
||||
{
|
||||
m_buf.Replace(buffer);
|
||||
}
|
||||
internal void Replace(byte[] buffer) => m_buf.Replace(buffer);
|
||||
|
||||
public uint ReadPackedUInt32()
|
||||
{
|
||||
byte b = ReadByte();
|
||||
var b = ReadByte();
|
||||
uint result;
|
||||
if (b < 241)
|
||||
{
|
||||
result = (uint)b;
|
||||
result = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b2 = ReadByte();
|
||||
var b2 = ReadByte();
|
||||
if (b >= 241 && b <= 248)
|
||||
{
|
||||
result = 240U + 256U * (uint)(b - 241) + (uint)b2;
|
||||
result = 240U + (256U * (uint)(b - 241)) + b2;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b3 = ReadByte();
|
||||
var b3 = ReadByte();
|
||||
if (b == 249)
|
||||
{
|
||||
result = 2288U + 256U * (uint)b2 + (uint)b3;
|
||||
result = 2288U + (256U * b2) + b3;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b4 = ReadByte();
|
||||
var b4 = ReadByte();
|
||||
if (b == 250)
|
||||
{
|
||||
result = (uint)((int)b2 + ((int)b3 << 8) + ((int)b4 << 16));
|
||||
result = (uint)(b2 + (b3 << 8) + (b4 << 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b5 = ReadByte();
|
||||
var b5 = ReadByte();
|
||||
if (b < 251)
|
||||
{
|
||||
throw new IndexOutOfRangeException("ReadPackedUInt32() failure: " + b);
|
||||
}
|
||||
result = (uint)((int)b2 + ((int)b3 << 8) + ((int)b4 << 16) + ((int)b5 << 24));
|
||||
result = (uint)(b2 + (b3 << 8) + (b4 << 16) + (b5 << 24));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,69 +86,69 @@ namespace QuantumUNET
|
||||
|
||||
public ulong ReadPackedUInt64()
|
||||
{
|
||||
byte b = ReadByte();
|
||||
var b = ReadByte();
|
||||
ulong result;
|
||||
if (b < 241)
|
||||
{
|
||||
result = (ulong)b;
|
||||
result = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b2 = ReadByte();
|
||||
var b2 = ReadByte();
|
||||
if (b >= 241 && b <= 248)
|
||||
{
|
||||
result = 240UL + 256UL * ((ulong)b - 241UL) + (ulong)b2;
|
||||
result = 240UL + (256UL * (b - 241UL)) + b2;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b3 = ReadByte();
|
||||
var b3 = ReadByte();
|
||||
if (b == 249)
|
||||
{
|
||||
result = 2288UL + 256UL * (ulong)b2 + (ulong)b3;
|
||||
result = 2288UL + (256UL * b2) + b3;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b4 = ReadByte();
|
||||
var b4 = ReadByte();
|
||||
if (b == 250)
|
||||
{
|
||||
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16);
|
||||
result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b5 = ReadByte();
|
||||
var b5 = ReadByte();
|
||||
if (b == 251)
|
||||
{
|
||||
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24);
|
||||
result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b6 = ReadByte();
|
||||
var b6 = ReadByte();
|
||||
if (b == 252)
|
||||
{
|
||||
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32);
|
||||
result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b7 = ReadByte();
|
||||
var b7 = ReadByte();
|
||||
if (b == 253)
|
||||
{
|
||||
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40);
|
||||
result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b8 = ReadByte();
|
||||
var b8 = ReadByte();
|
||||
if (b == 254)
|
||||
{
|
||||
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48);
|
||||
result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b9 = ReadByte();
|
||||
var b9 = ReadByte();
|
||||
if (b != 255)
|
||||
{
|
||||
throw new IndexOutOfRangeException("ReadPackedUInt64() failure: " + b);
|
||||
}
|
||||
result = (ulong)b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48) + ((ulong)b9 << 56);
|
||||
result = b2 + ((ulong)b3 << 8) + ((ulong)b4 << 16) + ((ulong)b5 << 24) + ((ulong)b6 << 32) + ((ulong)b7 << 40) + ((ulong)b8 << 48) + ((ulong)b9 << 56);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,61 +160,46 @@ namespace QuantumUNET
|
||||
return result;
|
||||
}
|
||||
|
||||
public NetworkInstanceId ReadNetworkId()
|
||||
{
|
||||
return new NetworkInstanceId(ReadPackedUInt32());
|
||||
}
|
||||
public NetworkInstanceId ReadNetworkId() => new NetworkInstanceId(ReadPackedUInt32());
|
||||
|
||||
public NetworkSceneId ReadSceneId()
|
||||
{
|
||||
return new NetworkSceneId(ReadPackedUInt32());
|
||||
}
|
||||
public NetworkSceneId ReadSceneId() => new NetworkSceneId(ReadPackedUInt32());
|
||||
|
||||
public byte ReadByte()
|
||||
{
|
||||
return m_buf.ReadByte();
|
||||
}
|
||||
public byte ReadByte() => m_buf.ReadByte();
|
||||
|
||||
public sbyte ReadSByte()
|
||||
{
|
||||
return (sbyte)m_buf.ReadByte();
|
||||
}
|
||||
public sbyte ReadSByte() => (sbyte)m_buf.ReadByte();
|
||||
|
||||
public short ReadInt16()
|
||||
{
|
||||
ushort num = 0;
|
||||
num |= (ushort)m_buf.ReadByte();
|
||||
num |= m_buf.ReadByte();
|
||||
num |= (ushort)(m_buf.ReadByte() << 8);
|
||||
return (short)num;
|
||||
}
|
||||
|
||||
public ushort ReadUInt16()
|
||||
{
|
||||
return (ushort)((uint)(ushort)(0U | (uint)m_buf.ReadByte()) | (uint)(ushort)((uint)m_buf.ReadByte() << 8));
|
||||
}
|
||||
public ushort ReadUInt16() => (ushort)((ushort)(0U | m_buf.ReadByte()) | (uint)(ushort)((uint)m_buf.ReadByte() << 8));
|
||||
|
||||
public int ReadInt32()
|
||||
{
|
||||
uint num = 0U;
|
||||
num |= (uint)m_buf.ReadByte();
|
||||
num |= (uint)((uint)m_buf.ReadByte() << 8);
|
||||
num |= (uint)((uint)m_buf.ReadByte() << 16);
|
||||
return (int)(num | (uint)((uint)m_buf.ReadByte() << 24));
|
||||
var num = 0U;
|
||||
num |= m_buf.ReadByte();
|
||||
num |= (uint)m_buf.ReadByte() << 8;
|
||||
num |= (uint)m_buf.ReadByte() << 16;
|
||||
return (int)(num | ((uint)m_buf.ReadByte() << 24));
|
||||
}
|
||||
|
||||
public uint ReadUInt32()
|
||||
{
|
||||
uint num = 0U;
|
||||
num |= (uint)m_buf.ReadByte();
|
||||
num |= (uint)((uint)m_buf.ReadByte() << 8);
|
||||
num |= (uint)((uint)m_buf.ReadByte() << 16);
|
||||
return num | (uint)((uint)m_buf.ReadByte() << 24);
|
||||
var num = 0U;
|
||||
num |= m_buf.ReadByte();
|
||||
num |= (uint)m_buf.ReadByte() << 8;
|
||||
num |= (uint)m_buf.ReadByte() << 16;
|
||||
return num | ((uint)m_buf.ReadByte() << 24);
|
||||
}
|
||||
|
||||
public long ReadInt64()
|
||||
{
|
||||
ulong num = 0UL;
|
||||
ulong num2 = (ulong)m_buf.ReadByte();
|
||||
var num = 0UL;
|
||||
var num2 = (ulong)m_buf.ReadByte();
|
||||
num |= num2;
|
||||
num2 = (ulong)m_buf.ReadByte() << 8;
|
||||
num |= num2;
|
||||
@ -254,8 +219,8 @@ namespace QuantumUNET
|
||||
|
||||
public ulong ReadUInt64()
|
||||
{
|
||||
ulong num = 0UL;
|
||||
ulong num2 = (ulong)m_buf.ReadByte();
|
||||
var num = 0UL;
|
||||
var num2 = (ulong)m_buf.ReadByte();
|
||||
num |= num2;
|
||||
num2 = (ulong)m_buf.ReadByte() << 8;
|
||||
num |= num2;
|
||||
@ -298,7 +263,7 @@ namespace QuantumUNET
|
||||
|
||||
public string ReadString()
|
||||
{
|
||||
ushort num = ReadUInt16();
|
||||
var num = ReadUInt16();
|
||||
string result;
|
||||
if (num == 0)
|
||||
{
|
||||
@ -310,25 +275,22 @@ namespace QuantumUNET
|
||||
{
|
||||
throw new IndexOutOfRangeException("ReadString() too long: " + num);
|
||||
}
|
||||
while ((int)num > s_StringReaderBuffer.Length)
|
||||
while (num > s_StringReaderBuffer.Length)
|
||||
{
|
||||
s_StringReaderBuffer = new byte[s_StringReaderBuffer.Length * 2];
|
||||
}
|
||||
m_buf.ReadBytes(s_StringReaderBuffer, (uint)num);
|
||||
char[] chars = s_Encoding.GetChars(s_StringReaderBuffer, 0, (int)num);
|
||||
m_buf.ReadBytes(s_StringReaderBuffer, num);
|
||||
var chars = s_Encoding.GetChars(s_StringReaderBuffer, 0, num);
|
||||
result = new string(chars);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public char ReadChar()
|
||||
{
|
||||
return (char)m_buf.ReadByte();
|
||||
}
|
||||
public char ReadChar() => (char)m_buf.ReadByte();
|
||||
|
||||
public bool ReadBoolean()
|
||||
{
|
||||
int num = (int)m_buf.ReadByte();
|
||||
var num = (int)m_buf.ReadByte();
|
||||
return num == 1;
|
||||
}
|
||||
|
||||
@ -338,14 +300,14 @@ namespace QuantumUNET
|
||||
{
|
||||
throw new IndexOutOfRangeException("NetworkReader ReadBytes " + count);
|
||||
}
|
||||
byte[] array = new byte[count];
|
||||
var array = new byte[count];
|
||||
m_buf.ReadBytes(array, (uint)count);
|
||||
return array;
|
||||
}
|
||||
|
||||
public byte[] ReadBytesAndSize()
|
||||
{
|
||||
ushort num = ReadUInt16();
|
||||
var num = ReadUInt16();
|
||||
byte[] result;
|
||||
if (num == 0)
|
||||
{
|
||||
@ -353,55 +315,28 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ReadBytes((int)num);
|
||||
result = ReadBytes(num);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Vector2 ReadVector2()
|
||||
{
|
||||
return new Vector2(ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Vector2 ReadVector2() => new Vector2(ReadSingle(), ReadSingle());
|
||||
|
||||
public Vector3 ReadVector3()
|
||||
{
|
||||
return new Vector3(ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Vector3 ReadVector3() => new Vector3(ReadSingle(), ReadSingle(), ReadSingle());
|
||||
|
||||
public Vector4 ReadVector4()
|
||||
{
|
||||
return new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Vector4 ReadVector4() => new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
|
||||
public Color ReadColor()
|
||||
{
|
||||
return new Color(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Color ReadColor() => new Color(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
|
||||
public Color32 ReadColor32()
|
||||
{
|
||||
return new Color32(ReadByte(), ReadByte(), ReadByte(), ReadByte());
|
||||
}
|
||||
public Color32 ReadColor32() => new Color32(ReadByte(), ReadByte(), ReadByte(), ReadByte());
|
||||
|
||||
public Quaternion ReadQuaternion()
|
||||
{
|
||||
return new Quaternion(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Quaternion ReadQuaternion() => new Quaternion(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
|
||||
public Rect ReadRect()
|
||||
{
|
||||
return new Rect(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Rect ReadRect() => new Rect(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
|
||||
public Plane ReadPlane()
|
||||
{
|
||||
return new Plane(ReadVector3(), ReadSingle());
|
||||
}
|
||||
public Plane ReadPlane() => new Plane(ReadVector3(), ReadSingle());
|
||||
|
||||
public Ray ReadRay()
|
||||
{
|
||||
return new Ray(ReadVector3(), ReadVector3());
|
||||
}
|
||||
public Ray ReadRay() => new Ray(ReadVector3(), ReadVector3());
|
||||
|
||||
public Matrix4x4 ReadMatrix4x4()
|
||||
{
|
||||
@ -450,7 +385,7 @@ namespace QuantumUNET
|
||||
|
||||
public Transform ReadTransform()
|
||||
{
|
||||
NetworkInstanceId networkInstanceId = ReadNetworkId();
|
||||
var networkInstanceId = ReadNetworkId();
|
||||
Transform result;
|
||||
if (networkInstanceId.IsEmpty())
|
||||
{
|
||||
@ -458,7 +393,7 @@ namespace QuantumUNET
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
|
||||
var gameObject = QSBClientScene.FindLocalObject(networkInstanceId);
|
||||
if (gameObject == null)
|
||||
{
|
||||
if (LogFilter.logDebug)
|
||||
@ -477,7 +412,7 @@ namespace QuantumUNET
|
||||
|
||||
public GameObject ReadGameObject()
|
||||
{
|
||||
NetworkInstanceId networkInstanceId = ReadNetworkId();
|
||||
var networkInstanceId = ReadNetworkId();
|
||||
GameObject result;
|
||||
if (networkInstanceId.IsEmpty())
|
||||
{
|
||||
@ -508,7 +443,7 @@ namespace QuantumUNET
|
||||
|
||||
public QSBNetworkIdentity ReadNetworkIdentity()
|
||||
{
|
||||
NetworkInstanceId networkInstanceId = ReadNetworkId();
|
||||
var networkInstanceId = ReadNetworkId();
|
||||
QSBNetworkIdentity result;
|
||||
if (networkInstanceId.IsEmpty())
|
||||
{
|
||||
@ -541,26 +476,13 @@ namespace QuantumUNET
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_buf.ToString();
|
||||
}
|
||||
public override string ToString() => m_buf.ToString();
|
||||
|
||||
public TMsg ReadMessage<TMsg>() where TMsg : QSBMessageBase, new()
|
||||
{
|
||||
TMsg result = Activator.CreateInstance<TMsg>();
|
||||
var result = Activator.CreateInstance<TMsg>();
|
||||
result.Deserialize(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
private QSBNetBuffer m_buf;
|
||||
|
||||
private const int k_MaxStringLength = 32768;
|
||||
|
||||
private const int k_InitialStringBufferSize = 1024;
|
||||
|
||||
private static byte[] s_StringReaderBuffer;
|
||||
|
||||
private static Encoding s_Encoding;
|
||||
}
|
||||
}
|
@ -18,13 +18,13 @@ namespace QuantumUNET
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_LocalObjects;
|
||||
return m_LocalObjects;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Shutdown()
|
||||
{
|
||||
this.ClearLocalObjects();
|
||||
ClearLocalObjects();
|
||||
ClearSpawners();
|
||||
}
|
||||
|
||||
@ -32,19 +32,19 @@ namespace QuantumUNET
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
this.localObjects[netId] = null;
|
||||
localObjects[netId] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
QSBNetworkIdentity networkIdentity = null;
|
||||
if (this.localObjects.ContainsKey(netId))
|
||||
if (localObjects.ContainsKey(netId))
|
||||
{
|
||||
networkIdentity = this.localObjects[netId];
|
||||
networkIdentity = localObjects[netId];
|
||||
}
|
||||
if (networkIdentity == null)
|
||||
{
|
||||
networkIdentity = obj.GetComponent<QSBNetworkIdentity>();
|
||||
this.localObjects[netId] = networkIdentity;
|
||||
localObjects[netId] = networkIdentity;
|
||||
}
|
||||
networkIdentity.UpdateClientServer(isClient, isServer);
|
||||
}
|
||||
@ -52,9 +52,9 @@ namespace QuantumUNET
|
||||
|
||||
internal GameObject FindLocalObject(NetworkInstanceId netId)
|
||||
{
|
||||
if (this.localObjects.ContainsKey(netId))
|
||||
if (localObjects.ContainsKey(netId))
|
||||
{
|
||||
QSBNetworkIdentity networkIdentity = this.localObjects[netId];
|
||||
var networkIdentity = localObjects[netId];
|
||||
if (networkIdentity != null)
|
||||
{
|
||||
return networkIdentity.gameObject;
|
||||
@ -87,11 +87,11 @@ namespace QuantumUNET
|
||||
internal bool RemoveLocalObjectAndDestroy(NetworkInstanceId netId)
|
||||
{
|
||||
bool result;
|
||||
if (this.localObjects.ContainsKey(netId))
|
||||
if (localObjects.ContainsKey(netId))
|
||||
{
|
||||
QSBNetworkIdentity networkIdentity = this.localObjects[netId];
|
||||
var networkIdentity = localObjects[netId];
|
||||
UnityEngine.Object.Destroy(networkIdentity.gameObject);
|
||||
result = this.localObjects.Remove(netId);
|
||||
result = localObjects.Remove(netId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -102,12 +102,12 @@ namespace QuantumUNET
|
||||
|
||||
internal void ClearLocalObjects()
|
||||
{
|
||||
this.localObjects.Clear();
|
||||
localObjects.Clear();
|
||||
}
|
||||
|
||||
internal static void RegisterPrefab(GameObject prefab, NetworkHash128 newAssetId)
|
||||
{
|
||||
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
var component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
if (component)
|
||||
{
|
||||
component.SetDynamicAssetId(newAssetId);
|
||||
@ -121,11 +121,11 @@ namespace QuantumUNET
|
||||
|
||||
internal static void RegisterPrefab(GameObject prefab)
|
||||
{
|
||||
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
var component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
if (component)
|
||||
{
|
||||
guidToPrefab[component.AssetId] = prefab;
|
||||
NetworkIdentity[] componentsInChildren = prefab.GetComponentsInChildren<NetworkIdentity>();
|
||||
var componentsInChildren = prefab.GetComponentsInChildren<NetworkIdentity>();
|
||||
if (componentsInChildren.Length > 1)
|
||||
{
|
||||
if (LogFilter.logWarn)
|
||||
@ -192,7 +192,7 @@ namespace QuantumUNET
|
||||
|
||||
internal static void UnregisterPrefab(GameObject prefab)
|
||||
{
|
||||
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
var component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
if (component == null)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
@ -209,7 +209,7 @@ namespace QuantumUNET
|
||||
|
||||
internal static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
|
||||
{
|
||||
QSBNetworkIdentity component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
var component = prefab.GetComponent<QSBNetworkIdentity>();
|
||||
if (component == null)
|
||||
{
|
||||
Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component");
|
||||
@ -250,7 +250,7 @@ namespace QuantumUNET
|
||||
bool result;
|
||||
if (unspawnHandlers.ContainsKey(assetId) && unspawnHandlers[assetId] != null)
|
||||
{
|
||||
UnSpawnDelegate unSpawnDelegate = unspawnHandlers[assetId];
|
||||
var unSpawnDelegate = unspawnHandlers[assetId];
|
||||
unSpawnDelegate(obj);
|
||||
result = true;
|
||||
}
|
||||
@ -263,9 +263,9 @@ namespace QuantumUNET
|
||||
|
||||
internal void DestroyAllClientObjects()
|
||||
{
|
||||
foreach (NetworkInstanceId key in this.localObjects.Keys)
|
||||
foreach (var key in localObjects.Keys)
|
||||
{
|
||||
QSBNetworkIdentity networkIdentity = this.localObjects[key];
|
||||
var networkIdentity = localObjects[key];
|
||||
if (networkIdentity != null && networkIdentity.gameObject != null)
|
||||
{
|
||||
if (!InvokeUnSpawnHandler(networkIdentity.AssetId, networkIdentity.gameObject))
|
||||
@ -282,14 +282,14 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ClearLocalObjects();
|
||||
ClearLocalObjects();
|
||||
}
|
||||
|
||||
internal void DumpAllClientObjects()
|
||||
{
|
||||
foreach (NetworkInstanceId networkInstanceId in this.localObjects.Keys)
|
||||
foreach (var networkInstanceId in localObjects.Keys)
|
||||
{
|
||||
QSBNetworkIdentity networkIdentity = this.localObjects[networkInstanceId];
|
||||
var networkIdentity = localObjects[networkInstanceId];
|
||||
if (networkIdentity != null)
|
||||
{
|
||||
Debug.Log(string.Concat(new object[]
|
||||
|
@ -75,29 +75,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Moved to NetworkMigrationManager")]
|
||||
public static bool sendPeerInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static bool dontListen
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DontListen;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_DontListen = value;
|
||||
}
|
||||
}
|
||||
public static bool dontListen { get; set; }
|
||||
|
||||
public static bool useWebSockets
|
||||
{
|
||||
@ -130,13 +108,7 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
|
||||
public static bool active
|
||||
{
|
||||
get
|
||||
{
|
||||
return s_Active;
|
||||
}
|
||||
}
|
||||
public static bool active { get; private set; }
|
||||
|
||||
public static bool localClientActive
|
||||
{
|
||||
@ -194,7 +166,7 @@ namespace QuantumUNET
|
||||
NetworkTransport.Shutdown();
|
||||
NetworkTransport.Init();
|
||||
s_Instance = null;
|
||||
s_Active = false;
|
||||
active = false;
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
@ -202,14 +174,14 @@ namespace QuantumUNET
|
||||
if (s_Instance != null)
|
||||
{
|
||||
s_Instance.InternalDisconnectAll();
|
||||
if (!m_DontListen)
|
||||
if (!dontListen)
|
||||
{
|
||||
s_Instance.m_SimpleServerSimple.Stop();
|
||||
}
|
||||
s_Instance = null;
|
||||
}
|
||||
m_DontListen = false;
|
||||
s_Active = false;
|
||||
dontListen = false;
|
||||
active = false;
|
||||
}
|
||||
|
||||
internal void RegisterMessageHandlers()
|
||||
@ -233,7 +205,7 @@ namespace QuantumUNET
|
||||
private void InternalListenRelay(string relayIp, int relayPort, NetworkID netGuid, SourceID sourceId, NodeID nodeId)
|
||||
{
|
||||
m_SimpleServerSimple.ListenRelay(relayIp, relayPort, netGuid, sourceId, nodeId);
|
||||
s_Active = true;
|
||||
active = true;
|
||||
RegisterMessageHandlers();
|
||||
}
|
||||
|
||||
@ -249,7 +221,7 @@ namespace QuantumUNET
|
||||
|
||||
internal bool InternalListen(string ipAddress, int serverPort)
|
||||
{
|
||||
if (m_DontListen)
|
||||
if (dontListen)
|
||||
{
|
||||
m_SimpleServerSimple.Initialize();
|
||||
}
|
||||
@ -258,7 +230,7 @@ namespace QuantumUNET
|
||||
return false;
|
||||
}
|
||||
maxPacketSize = hostTopology.DefaultConfig.PacketSize;
|
||||
s_Active = true;
|
||||
active = true;
|
||||
RegisterMessageHandlers();
|
||||
return true;
|
||||
}
|
||||
@ -271,7 +243,7 @@ namespace QuantumUNET
|
||||
internal QSBNetworkClient BecomeHostInternal(QSBNetworkClient oldClient, int port, int oldConnectionId, QSBPeerInfoMessage[] peers)
|
||||
{
|
||||
QSBNetworkClient result;
|
||||
if (s_Active)
|
||||
if (active)
|
||||
{
|
||||
if (LogFilter.logError)
|
||||
{
|
||||
@ -741,7 +713,7 @@ namespace QuantumUNET
|
||||
internal void InternalUpdate()
|
||||
{
|
||||
m_SimpleServerSimple.Update();
|
||||
if (m_DontListen)
|
||||
if (dontListen)
|
||||
{
|
||||
m_SimpleServerSimple.UpdateConnections();
|
||||
}
|
||||
@ -1916,19 +1888,10 @@ namespace QuantumUNET
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("moved to NetworkMigrationManager")]
|
||||
public void SendNetworkInfo(NetworkConnection targetConnection)
|
||||
{
|
||||
}
|
||||
|
||||
private static bool s_Active;
|
||||
|
||||
private static volatile QSBNetworkServer s_Instance;
|
||||
|
||||
private static object s_Sync = new UnityEngine.Object();
|
||||
|
||||
private static bool m_DontListen;
|
||||
|
||||
private bool m_LocalClientActive;
|
||||
|
||||
private List<QSBNetworkConnection> m_LocalConnectionsFakeList = new List<QSBNetworkConnection>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user