コード例 #1
0
        public GenericSpawner Copy()
        {
            GenericSpawner genericSpawner = Pool.Get <GenericSpawner>();

            this.CopyTo(genericSpawner);
            return(genericSpawner);
        }
コード例 #2
0
        public static GenericSpawner Deserialize(Stream stream)
        {
            GenericSpawner genericSpawner = Pool.Get <GenericSpawner>();

            GenericSpawner.Deserialize(stream, genericSpawner, false);
            return(genericSpawner);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public static GenericSpawner Deserialize(byte[] buffer, GenericSpawner instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         GenericSpawner.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
コード例 #5
0
 public virtual void WriteToStreamDelta(Stream stream, GenericSpawner previous)
 {
     if (previous == null)
     {
         GenericSpawner.Serialize(stream, this);
         return;
     }
     GenericSpawner.SerializeDelta(stream, this, previous);
 }
コード例 #6
0
 public static byte[] SerializeToBytes(GenericSpawner instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         GenericSpawner.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
コード例 #7
0
        public static GenericSpawner Deserialize(byte[] buffer)
        {
            GenericSpawner genericSpawner = Pool.Get <GenericSpawner>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                GenericSpawner.Deserialize(memoryStream, genericSpawner, false);
            }
            return(genericSpawner);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 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);
 }
コード例 #10
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     GenericSpawner.DeserializeLength(stream, size, this, isDelta);
 }
コード例 #11
0
 public virtual void WriteToStream(Stream stream)
 {
     GenericSpawner.Serialize(stream, this);
 }
コード例 #12
0
 public byte[] ToProtoBytes()
 {
     return(GenericSpawner.SerializeToBytes(this));
 }
コード例 #13
0
 public void ToProto(Stream stream)
 {
     GenericSpawner.Serialize(stream, this);
 }
コード例 #14
0
 public void CopyTo(GenericSpawner instance)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     GenericSpawner.Deserialize(stream, this, isDelta);
 }
コード例 #16
0
 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);
 }
コード例 #17
0
 public void ResetToPool()
 {
     GenericSpawner.ResetToPool(this);
 }