Exemplo n.º 1
0
        public static ulong ReadUInt64(this NetworkReader reader)
        {
            ulong value = 0;

            value |= reader.ReadByte();
            value |= ((ulong)reader.ReadByte()) << 8;
            value |= ((ulong)reader.ReadByte()) << 16;
            value |= ((ulong)reader.ReadByte()) << 24;
            value |= ((ulong)reader.ReadByte()) << 32;
            value |= ((ulong)reader.ReadByte()) << 40;
            value |= ((ulong)reader.ReadByte()) << 48;
            value |= ((ulong)reader.ReadByte()) << 56;
            return(value);
        }
Exemplo n.º 2
0
        public static NetworkBehaviour ReadNetworkBehaviour(this NetworkReader reader)
        {
            NetworkIdentity identity = reader.ReadNetworkIdentity();

            if (identity == null)
            {
                return(null);
            }

            byte componentIndex = reader.ReadByte();

            return(identity.NetworkBehaviours[componentIndex]);
        }
Exemplo n.º 3
0
        public static NetworkBehaviour ReadNetworkBehaviour(this NetworkReader reader)
        {
            // we can't use ReadNetworkIdentity here, because we need to know if netid was 0 or not
            // if it is not 0 we need to read component index even if NI is null, or it'll fail to deserilize next part
            uint netId = reader.ReadPackedUInt32();

            if (netId == 0)
            {
                return(null);
            }

            // always read index if netid is not 0
            byte componentIndex = reader.ReadByte();

            NetworkIdentity identity = FindNetworkIdentity(reader.ObjectLocator, netId);

            if (identity is null)
            {
                return(null);
            }

            return(identity.NetworkBehaviours[componentIndex]);
        }
Exemplo n.º 4
0
        public static ulong ReadPackedUInt64(this NetworkReader reader)
        {
            var a0 = reader.ReadByte();

            if (a0 < 241)
            {
                return(a0);
            }

            var a1 = reader.ReadByte();

            if (a0 >= 241 && a0 <= 248)
            {
                return(240 + ((a0 - (ulong)241) << 8) + a1);
            }

            var a2 = reader.ReadByte();

            if (a0 == 249)
            {
                return(2288 + ((ulong)a1 << 8) + a2);
            }

            var a3 = reader.ReadByte();

            if (a0 == 250)
            {
                return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16));
            }

            var a4 = reader.ReadByte();

            if (a0 == 251)
            {
                return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24));
            }

            var a5 = reader.ReadByte();

            if (a0 == 252)
            {
                return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24) + (((ulong)a5) << 32));
            }

            var a6 = reader.ReadByte();

            if (a0 == 253)
            {
                return(a1 + (((ulong)a2) << 8) + (((ulong)a3) << 16) + (((ulong)a4) << 24) + (((ulong)a5) << 32) + (((ulong)a6) << 40));
            }

            var 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));
            }

            var 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 DataMisalignedException("ReadPackedUInt64() failure: " + a0);
        }
Exemplo n.º 5
0
 public static byte ReadByteExtension(this NetworkReader reader) => reader.ReadByte();
Exemplo n.º 6
0
 public static Color32 ReadColor32(this NetworkReader reader) => new Color32(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
Exemplo n.º 7
0
 public static bool ReadBoolean(this NetworkReader reader) => reader.ReadByte() != 0;
Exemplo n.º 8
0
 public static sbyte ReadSByte(this NetworkReader reader) => (sbyte)reader.ReadByte();