public static void ResetToPool(WorldItem instance) { if (!instance.ShouldPool) { return; } if (instance.item != null) { instance.item.ResetToPool(); instance.item = null; } Pool.Free <WorldItem>(ref instance); }
public void CopyTo(WorldItem instance) { if (this.item == null) { instance.item = null; return; } if (instance.item == null) { instance.item = this.item.Copy(); return; } this.item.CopyTo(instance.item); }
public static void SerializeDelta(Stream stream, WorldItem instance, WorldItem previous) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.item != null) { stream.WriteByte(10); memoryStream.SetLength((long)0); Item.SerializeDelta(memoryStream, instance.item, previous.item); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); } Pool.FreeMemoryStream(ref memoryStream); }
public static WorldItem DeserializeLengthDelimited(Stream stream, WorldItem 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 != 10) { 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); } else if (instance.item != null) { Item.DeserializeLengthDelimited(stream, instance.item, isDelta); } else { instance.item = Item.DeserializeLengthDelimited(stream); } } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }
public virtual void WriteToStream(Stream stream) { WorldItem.Serialize(stream, this); }
public byte[] ToProtoBytes() { return(WorldItem.SerializeToBytes(this)); }
public void ToProto(Stream stream) { WorldItem.Serialize(stream, this); }
public static void SerializeLengthDelimited(Stream stream, WorldItem instance) { byte[] bytes = WorldItem.SerializeToBytes(instance); ProtocolParser.WriteUInt32(stream, (uint)bytes.Length); stream.Write(bytes, 0, (int)bytes.Length); }
public void ResetToPool() { WorldItem.ResetToPool(this); }
public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false) { WorldItem.DeserializeLength(stream, size, this, isDelta); }
public void FromProto(Stream stream, bool isDelta = false) { WorldItem.Deserialize(stream, this, isDelta); }