示例#1
0
        public static void SerializeDelta(Stream stream, RelationshipManager instance, RelationshipManager previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.lastTeamIndex != previous.lastTeamIndex)
            {
                stream.WriteByte(8);
                ProtocolParser.WriteUInt64(stream, instance.lastTeamIndex);
            }
            if (instance.teamList != null)
            {
                for (int i = 0; i < instance.teamList.Count; i++)
                {
                    PlayerTeam item = instance.teamList[i];
                    stream.WriteByte(18);
                    memoryStream.SetLength((long)0);
                    PlayerTeam.SerializeDelta(memoryStream, item, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            if (instance.maxTeamSize != previous.maxTeamSize)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteUInt64(stream, (ulong)instance.maxTeamSize);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
示例#2
0
 public virtual void WriteToStreamDelta(Stream stream, PlayerTeam previous)
 {
     if (previous == null)
     {
         PlayerTeam.Serialize(stream, this);
         return;
     }
     PlayerTeam.SerializeDelta(stream, this, previous);
 }