コード例 #1
0
 public static void WriteColor32(this NetworkWriter writer, Color32 value)
 {
     writer.WriteByte(value.r);
     writer.WriteByte(value.g);
     writer.WriteByte(value.b);
     writer.WriteByte(value.a);
 }
コード例 #2
0
 public static void WriteNetworkBehaviour(this NetworkWriter writer, NetworkBehaviour value)
 {
     if (value == null)
     {
         writer.WriteNetworkIdentity(null);
         return;
     }
     writer.WriteNetworkIdentity(value.Identity);
     writer.WriteByte((byte)value.ComponentIndex);
 }
コード例 #3
0
ファイル: PackedExtensions.cs プロジェクト: Hertzole/MirrorNG
        public static void WritePackedUInt64(this NetworkWriter writer, ulong value)
        {
            // numbers are usually small,  have special encoding for smaller numbers
            if (value <= 240)
            {
                writer.WriteByte((byte)value);
                return;
            }
            if (value <= 2287)
            {
                writer.WriteByte((byte)(((value - 240) >> 8) + 241));
                writer.WriteByte((byte)(value - 240));
                return;
            }
            if (value <= 67823)
            {
                writer.WriteByte(249);
                writer.WriteByte((byte)((value - 2288) >> 8));
                writer.WriteByte((byte)(value - 2288));
                return;
            }

            // first byte determines how many bytes 250 => 3 bytes, 251 => 4 bytes
            // etc...
            if (value <= 0xffffff)
            {
                writer.WriteByte(250);
            }
            else if (value <= 0xffffffff)
            {
                writer.WriteByte(251);
            }
            else if (value <= 0xffffffffff)
            {
                writer.WriteByte(252);
            }
            else if (value <= 0xffffffffffff)
            {
                writer.WriteByte(253);
            }
            else if (value <= 0xffffffffffffff)
            {
                writer.WriteByte(254);
            }
            else
            {
                writer.WriteByte(255);
            }

            // write the data
            while (value > 0)
            {
                writer.WriteByte((byte)value);
                value >>= 8;
            }
        }
コード例 #4
0
 public static void WriteByteExtension(this NetworkWriter writer, byte value) => writer.WriteByte(value);