public static void ResetToPool(RespawnInformation instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     if (instance.spawnOptions != null)
     {
         for (int i = 0; i < instance.spawnOptions.Count; i++)
         {
             if (instance.spawnOptions[i] != null)
             {
                 instance.spawnOptions[i].ResetToPool();
                 instance.spawnOptions[i] = null;
             }
         }
         List <RespawnInformation.SpawnOptions> spawnOptions = instance.spawnOptions;
         Pool.FreeList <RespawnInformation.SpawnOptions>(ref spawnOptions);
         instance.spawnOptions = spawnOptions;
     }
     if (instance.previousLife != null)
     {
         instance.previousLife.ResetToPool();
         instance.previousLife = null;
     }
     instance.fadeIn = false;
     Pool.Free <RespawnInformation>(ref instance);
 }
        public static void SerializeDelta(Stream stream, RespawnInformation instance, RespawnInformation previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.spawnOptions != null)
            {
                for (int i = 0; i < instance.spawnOptions.Count; i++)
                {
                    RespawnInformation.SpawnOptions item = instance.spawnOptions[i];
                    stream.WriteByte(10);
                    memoryStream.SetLength((long)0);
                    RespawnInformation.SpawnOptions.SerializeDelta(memoryStream, item, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            if (instance.previousLife != null)
            {
                stream.WriteByte(18);
                memoryStream.SetLength((long)0);
                PlayerLifeStory.SerializeDelta(memoryStream, instance.previousLife, previous.previousLife);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            stream.WriteByte(24);
            ProtocolParser.WriteBool(stream, instance.fadeIn);
            Pool.FreeMemoryStream(ref memoryStream);
        }
        public RespawnInformation Copy()
        {
            RespawnInformation respawnInformation = Pool.Get <RespawnInformation>();

            this.CopyTo(respawnInformation);
            return(respawnInformation);
        }
        public static RespawnInformation Deserialize(Stream stream)
        {
            RespawnInformation respawnInformation = Pool.Get <RespawnInformation>();

            RespawnInformation.Deserialize(stream, respawnInformation, false);
            return(respawnInformation);
        }
        public static RespawnInformation DeserializeLength(Stream stream, int length)
        {
            RespawnInformation respawnInformation = Pool.Get <RespawnInformation>();

            RespawnInformation.DeserializeLength(stream, length, respawnInformation, false);
            return(respawnInformation);
        }
 public static RespawnInformation Deserialize(byte[] buffer, RespawnInformation instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         RespawnInformation.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
 public virtual void WriteToStreamDelta(Stream stream, RespawnInformation previous)
 {
     if (previous == null)
     {
         RespawnInformation.Serialize(stream, this);
         return;
     }
     RespawnInformation.SerializeDelta(stream, this, previous);
 }
        public static RespawnInformation Deserialize(byte[] buffer)
        {
            RespawnInformation respawnInformation = Pool.Get <RespawnInformation>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                RespawnInformation.Deserialize(memoryStream, respawnInformation, false);
            }
            return(respawnInformation);
        }
 public static byte[] SerializeToBytes(RespawnInformation instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         RespawnInformation.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
        public static RespawnInformation DeserializeLengthDelimited(Stream stream, RespawnInformation instance, bool isDelta)
        {
            if (!isDelta && instance.spawnOptions == null)
            {
                instance.spawnOptions = Pool.Get <List <RespawnInformation.SpawnOptions> >();
            }
            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)
                {
                    instance.spawnOptions.Add(RespawnInformation.SpawnOptions.DeserializeLengthDelimited(stream));
                }
                else if (num != 18)
                {
                    if (num == 24)
                    {
                        instance.fadeIn = 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);
                    }
                }
                else if (instance.previousLife != null)
                {
                    PlayerLifeStory.DeserializeLengthDelimited(stream, instance.previousLife, isDelta);
                }
                else
                {
                    instance.previousLife = PlayerLifeStory.DeserializeLengthDelimited(stream);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
 public static void SerializeLengthDelimited(Stream stream, RespawnInformation instance)
 {
     byte[] bytes = RespawnInformation.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
 public void FromProto(Stream stream, bool isDelta = false)
 {
     RespawnInformation.Deserialize(stream, this, isDelta);
 }
 public virtual void WriteToStream(Stream stream)
 {
     RespawnInformation.Serialize(stream, this);
 }
 public byte[] ToProtoBytes()
 {
     return(RespawnInformation.SerializeToBytes(this));
 }
 public void ToProto(Stream stream)
 {
     RespawnInformation.Serialize(stream, this);
 }
 public void CopyTo(RespawnInformation instance)
 {
     throw new NotImplementedException();
 }
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     RespawnInformation.DeserializeLength(stream, size, this, isDelta);
 }
 public void ResetToPool()
 {
     RespawnInformation.ResetToPool(this);
 }