public virtual bool InvokeCommand(int cmdHash, NetworkReader reader) { return(InvokeHandlerDelegate(cmdHash, MirrorInvokeType.Command, reader)); }
// zigzag decoding https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba public static long ReadPackedInt64(this NetworkReader reader) { ulong data = reader.ReadPackedUInt64(); return(((long)(data >> 1)) ^ -((long)data & 1)); }
public static Vector4 ReadVector4(this NetworkReader reader) => new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
public static int ReadInt32(this NetworkReader reader) => (int)reader.ReadUInt32();
// zigzag decoding https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba public static int ReadPackedInt32(this NetworkReader reader) { uint data = reader.ReadPackedUInt32(); return((int)((data >> 1) ^ -(data & 1))); }
public static sbyte ReadSByte(this NetworkReader reader) => (sbyte)reader.ReadByte();
public static bool ReadBoolean(this NetworkReader reader) => reader.ReadByte() != 0;
public override void Deserialize(NetworkReader reader) { }
// De-serialize the contents of the reader into this message public virtual void Deserialize(NetworkReader reader) { }
public override void Deserialize(NetworkReader reader) { value = reader.ReadPackedInt32(); }
public override void Deserialize(NetworkReader reader) { value = reader.ReadDouble(); }
// InvokeCmd/Rpc/SyncEventDelegate can all use the same function here internal bool InvokeHandlerDelegate(int cmdHash, MirrorInvokeType invokeType, NetworkReader reader) { if (GetInvokerForHash(cmdHash, invokeType, out Invoker invoker) && invoker.invokeClass.IsInstanceOfType(this)) { invoker.invokeFunction(this, reader); return(true); } return(false); }
public virtual bool InvokeSyncEvent(int eventHash, NetworkReader reader) { return(InvokeHandlerDelegate(eventHash, MirrorInvokeType.SyncEvent, reader)); }
public virtual bool InvokeRPC(int rpcHash, NetworkReader reader) { return(InvokeHandlerDelegate(rpcHash, MirrorInvokeType.ClientRpc, reader)); }
protected virtual TValue DeserializeItem(NetworkReader reader) => default;
public override void Deserialize(NetworkReader reader) { netId = reader.ReadPackedUInt32(); }
public static byte ReadByte(this NetworkReader reader) => reader.ReadByte();
public override void Deserialize(NetworkReader reader) { netId = reader.ReadPackedUInt32(); authority = reader.ReadBoolean(); }
public static char ReadChar(this NetworkReader reader) => (char)reader.ReadUInt16();
public override void Deserialize(NetworkReader reader) { netId = reader.ReadPackedUInt32(); payload = reader.ReadBytesAndSize(); }
public static short ReadInt16(this NetworkReader reader) => (short)reader.ReadUInt16();
public override void Deserialize(NetworkReader reader) { clientTime = reader.ReadDouble(); serverTime = reader.ReadDouble(); }
public static long ReadInt64(this NetworkReader reader) => (long)reader.ReadUInt64();
public override void Deserialize(NetworkReader reader) { value = reader.ReadString(); }
// http://sqlite.org/src4/doc/trunk/www/varint.wiki // NOTE: big endian. // Use checked() to force it to throw OverflowException if data is invalid public static uint ReadPackedUInt32(this NetworkReader reader) => checked ((uint)reader.ReadPackedUInt64());
public override void Deserialize(NetworkReader reader) { value = reader.ReadBytesAndSize(); }
public static ulong ReadPackedUInt64(this NetworkReader reader) { byte a0 = reader.ReadByte(); if (a0 < 241) { return(a0); } byte a1 = reader.ReadByte(); if (a0 >= 241 && a0 <= 248) { return(240 + ((a0 - (ulong)241) << 8) + a1); } byte a2 = reader.ReadByte(); if (a0 == 249) { return(2288 + ((ulong)a1 << 8) + a2); } byte a3 = reader.ReadByte(); if (a0 == 250) { return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16)); } byte a4 = reader.ReadByte(); if (a0 == 251) { return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24)); } byte a5 = reader.ReadByte(); if (a0 == 252) { return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24) + (((ulong)a5) << 32)); } byte a6 = reader.ReadByte(); if (a0 == 253) { return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24) + (((ulong)a5) << 32) + (((ulong)a6) << 40)); } byte a7 = reader.ReadByte(); if (a0 == 254) { return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24) + (((ulong)a5) << 32) + (((ulong)a6) << 40) + (((ulong)a7) << 48)); } byte a8 = reader.ReadByte(); if (a0 == 255) { return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24) + (((ulong)a5) << 32) + (((ulong)a6) << 40) + (((ulong)a7) << 48) + (((ulong)a8) << 56)); } throw new IndexOutOfRangeException("ReadPackedUInt64() failure: " + a0); }
protected virtual TKey DeserializeKey(NetworkReader reader) => default;
public static Vector2Int ReadVector2Int(this NetworkReader reader) => new Vector2Int(reader.ReadPackedInt32(), reader.ReadPackedInt32());
void HandleAnimMsg(int stateHash, float normalizedTime, int layerId, float weight, NetworkReader reader) { if (hasAuthority && clientAuthority) { return; } // usually transitions will be triggered by parameters, if not, play anims directly. // NOTE: this plays "animations", not transitions, so any transitions will be skipped. // NOTE: there is no API to play a transition(?) if (stateHash != 0 && animator.enabled) { animator.Play(stateHash, layerId, normalizedTime); } animator.SetLayerWeight(layerId, weight); ReadParameters(reader); }