public static void Serialize(Stream stream, AutoTurret instance) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); stream.WriteByte(10); memoryStream.SetLength((long)0); Vector3Serialized.Serialize(memoryStream, instance.aimPos); 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.aimDir); uint num = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num); stream.Write(memoryStream.GetBuffer(), 0, (int)num); 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.Serialize(memoryStream, item); uint length1 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length1); stream.Write(memoryStream.GetBuffer(), 0, (int)length1); } } Pool.FreeMemoryStream(ref memoryStream); }
public static PlayerNameID DeserializeLength(Stream stream, int length, PlayerNameID instance, bool isDelta) { long position = stream.Position + (long)length; while (stream.Position < position) { int num = stream.ReadByte(); if (num == -1) { throw new EndOfStreamException(); } if (num == 10) { instance.username = ProtocolParser.ReadString(stream); } else if (num == 16) { instance.userid = ProtocolParser.ReadUInt64(stream); } else { Key key = ProtocolParser.ReadKey((byte)num, stream); if (key.Field == 0) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }
public static PlayerNameID Deserialize(Stream stream, PlayerNameID instance, bool isDelta) { while (true) { int num = stream.ReadByte(); if (num == -1) { break; } if (num == 10) { instance.username = ProtocolParser.ReadString(stream); } else if (num == 16) { instance.userid = ProtocolParser.ReadUInt64(stream); } else { Key key = ProtocolParser.ReadKey((byte)num, stream); if (key.Field == 0) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } } return(instance); }
public PlayerNameID Copy() { PlayerNameID playerNameID = Pool.Get <PlayerNameID>(); this.CopyTo(playerNameID); return(playerNameID); }
public static PlayerNameID DeserializeLength(Stream stream, int length) { PlayerNameID playerNameID = Pool.Get <PlayerNameID>(); PlayerNameID.DeserializeLength(stream, length, playerNameID, false); return(playerNameID); }
public static PlayerNameID Deserialize(Stream stream) { PlayerNameID playerNameID = Pool.Get <PlayerNameID>(); PlayerNameID.Deserialize(stream, playerNameID, false); return(playerNameID); }
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 static PlayerNameID Deserialize(byte[] buffer, PlayerNameID instance, bool isDelta = false) { using (MemoryStream memoryStream = new MemoryStream(buffer)) { PlayerNameID.Deserialize(memoryStream, instance, isDelta); } return(instance); }
public virtual void WriteToStreamDelta(Stream stream, PlayerNameID previous) { if (previous == null) { PlayerNameID.Serialize(stream, this); return; } PlayerNameID.SerializeDelta(stream, this, previous); }
public static byte[] SerializeToBytes(PlayerNameID instance) { byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { PlayerNameID.Serialize(memoryStream, instance); array = memoryStream.ToArray(); } return(array); }
public static PlayerNameID Deserialize(byte[] buffer) { PlayerNameID playerNameID = Pool.Get <PlayerNameID>(); using (MemoryStream memoryStream = new MemoryStream(buffer)) { PlayerNameID.Deserialize(memoryStream, playerNameID, false); } return(playerNameID); }
public static void ResetToPool(PlayerNameID instance) { if (!instance.ShouldPool) { return; } instance.username = string.Empty; instance.userid = (ulong)0; Pool.Free <PlayerNameID>(ref instance); }
public static BuildingPrivilege DeserializeLengthDelimited(Stream stream, BuildingPrivilege instance, bool isDelta) { if (!isDelta && instance.users == null) { instance.users = Pool.Get <List <PlayerNameID> >(); } long position = (long)ProtocolParser.ReadUInt32(stream); position += stream.Position; while (stream.Position < position) { int num = stream.ReadByte(); if (num == -1) { throw new EndOfStreamException(); } if (num <= 21) { if (num == 10) { instance.users.Add(PlayerNameID.DeserializeLengthDelimited(stream)); continue; } else if (num == 21) { instance.upkeepPeriodMinutes = ProtocolParser.ReadSingle(stream); continue; } } else if (num == 29) { instance.costFraction = ProtocolParser.ReadSingle(stream); continue; } else if (num == 37) { instance.protectedMinutes = ProtocolParser.ReadSingle(stream); continue; } Key key = ProtocolParser.ReadKey((byte)num, stream); if (key.Field == 0) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }
public static AutoTurret DeserializeLengthDelimited(Stream stream, AutoTurret instance, bool isDelta) { if (!isDelta && instance.users == null) { instance.users = Pool.Get <List <PlayerNameID> >(); } long position = (long)ProtocolParser.ReadUInt32(stream); position += stream.Position; while (stream.Position < position) { int num = stream.ReadByte(); if (num == -1) { throw new EndOfStreamException(); } if (num <= 18) { if (num == 10) { Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.aimPos, isDelta); continue; } else if (num == 18) { Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.aimDir, isDelta); continue; } } else if (num == 24) { instance.targetID = ProtocolParser.ReadUInt32(stream); continue; } else if (num == 34) { instance.users.Add(PlayerNameID.DeserializeLengthDelimited(stream)); continue; } Key key = ProtocolParser.ReadKey((byte)num, stream); if (key.Field == 0) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }
public static void Serialize(Stream stream, PlayerNameID instance) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.username == null) { throw new ArgumentNullException("username", "Required by proto specification."); } stream.WriteByte(10); ProtocolParser.WriteString(stream, instance.username); stream.WriteByte(16); ProtocolParser.WriteUInt64(stream, instance.userid); Pool.FreeMemoryStream(ref memoryStream); }
public void FromProto(Stream stream, bool isDelta = false) { PlayerNameID.Deserialize(stream, this, isDelta); }
public void ResetToPool() { PlayerNameID.ResetToPool(this); }
public static void SerializeLengthDelimited(Stream stream, PlayerNameID instance) { byte[] bytes = PlayerNameID.SerializeToBytes(instance); ProtocolParser.WriteUInt32(stream, (uint)bytes.Length); stream.Write(bytes, 0, (int)bytes.Length); }
public void CopyTo(PlayerNameID instance) { instance.username = this.username; instance.userid = this.userid; }
public byte[] ToProtoBytes() { return(PlayerNameID.SerializeToBytes(this)); }
public void ToProto(Stream stream) { PlayerNameID.Serialize(stream, this); }
public virtual void WriteToStream(Stream stream) { PlayerNameID.Serialize(stream, this); }
public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false) { PlayerNameID.DeserializeLength(stream, size, this, isDelta); }