UnityEngine.Networking.NetworkWriter.WritePackedUInt64 C# (CSharp) Method

WritePackedUInt64() public method

This writes the 64-bit value to the stream using variable-length-encoding.

public WritePackedUInt64 ( ulong value ) : void
value ulong Value to write.
return void
        public void WritePackedUInt64(ulong value)
        {
            if (value <= 240L)
            {
                this.Write((byte) value);
            }
            else if (value <= 0x8efL)
            {
                this.Write((byte) (((value - ((ulong) 240L)) / ((ulong) 0x100L)) + ((ulong) 0xf1L)));
                this.Write((byte) ((value - ((ulong) 240L)) % ((ulong) 0x100L)));
            }
            else if (value <= 0x108efL)
            {
                this.Write((byte) 0xf9);
                this.Write((byte) ((value - ((ulong) 0x8f0L)) / ((ulong) 0x100L)));
                this.Write((byte) ((value - ((ulong) 0x8f0L)) % ((ulong) 0x100L)));
            }
            else if (value <= 0xffffffL)
            {
                this.Write((byte) 250);
                this.Write((byte) (value & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 8) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x10) & ((ulong) 0xffL)));
            }
            else if (value <= 0xffffffffL)
            {
                this.Write((byte) 0xfb);
                this.Write((byte) (value & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 8) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x10) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x18) & ((ulong) 0xffL)));
            }
            else if (value <= 0xffffffffffL)
            {
                this.Write((byte) 0xfc);
                this.Write((byte) (value & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 8) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x10) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x18) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x20) & ((ulong) 0xffL)));
            }
            else if (value <= 0xffffffffffffL)
            {
                this.Write((byte) 0xfd);
                this.Write((byte) (value & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 8) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x10) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x18) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x20) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 40) & ((ulong) 0xffL)));
            }
            else if (value <= 0xffffffffffffffL)
            {
                this.Write((byte) 0xfe);
                this.Write((byte) (value & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 8) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x10) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x18) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x20) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 40) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x30) & ((ulong) 0xffL)));
            }
            else
            {
                this.Write((byte) 0xff);
                this.Write((byte) (value & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 8) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x10) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x18) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x20) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 40) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x30) & ((ulong) 0xffL)));
                this.Write((byte) ((value >> 0x38) & ((ulong) 0xffL)));
            }
        }

Usage Example

 public virtual bool OnSerialize(NetworkWriter writer, bool initialState)
 {
     if (!initialState)
     {
         writer.WritePackedUInt64(0);
     }
     return(false);
 }
All Usage Examples Of UnityEngine.Networking.NetworkWriter::WritePackedUInt64