public static void Serialize(Stream stream, BuildingBlock instance) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); stream.WriteByte(8); ProtocolParser.WriteUInt64(stream, (ulong)instance.model); stream.WriteByte(16); ProtocolParser.WriteUInt64(stream, (ulong)instance.grade); stream.WriteByte(24); ProtocolParser.WriteBool(stream, instance.beingDemolished); Pool.FreeMemoryStream(ref memoryStream); }
public static BuildingBlock DeserializeLengthDelimited(Stream stream, BuildingBlock instance, bool isDelta) { 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 == 8) { instance.model = (int)ProtocolParser.ReadUInt64(stream); } else if (num == 16) { instance.grade = (int)ProtocolParser.ReadUInt64(stream); } else if (num == 24) { instance.beingDemolished = ProtocolParser.ReadBool(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 void CopyTo(BuildingBlock instance) { instance.model = this.model; instance.grade = this.grade; instance.beingDemolished = this.beingDemolished; }
public virtual void WriteToStream(Stream stream) { BuildingBlock.Serialize(stream, this); }
public byte[] ToProtoBytes() { return(BuildingBlock.SerializeToBytes(this)); }
public void ToProto(Stream stream) { BuildingBlock.Serialize(stream, this); }
public static void SerializeLengthDelimited(Stream stream, BuildingBlock instance) { byte[] bytes = BuildingBlock.SerializeToBytes(instance); ProtocolParser.WriteUInt32(stream, (uint)bytes.Length); stream.Write(bytes, 0, (int)bytes.Length); }
public void ResetToPool() { BuildingBlock.ResetToPool(this); }
public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false) { BuildingBlock.DeserializeLength(stream, size, this, isDelta); }
public void FromProto(Stream stream, bool isDelta = false) { BuildingBlock.Deserialize(stream, this, isDelta); }