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 virtual void WriteToStreamDelta(Stream stream, PlayerLifeStory previous)
 {
     if (previous == null)
     {
         PlayerLifeStory.Serialize(stream, this);
         return;
     }
     PlayerLifeStory.SerializeDelta(stream, this, previous);
 }
예제 #3
0
        public static void SerializeDelta(Stream stream, BasePlayer instance, BasePlayer previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.name != null && instance.name != previous.name)
            {
                stream.WriteByte(10);
                ProtocolParser.WriteString(stream, instance.name);
            }
            if (instance.userid != previous.userid)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt64(stream, instance.userid);
            }
            if (instance.inventory != null)
            {
                stream.WriteByte(26);
                memoryStream.SetLength((long)0);
                PlayerInventory.SerializeDelta(memoryStream, instance.inventory, previous.inventory);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.metabolism != null)
            {
                stream.WriteByte(34);
                memoryStream.SetLength((long)0);
                PlayerMetabolism.SerializeDelta(memoryStream, instance.metabolism, previous.metabolism);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            if (instance.modelState != null)
            {
                stream.WriteByte(50);
                memoryStream.SetLength((long)0);
                ModelState.SerializeDelta(memoryStream, instance.modelState, previous.modelState);
                uint length1 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length1);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length1);
            }
            if (instance.playerFlags != previous.playerFlags)
            {
                stream.WriteByte(56);
                ProtocolParser.WriteUInt64(stream, (ulong)instance.playerFlags);
            }
            if (instance.heldEntity != previous.heldEntity)
            {
                stream.WriteByte(64);
                ProtocolParser.WriteUInt32(stream, instance.heldEntity);
            }
            if (instance.health != previous.health)
            {
                stream.WriteByte(77);
                ProtocolParser.WriteSingle(stream, instance.health);
            }
            if (instance.persistantData != null)
            {
                stream.WriteByte(82);
                memoryStream.SetLength((long)0);
                PersistantPlayer.SerializeDelta(memoryStream, instance.persistantData, previous.persistantData);
                uint num1 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num1);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num1);
            }
            if (instance.skinCol != previous.skinCol)
            {
                stream.WriteByte(125);
                ProtocolParser.WriteSingle(stream, instance.skinCol);
            }
            if (instance.skinTex != previous.skinTex)
            {
                stream.WriteByte(133);
                stream.WriteByte(1);
                ProtocolParser.WriteSingle(stream, instance.skinTex);
            }
            if (instance.skinMesh != previous.skinMesh)
            {
                stream.WriteByte(141);
                stream.WriteByte(1);
                ProtocolParser.WriteSingle(stream, instance.skinMesh);
            }
            if (instance.currentLife != null)
            {
                stream.WriteByte(162);
                stream.WriteByte(1);
                memoryStream.SetLength((long)0);
                PlayerLifeStory.SerializeDelta(memoryStream, instance.currentLife, previous.currentLife);
                uint length2 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length2);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length2);
            }
            if (instance.previousLife != null)
            {
                stream.WriteByte(170);
                stream.WriteByte(1);
                memoryStream.SetLength((long)0);
                PlayerLifeStory.SerializeDelta(memoryStream, instance.previousLife, previous.previousLife);
                uint num2 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num2);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num2);
            }
            if (instance.mounted != previous.mounted)
            {
                stream.WriteByte(176);
                stream.WriteByte(1);
                ProtocolParser.WriteUInt32(stream, instance.mounted);
            }
            if (instance.currentTeam != previous.currentTeam)
            {
                stream.WriteByte(184);
                stream.WriteByte(1);
                ProtocolParser.WriteUInt64(stream, instance.currentTeam);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }