public static void SerializeDelta(Stream stream, BuildingPrivilege instance, BuildingPrivilege previous) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.users != null) { for (int i = 0; i < instance.users.Count; i++) { PlayerNameID item = instance.users[i]; stream.WriteByte(10); memoryStream.SetLength((long)0); PlayerNameID.SerializeDelta(memoryStream, item, item); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); } } if (instance.upkeepPeriodMinutes != previous.upkeepPeriodMinutes) { stream.WriteByte(21); ProtocolParser.WriteSingle(stream, instance.upkeepPeriodMinutes); } if (instance.costFraction != previous.costFraction) { stream.WriteByte(29); ProtocolParser.WriteSingle(stream, instance.costFraction); } if (instance.protectedMinutes != previous.protectedMinutes) { stream.WriteByte(37); ProtocolParser.WriteSingle(stream, instance.protectedMinutes); } Pool.FreeMemoryStream(ref memoryStream); }
public virtual void WriteToStreamDelta(Stream stream, PlayerNameID previous) { if (previous == null) { PlayerNameID.Serialize(stream, this); return; } PlayerNameID.SerializeDelta(stream, this, previous); }
public static void SerializeDelta(Stream stream, AutoTurret instance, AutoTurret previous) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.aimPos != previous.aimPos) { stream.WriteByte(10); memoryStream.SetLength((long)0); Vector3Serialized.SerializeDelta(memoryStream, instance.aimPos, previous.aimPos); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); } if (instance.aimDir != previous.aimDir) { stream.WriteByte(18); memoryStream.SetLength((long)0); Vector3Serialized.SerializeDelta(memoryStream, instance.aimDir, previous.aimDir); uint num = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num); stream.Write(memoryStream.GetBuffer(), 0, (int)num); } if (instance.targetID != previous.targetID) { stream.WriteByte(24); ProtocolParser.WriteUInt32(stream, instance.targetID); } if (instance.users != null) { for (int i = 0; i < instance.users.Count; i++) { PlayerNameID item = instance.users[i]; stream.WriteByte(34); memoryStream.SetLength((long)0); PlayerNameID.SerializeDelta(memoryStream, item, item); uint length1 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length1); stream.Write(memoryStream.GetBuffer(), 0, (int)length1); } } Pool.FreeMemoryStream(ref memoryStream); }