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