예제 #1
0
        public PuzzleReset Copy()
        {
            PuzzleReset puzzleReset = Pool.Get <PuzzleReset>();

            this.CopyTo(puzzleReset);
            return(puzzleReset);
        }
예제 #2
0
        public static void SerializeDelta(Stream stream, PuzzleReset instance, PuzzleReset previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(8);
            ProtocolParser.WriteBool(stream, instance.playerBlocksReset);
            if (instance.playerDetectionRadius != previous.playerDetectionRadius)
            {
                stream.WriteByte(21);
                ProtocolParser.WriteSingle(stream, instance.playerDetectionRadius);
            }
            if (instance.playerDetectionOrigin != previous.playerDetectionOrigin)
            {
                stream.WriteByte(26);
                memoryStream.SetLength((long)0);
                Vector3Serialized.SerializeDelta(memoryStream, instance.playerDetectionOrigin, previous.playerDetectionOrigin);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.timeBetweenResets != previous.timeBetweenResets)
            {
                stream.WriteByte(37);
                ProtocolParser.WriteSingle(stream, instance.timeBetweenResets);
            }
            stream.WriteByte(40);
            ProtocolParser.WriteBool(stream, instance.scaleWithServerPopulation);
            Pool.FreeMemoryStream(ref memoryStream);
        }
예제 #3
0
        public static PuzzleReset Deserialize(Stream stream)
        {
            PuzzleReset puzzleReset = Pool.Get <PuzzleReset>();

            PuzzleReset.Deserialize(stream, puzzleReset, false);
            return(puzzleReset);
        }
예제 #4
0
        public static PuzzleReset DeserializeLength(Stream stream, int length)
        {
            PuzzleReset puzzleReset = Pool.Get <PuzzleReset>();

            PuzzleReset.DeserializeLength(stream, length, puzzleReset, false);
            return(puzzleReset);
        }
예제 #5
0
 public static PuzzleReset Deserialize(byte[] buffer, PuzzleReset instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         PuzzleReset.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
예제 #6
0
 public void CopyTo(PuzzleReset instance)
 {
     instance.playerBlocksReset         = this.playerBlocksReset;
     instance.playerDetectionRadius     = this.playerDetectionRadius;
     instance.playerDetectionOrigin     = this.playerDetectionOrigin;
     instance.timeBetweenResets         = this.timeBetweenResets;
     instance.scaleWithServerPopulation = this.scaleWithServerPopulation;
 }
예제 #7
0
 public virtual void WriteToStreamDelta(Stream stream, PuzzleReset previous)
 {
     if (previous == null)
     {
         PuzzleReset.Serialize(stream, this);
         return;
     }
     PuzzleReset.SerializeDelta(stream, this, previous);
 }
예제 #8
0
 public static byte[] SerializeToBytes(PuzzleReset instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         PuzzleReset.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
예제 #9
0
        public static PuzzleReset Deserialize(byte[] buffer)
        {
            PuzzleReset puzzleReset = Pool.Get <PuzzleReset>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                PuzzleReset.Deserialize(memoryStream, puzzleReset, false);
            }
            return(puzzleReset);
        }
예제 #10
0
        public static PuzzleReset DeserializeLengthDelimited(Stream stream, PuzzleReset 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 <= 21)
                {
                    if (num == 8)
                    {
                        instance.playerBlocksReset = ProtocolParser.ReadBool(stream);
                        continue;
                    }
                    else if (num == 21)
                    {
                        instance.playerDetectionRadius = ProtocolParser.ReadSingle(stream);
                        continue;
                    }
                }
                else if (num == 26)
                {
                    Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.playerDetectionOrigin, isDelta);
                    continue;
                }
                else if (num == 37)
                {
                    instance.timeBetweenResets = ProtocolParser.ReadSingle(stream);
                    continue;
                }
                else if (num == 40)
                {
                    instance.scaleWithServerPopulation = ProtocolParser.ReadBool(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);
        }
예제 #11
0
 public static void ResetToPool(PuzzleReset instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.playerBlocksReset         = false;
     instance.playerDetectionRadius     = 0f;
     instance.playerDetectionOrigin     = new Vector3();
     instance.timeBetweenResets         = 0f;
     instance.scaleWithServerPopulation = false;
     Pool.Free <PuzzleReset>(ref instance);
 }
예제 #12
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     PuzzleReset.Deserialize(stream, this, isDelta);
 }
예제 #13
0
 public virtual void WriteToStream(Stream stream)
 {
     PuzzleReset.Serialize(stream, this);
 }
예제 #14
0
 public byte[] ToProtoBytes()
 {
     return(PuzzleReset.SerializeToBytes(this));
 }
예제 #15
0
 public void ToProto(Stream stream)
 {
     PuzzleReset.Serialize(stream, this);
 }
예제 #16
0
 public static void SerializeLengthDelimited(Stream stream, PuzzleReset instance)
 {
     byte[] bytes = PuzzleReset.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
예제 #17
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     PuzzleReset.DeserializeLength(stream, size, this, isDelta);
 }
예제 #18
0
 public void ResetToPool()
 {
     PuzzleReset.ResetToPool(this);
 }