public GenericSpawner Copy()
        {
            GenericSpawner genericSpawner = Pool.Get <GenericSpawner>();

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

            GenericSpawner.Deserialize(stream, genericSpawner, false);
            return(genericSpawner);
        }
        public static GenericSpawner DeserializeLength(Stream stream, int length, GenericSpawner instance, bool isDelta)
        {
            if (!isDelta && instance.ents == null)
            {
                instance.ents = Pool.Get <List <GenericSpawner.SpawnedEnt> >();
            }
            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
                {
                    instance.ents.Add(GenericSpawner.SpawnedEnt.DeserializeLengthDelimited(stream));
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
 public static GenericSpawner Deserialize(byte[] buffer, GenericSpawner instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         GenericSpawner.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
 public virtual void WriteToStreamDelta(Stream stream, GenericSpawner previous)
 {
     if (previous == null)
     {
         GenericSpawner.Serialize(stream, this);
         return;
     }
     GenericSpawner.SerializeDelta(stream, this, previous);
 }
 public static byte[] SerializeToBytes(GenericSpawner instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         GenericSpawner.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
        public static GenericSpawner Deserialize(byte[] buffer)
        {
            GenericSpawner genericSpawner = Pool.Get <GenericSpawner>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                GenericSpawner.Deserialize(memoryStream, genericSpawner, false);
            }
            return(genericSpawner);
        }
        public static void SerializeDelta(Stream stream, GenericSpawner instance, GenericSpawner previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.ents != null)
            {
                for (int i = 0; i < instance.ents.Count; i++)
                {
                    GenericSpawner.SpawnedEnt item = instance.ents[i];
                    stream.WriteByte(10);
                    memoryStream.SetLength((long)0);
                    GenericSpawner.SpawnedEnt.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(GenericSpawner instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     if (instance.ents != null)
     {
         for (int i = 0; i < instance.ents.Count; i++)
         {
             if (instance.ents[i] != null)
             {
                 instance.ents[i].ResetToPool();
                 instance.ents[i] = null;
             }
         }
         List <GenericSpawner.SpawnedEnt> spawnedEnts = instance.ents;
         Pool.FreeList <GenericSpawner.SpawnedEnt>(ref spawnedEnts);
         instance.ents = spawnedEnts;
     }
     Pool.Free <GenericSpawner>(ref instance);
 }
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     GenericSpawner.DeserializeLength(stream, size, this, isDelta);
 }
 public virtual void WriteToStream(Stream stream)
 {
     GenericSpawner.Serialize(stream, this);
 }
 public byte[] ToProtoBytes()
 {
     return(GenericSpawner.SerializeToBytes(this));
 }
 public void ToProto(Stream stream)
 {
     GenericSpawner.Serialize(stream, this);
 }
 public void CopyTo(GenericSpawner instance)
 {
     throw new NotImplementedException();
 }
 public void FromProto(Stream stream, bool isDelta = false)
 {
     GenericSpawner.Deserialize(stream, this, isDelta);
 }
 public static void SerializeLengthDelimited(Stream stream, GenericSpawner instance)
 {
     byte[] bytes = GenericSpawner.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
 public void ResetToPool()
 {
     GenericSpawner.ResetToPool(this);
 }