Ejemplo n.º 1
0
        public static void SerializeDelta(Stream stream, PlayerTeam instance, PlayerTeam previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.teamID != previous.teamID)
            {
                stream.WriteByte(8);
                ProtocolParser.WriteUInt64(stream, instance.teamID);
            }
            if (instance.teamName != null && instance.teamName != previous.teamName)
            {
                stream.WriteByte(18);
                ProtocolParser.WriteString(stream, instance.teamName);
            }
            if (instance.teamLeader != previous.teamLeader)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteUInt64(stream, instance.teamLeader);
            }
            if (instance.members != null)
            {
                for (int i = 0; i < instance.members.Count; i++)
                {
                    PlayerTeam.TeamMember item = instance.members[i];
                    stream.WriteByte(34);
                    memoryStream.SetLength((long)0);
                    PlayerTeam.TeamMember.SerializeDelta(memoryStream, item, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Ejemplo n.º 2
0
            public static void SerializeDelta(Stream stream, PlayerTeam.TeamMember instance, PlayerTeam.TeamMember previous)
            {
                MemoryStream memoryStream = Pool.Get <MemoryStream>();

                if (instance.displayName != null && instance.displayName != previous.displayName)
                {
                    stream.WriteByte(10);
                    ProtocolParser.WriteString(stream, instance.displayName);
                }
                if (instance.userID != previous.userID)
                {
                    stream.WriteByte(16);
                    ProtocolParser.WriteUInt64(stream, instance.userID);
                }
                if (instance.healthFraction != previous.healthFraction)
                {
                    stream.WriteByte(29);
                    ProtocolParser.WriteSingle(stream, instance.healthFraction);
                }
                if (instance.position != previous.position)
                {
                    stream.WriteByte(34);
                    memoryStream.SetLength((long)0);
                    Vector3Serialized.SerializeDelta(memoryStream, instance.position, previous.position);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
                stream.WriteByte(40);
                ProtocolParser.WriteBool(stream, instance.online);
                Pool.FreeMemoryStream(ref memoryStream);
            }
 public override void Save(BaseNetworkable.SaveInfo info)
 {
     base.Save(info);
     info.msg.relationshipManager = (__Null)Pool.Get <RelationshipManager>();
     ((RelationshipManager)info.msg.relationshipManager).maxTeamSize = (__Null)RelationshipManager.maxTeamSize;
     if (!info.forDisk)
     {
         return;
     }
     ((RelationshipManager)info.msg.relationshipManager).lastTeamIndex = (__Null)(long)this.lastTeamIndex;
     ((RelationshipManager)info.msg.relationshipManager).teamList      = (__Null)Pool.GetList <ProtoBuf.PlayerTeam>();
     foreach (KeyValuePair <ulong, RelationshipManager.PlayerTeam> playerTeam1 in this.playerTeams)
     {
         RelationshipManager.PlayerTeam playerTeam2 = playerTeam1.Value;
         if (playerTeam2 != null)
         {
             ProtoBuf.PlayerTeam playerTeam3 = (ProtoBuf.PlayerTeam)Pool.Get <ProtoBuf.PlayerTeam>();
             playerTeam3.teamLeader = (__Null)(long)playerTeam2.teamLeader;
             playerTeam3.teamID     = (__Null)(long)playerTeam2.teamID;
             playerTeam3.teamName   = (__Null)playerTeam2.teamName;
             playerTeam3.members    = (__Null)Pool.GetList <ProtoBuf.PlayerTeam.TeamMember>();
             foreach (ulong member in playerTeam2.members)
             {
                 ProtoBuf.PlayerTeam.TeamMember teamMember = (ProtoBuf.PlayerTeam.TeamMember)Pool.Get <ProtoBuf.PlayerTeam.TeamMember>();
                 BasePlayer byId = RelationshipManager.FindByID(member);
                 teamMember.displayName = Object.op_Inequality((Object)byId, (Object)null) ? (__Null)byId.displayName : (__Null)"DEAD";
                 teamMember.userID      = (__Null)(long)member;
                 ((List <ProtoBuf.PlayerTeam.TeamMember>)playerTeam3.members).Add(teamMember);
             }
             ((List <ProtoBuf.PlayerTeam>)((RelationshipManager)info.msg.relationshipManager).teamList).Add(playerTeam3);
         }
     }
 }
 public override void Load(BaseNetworkable.LoadInfo info)
 {
     base.Load(info);
     if (!info.fromDisk || info.msg.relationshipManager == null)
     {
         return;
     }
     this.lastTeamIndex = (ulong)((RelationshipManager)info.msg.relationshipManager).lastTeamIndex;
     using (List <ProtoBuf.PlayerTeam> .Enumerator enumerator1 = ((List <ProtoBuf.PlayerTeam>)((RelationshipManager)info.msg.relationshipManager).teamList).GetEnumerator())
     {
         while (enumerator1.MoveNext())
         {
             ProtoBuf.PlayerTeam            current1   = enumerator1.Current;
             RelationshipManager.PlayerTeam playerTeam = (RelationshipManager.PlayerTeam)Pool.Get <RelationshipManager.PlayerTeam>();
             playerTeam.teamLeader = (ulong)current1.teamLeader;
             playerTeam.teamID     = (ulong)current1.teamID;
             playerTeam.teamName   = (string)current1.teamName;
             playerTeam.members    = new List <ulong>();
             using (List <ProtoBuf.PlayerTeam.TeamMember> .Enumerator enumerator2 = ((List <ProtoBuf.PlayerTeam.TeamMember>)current1.members).GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     ProtoBuf.PlayerTeam.TeamMember current2 = enumerator2.Current;
                     playerTeam.members.Add((ulong)current2.userID);
                 }
             }
             this.playerTeams[playerTeam.teamID] = playerTeam;
         }
     }
 }
 public override void Save(BaseNetworkable.SaveInfo info)
 {
     base.Save(info);
     info.msg.relationshipManager             = Pool.Get <ProtoBuf.RelationshipManager>();
     info.msg.relationshipManager.maxTeamSize = RelationshipManager.maxTeamSize;
     if (info.forDisk)
     {
         info.msg.relationshipManager.lastTeamIndex = this.lastTeamIndex;
         info.msg.relationshipManager.teamList      = Pool.GetList <ProtoBuf.PlayerTeam>();
         foreach (KeyValuePair <ulong, RelationshipManager.PlayerTeam> playerTeam in this.playerTeams)
         {
             RelationshipManager.PlayerTeam value = playerTeam.Value;
             if (value == null)
             {
                 continue;
             }
             ProtoBuf.PlayerTeam list = Pool.Get <ProtoBuf.PlayerTeam>();
             list.teamLeader = value.teamLeader;
             list.teamID     = value.teamID;
             list.teamName   = value.teamName;
             list.members    = Pool.GetList <ProtoBuf.PlayerTeam.TeamMember>();
             foreach (ulong member in value.members)
             {
                 ProtoBuf.PlayerTeam.TeamMember teamMember = Pool.Get <ProtoBuf.PlayerTeam.TeamMember>();
                 BasePlayer basePlayer = RelationshipManager.FindByID(member);
                 teamMember.displayName = (basePlayer != null ? basePlayer.displayName : "DEAD");
                 teamMember.userID      = member;
                 list.members.Add(teamMember);
             }
             info.msg.relationshipManager.teamList.Add(list);
         }
     }
 }
Ejemplo n.º 6
0
 public static PlayerTeam.TeamMember Deserialize(byte[] buffer, PlayerTeam.TeamMember instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         PlayerTeam.TeamMember.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
Ejemplo n.º 7
0
 public void CopyTo(PlayerTeam.TeamMember instance)
 {
     instance.displayName    = this.displayName;
     instance.userID         = this.userID;
     instance.healthFraction = this.healthFraction;
     instance.position       = this.position;
     instance.online         = this.online;
 }
Ejemplo n.º 8
0
 public virtual void WriteToStreamDelta(Stream stream, PlayerTeam.TeamMember previous)
 {
     if (previous == null)
     {
         PlayerTeam.TeamMember.Serialize(stream, this);
         return;
     }
     PlayerTeam.TeamMember.SerializeDelta(stream, this, previous);
 }
Ejemplo n.º 9
0
 public static PlayerTeam.TeamMember Deserialize(byte[] buffer)
 {
     PlayerTeam.TeamMember teamMember = Pool.Get <PlayerTeam.TeamMember>();
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         PlayerTeam.TeamMember.Deserialize(memoryStream, teamMember, false);
     }
     return(teamMember);
 }
Ejemplo n.º 10
0
 public static byte[] SerializeToBytes(PlayerTeam.TeamMember instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         PlayerTeam.TeamMember.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Ejemplo n.º 11
0
 public static void ResetToPool(PlayerTeam.TeamMember instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.displayName    = string.Empty;
     instance.userID         = (ulong)0;
     instance.healthFraction = 0f;
     instance.position       = new Vector3();
     instance.online         = false;
     Pool.Free <PlayerTeam.TeamMember>(ref instance);
 }
Ejemplo n.º 12
0
 public static PlayerTeam.TeamMember Deserialize(Stream stream, PlayerTeam.TeamMember instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num <= 16)
         {
             if (num == 10)
             {
                 instance.displayName = ProtocolParser.ReadString(stream);
                 continue;
             }
             else if (num == 16)
             {
                 instance.userID = ProtocolParser.ReadUInt64(stream);
                 continue;
             }
         }
         else if (num == 29)
         {
             instance.healthFraction = ProtocolParser.ReadSingle(stream);
             continue;
         }
         else if (num == 34)
         {
             Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.position, isDelta);
             continue;
         }
         else if (num == 40)
         {
             instance.online = 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);
     }
     return(instance);
 }
Ejemplo n.º 13
0
 public static void SerializeLengthDelimited(Stream stream, PlayerTeam.TeamMember instance)
 {
     byte[] bytes = PlayerTeam.TeamMember.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Ejemplo n.º 14
0
 public static PlayerTeam.TeamMember DeserializeLengthDelimited(Stream stream)
 {
     PlayerTeam.TeamMember teamMember = Pool.Get <PlayerTeam.TeamMember>();
     PlayerTeam.TeamMember.DeserializeLengthDelimited(stream, teamMember, false);
     return(teamMember);
 }
Ejemplo n.º 15
0
 public static PlayerTeam.TeamMember DeserializeLength(Stream stream, int length)
 {
     PlayerTeam.TeamMember teamMember = Pool.Get <PlayerTeam.TeamMember>();
     PlayerTeam.TeamMember.DeserializeLength(stream, length, teamMember, false);
     return(teamMember);
 }
Ejemplo n.º 16
0
 public PlayerTeam.TeamMember Copy()
 {
     PlayerTeam.TeamMember teamMember = Pool.Get <PlayerTeam.TeamMember>();
     this.CopyTo(teamMember);
     return(teamMember);
 }