예제 #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));
 }
예제 #15
0
 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);
        }
예제 #28
0
 protected virtual TKey DeserializeKey(NetworkReader reader) => default;
예제 #29
0
 public static Vector2Int ReadVector2Int(this NetworkReader reader) => new Vector2Int(reader.ReadPackedInt32(), reader.ReadPackedInt32());
예제 #30
0
        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);
        }