public static void Serialize(Stream stream, Ray instance) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); stream.WriteByte(10); memoryStream.SetLength((long)0); Vector3Serialized.Serialize(memoryStream, instance.origin); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); stream.WriteByte(18); memoryStream.SetLength((long)0); Vector3Serialized.Serialize(memoryStream, instance.direction); uint num = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num); stream.Write(memoryStream.GetBuffer(), 0, (int)num); Pool.FreeMemoryStream(ref memoryStream); }
public static void SerializeDelta(Stream stream, Vector3 instance, Vector3 previous) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.x != previous.x) { stream.WriteByte(13); ProtocolParser.WriteSingle(stream, instance.x); } if (instance.y != previous.y) { stream.WriteByte(21); ProtocolParser.WriteSingle(stream, instance.y); } if (instance.z != previous.z) { stream.WriteByte(29); ProtocolParser.WriteSingle(stream, instance.z); } Pool.FreeMemoryStream(ref memoryStream); }
public static void SerializeDelta(Stream stream, Vector3 instance, Vector3 previous) { var msField = Pool.Get <MemoryStream>(); if (instance.x != previous.x) { // Key for field: 1, Fixed32 stream.WriteByte(13); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteSingle(stream, instance.x); } if (instance.y != previous.y) { // Key for field: 2, Fixed32 stream.WriteByte(21); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteSingle(stream, instance.y); } if (instance.z != previous.z) { // Key for field: 3, Fixed32 stream.WriteByte(29); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteSingle(stream, instance.z); } Pool.FreeMemoryStream(ref msField); }