示例#1
0
 public virtual bool InvokeCommand(int cmdHash, NetworkReader reader)
 {
     return(InvokeHandlerDelegate(cmdHash, MirrorInvokeType.Command, reader));
 }
示例#2
0
        // 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));
        }
示例#3
0
 public static Vector4 ReadVector4(this NetworkReader reader) => new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
示例#4
0
 public static int ReadInt32(this NetworkReader reader) => (int)reader.ReadUInt32();
示例#5
0
        // 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)));
        }
示例#6
0
 public static sbyte ReadSByte(this NetworkReader reader) => (sbyte)reader.ReadByte();
示例#7
0
 public static bool ReadBoolean(this NetworkReader reader) => reader.ReadByte() != 0;
示例#8
0
 public override void Deserialize(NetworkReader reader)
 {
 }
示例#9
0
 // De-serialize the contents of the reader into this message
 public virtual void Deserialize(NetworkReader reader)
 {
 }
示例#10
0
 public override void Deserialize(NetworkReader reader)
 {
     value = reader.ReadPackedInt32();
 }
示例#11
0
 public override void Deserialize(NetworkReader reader)
 {
     value = reader.ReadDouble();
 }
示例#12
0
 // 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);
 }
示例#13
0
 public virtual bool InvokeSyncEvent(int eventHash, NetworkReader reader)
 {
     return(InvokeHandlerDelegate(eventHash, MirrorInvokeType.SyncEvent, reader));
 }
示例#14
0
 public virtual bool InvokeRPC(int rpcHash, NetworkReader reader)
 {
     return(InvokeHandlerDelegate(rpcHash, MirrorInvokeType.ClientRpc, reader));
 }
 protected virtual TValue DeserializeItem(NetworkReader reader) => default;
示例#16
0
 public override void Deserialize(NetworkReader reader)
 {
     netId = reader.ReadPackedUInt32();
 }
示例#17
0
 public static byte ReadByte(this NetworkReader reader) => reader.ReadByte();
示例#18
0
 public override void Deserialize(NetworkReader reader)
 {
     netId     = reader.ReadPackedUInt32();
     authority = reader.ReadBoolean();
 }
示例#19
0
 public static char ReadChar(this NetworkReader reader) => (char)reader.ReadUInt16();
示例#20
0
 public override void Deserialize(NetworkReader reader)
 {
     netId   = reader.ReadPackedUInt32();
     payload = reader.ReadBytesAndSize();
 }
示例#21
0
 public static short ReadInt16(this NetworkReader reader) => (short)reader.ReadUInt16();
示例#22
0
 public override void Deserialize(NetworkReader reader)
 {
     clientTime = reader.ReadDouble();
     serverTime = reader.ReadDouble();
 }
示例#23
0
 public static long ReadInt64(this NetworkReader reader) => (long)reader.ReadUInt64();
示例#24
0
 public override void Deserialize(NetworkReader reader)
 {
     value = reader.ReadString();
 }
示例#25
0
 // 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());
示例#26
0
 public override void Deserialize(NetworkReader reader)
 {
     value = reader.ReadBytesAndSize();
 }
示例#27
0
        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;
示例#29
0
 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);
        }