public static ArcadeGame.arcadeEnt Deserialize(byte[] buffer, ArcadeGame.arcadeEnt instance, bool isDelta = false) { using (MemoryStream memoryStream = new MemoryStream(buffer)) { ArcadeGame.arcadeEnt.Deserialize(memoryStream, instance, isDelta); } return(instance); }
public virtual void WriteToStreamDelta(Stream stream, ArcadeGame.arcadeEnt previous) { if (previous == null) { ArcadeGame.arcadeEnt.Serialize(stream, this); return; } ArcadeGame.arcadeEnt.SerializeDelta(stream, this, previous); }
public static ArcadeGame.arcadeEnt Deserialize(byte[] buffer) { ArcadeGame.arcadeEnt _arcadeEnt = Pool.Get <ArcadeGame.arcadeEnt>(); using (MemoryStream memoryStream = new MemoryStream(buffer)) { ArcadeGame.arcadeEnt.Deserialize(memoryStream, _arcadeEnt, false); } return(_arcadeEnt); }
public static void Serialize(Stream stream, ArcadeGame.arcadeEnt instance) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); stream.WriteByte(8); ProtocolParser.WriteUInt32(stream, instance.id); if (instance.name == null) { throw new ArgumentNullException("name", "Required by proto specification."); } stream.WriteByte(18); ProtocolParser.WriteString(stream, instance.name); stream.WriteByte(24); ProtocolParser.WriteUInt32(stream, instance.spriteID); stream.WriteByte(32); ProtocolParser.WriteUInt32(stream, instance.soundID); stream.WriteByte(40); ProtocolParser.WriteBool(stream, instance.visible); stream.WriteByte(50); memoryStream.SetLength((long)0); Vector3Serialized.Serialize(memoryStream, instance.position); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); stream.WriteByte(58); memoryStream.SetLength((long)0); Vector3Serialized.Serialize(memoryStream, instance.heading); uint num = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num); stream.Write(memoryStream.GetBuffer(), 0, (int)num); stream.WriteByte(64); ProtocolParser.WriteBool(stream, instance.enabled); stream.WriteByte(74); memoryStream.SetLength((long)0); Vector3Serialized.Serialize(memoryStream, instance.scale); uint length1 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length1); stream.Write(memoryStream.GetBuffer(), 0, (int)length1); stream.WriteByte(82); memoryStream.SetLength((long)0); Vector3Serialized.Serialize(memoryStream, instance.colliderScale); uint num1 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num1); stream.Write(memoryStream.GetBuffer(), 0, (int)num1); stream.WriteByte(93); ProtocolParser.WriteSingle(stream, instance.alpha); stream.WriteByte(96); ProtocolParser.WriteUInt32(stream, instance.prefabID); stream.WriteByte(104); ProtocolParser.WriteUInt32(stream, instance.parentID); Pool.FreeMemoryStream(ref memoryStream); }
public static byte[] SerializeToBytes(ArcadeGame.arcadeEnt instance) { byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { ArcadeGame.arcadeEnt.Serialize(memoryStream, instance); array = memoryStream.ToArray(); } return(array); }
public void CopyTo(ArcadeGame.arcadeEnt instance) { instance.id = this.id; instance.name = this.name; instance.spriteID = this.spriteID; instance.soundID = this.soundID; instance.visible = this.visible; instance.position = this.position; instance.heading = this.heading; instance.enabled = this.enabled; instance.scale = this.scale; instance.colliderScale = this.colliderScale; instance.alpha = this.alpha; instance.prefabID = this.prefabID; instance.parentID = this.parentID; }
public static void SerializeDelta(Stream stream, ArcadeGame instance, ArcadeGame previous) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.arcadeEnts != null) { for (int i = 0; i < instance.arcadeEnts.Count; i++) { ArcadeGame.arcadeEnt item = instance.arcadeEnts[i]; stream.WriteByte(10); memoryStream.SetLength((long)0); ArcadeGame.arcadeEnt.SerializeDelta(memoryStream, item, item); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); } } Pool.FreeMemoryStream(ref memoryStream); }
public static void ResetToPool(ArcadeGame.arcadeEnt instance) { if (!instance.ShouldPool) { return; } instance.id = 0; instance.name = string.Empty; instance.spriteID = 0; instance.soundID = 0; instance.visible = false; instance.position = new Vector3(); instance.heading = new Vector3(); instance.enabled = false; instance.scale = new Vector3(); instance.colliderScale = new Vector3(); instance.alpha = 0f; instance.prefabID = 0; instance.parentID = 0; Pool.Free <ArcadeGame.arcadeEnt>(ref instance); }
public static void SerializeLengthDelimited(Stream stream, ArcadeGame.arcadeEnt instance) { byte[] bytes = ArcadeGame.arcadeEnt.SerializeToBytes(instance); ProtocolParser.WriteUInt32(stream, (uint)bytes.Length); stream.Write(bytes, 0, (int)bytes.Length); }
public static ArcadeGame.arcadeEnt DeserializeLengthDelimited(Stream stream, ArcadeGame.arcadeEnt 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 <= 50) { if (num <= 24) { if (num == 8) { instance.id = ProtocolParser.ReadUInt32(stream); continue; } else if (num == 18) { instance.name = ProtocolParser.ReadString(stream); continue; } else if (num == 24) { instance.spriteID = ProtocolParser.ReadUInt32(stream); continue; } } else if (num == 32) { instance.soundID = ProtocolParser.ReadUInt32(stream); continue; } else if (num == 40) { instance.visible = ProtocolParser.ReadBool(stream); continue; } else if (num == 50) { Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.position, isDelta); continue; } } else if (num <= 74) { if (num == 58) { Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.heading, isDelta); continue; } else if (num == 64) { instance.enabled = ProtocolParser.ReadBool(stream); continue; } else if (num == 74) { Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.scale, isDelta); continue; } } else if (num <= 93) { if (num == 82) { Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.colliderScale, isDelta); continue; } else if (num == 93) { instance.alpha = ProtocolParser.ReadSingle(stream); continue; } } else if (num == 96) { instance.prefabID = ProtocolParser.ReadUInt32(stream); continue; } else if (num == 104) { instance.parentID = ProtocolParser.ReadUInt32(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 ArcadeGame.arcadeEnt DeserializeLengthDelimited(Stream stream) { ArcadeGame.arcadeEnt _arcadeEnt = Pool.Get <ArcadeGame.arcadeEnt>(); ArcadeGame.arcadeEnt.DeserializeLengthDelimited(stream, _arcadeEnt, false); return(_arcadeEnt); }
public static ArcadeGame.arcadeEnt DeserializeLength(Stream stream, int length) { ArcadeGame.arcadeEnt _arcadeEnt = Pool.Get <ArcadeGame.arcadeEnt>(); ArcadeGame.arcadeEnt.DeserializeLength(stream, length, _arcadeEnt, false); return(_arcadeEnt); }
public ArcadeGame.arcadeEnt Copy() { ArcadeGame.arcadeEnt _arcadeEnt = Pool.Get <ArcadeGame.arcadeEnt>(); this.CopyTo(_arcadeEnt); return(_arcadeEnt); }