WriteByte() public method

1字节写入
public WriteByte ( int v ) : void
v int
return void
        public sealed override void WriteToBuffer(NetBuffer buffer, SyncContext context)
        {
            List <byte> updatedFields = new List <byte>();

            for (byte i = 0; i < Fields.Length; i++)
            {
                if (Fields[i].ContainsRevision(context.Revision))
                {
                    updatedFields.Add(i);
                }
            }

            bool skipHeaders = updatedFields.Count == Fields.Length;

            buffer.WriteByte((byte)updatedFields.Count);

            if (skipHeaders)
            {
                foreach (Synchroniser field in Fields)
                {
                    field.WriteToBuffer(buffer, context);
                }
            }
            else
            {
                foreach (byte index in updatedFields)
                {
                    buffer.WriteByte(index);
                    Fields[index].WriteToBuffer(buffer, context);
                }
            }
        }
示例#2
0
    public void CanWriteByte()
    {
        buffer.WriteByte(byte.MaxValue);

        Assert.AreEqual(byte.MaxValue, bytes[0], "WriteByte function cannot write byte to the provided array");
        Assert.AreEqual(1, buffer.Position, "WriteByte function didn't shift the NetBuffer's position");
    }
 public sealed override void WriteToBuffer(NetBuffer buffer)
 {
     buffer.WriteByte((byte)Fields.Length);
     foreach (Synchroniser field in Fields)
     {
         field.WriteToBuffer(buffer);
     }
 }
示例#4
0
    public void BufferSizeGrows_NewBufferLengthRoundedUp(int length, int expectedLength)
    {
        var testBuffer = new NetBuffer(new byte[length]);

        for (var i = 0; i < length; i++)
        {
            testBuffer.WriteByte(byte.MaxValue);
        }

        Assert.AreEqual(expectedLength, testBuffer.Length, "New NetBuffer's length has unexpected value");
    }
 public override void WriteToBuffer(NetBuffer buffer)
 {
     buffer.WriteByte(value ? (byte)0x01 : (byte)0x00);
 }
 public override void WriteToBuffer(NetBuffer buffer)
 {
     buffer.WriteByte(value);
 }