public static BaseProjectile Deserialize(Stream stream, BaseProjectile instance, bool isDelta) { while (true) { int num = stream.ReadByte(); if (num == -1) { break; } 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.primaryMagazine != null) { Magazine.DeserializeLengthDelimited(stream, instance.primaryMagazine, isDelta); } else { instance.primaryMagazine = Magazine.DeserializeLengthDelimited(stream); } } return(instance); }
public static Magazine DeserializeLengthDelimited(Stream stream) { Magazine magazine = Pool.Get <Magazine>(); Magazine.DeserializeLengthDelimited(stream, magazine, false); return(magazine); }
public static BaseProjectile DeserializeLength(Stream stream, int length, BaseProjectile 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) { 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.primaryMagazine != null) { Magazine.DeserializeLengthDelimited(stream, instance.primaryMagazine, isDelta); } else { instance.primaryMagazine = Magazine.DeserializeLengthDelimited(stream); } } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }