Beispiel #1
0
    public static T DeserializeCharacterData <T>(this T characterData, NetDataReader reader) where T : IPlayerCharacterData
    {
        var tempCharacterData = new PlayerCharacterData();

        tempCharacterData.Id              = reader.GetString();
        tempCharacterData.DataId          = reader.GetInt();
        tempCharacterData.EntityId        = reader.GetInt();
        tempCharacterData.CharacterName   = reader.GetString();
        tempCharacterData.Level           = reader.GetShort();
        tempCharacterData.Exp             = reader.GetInt();
        tempCharacterData.CurrentHp       = reader.GetInt();
        tempCharacterData.CurrentMp       = reader.GetInt();
        tempCharacterData.CurrentStamina  = reader.GetInt();
        tempCharacterData.CurrentFood     = reader.GetInt();
        tempCharacterData.CurrentWater    = reader.GetInt();
        tempCharacterData.StatPoint       = reader.GetShort();
        tempCharacterData.SkillPoint      = reader.GetShort();
        tempCharacterData.Gold            = reader.GetInt();
        tempCharacterData.PartyId         = reader.GetInt();
        tempCharacterData.GuildId         = reader.GetInt();
        tempCharacterData.GuildRole       = reader.GetByte();
        tempCharacterData.SharedGuildExp  = reader.GetInt();
        tempCharacterData.CurrentMapName  = reader.GetString();
        tempCharacterData.CurrentPosition = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
        tempCharacterData.RespawnMapName  = reader.GetString();
        tempCharacterData.RespawnPosition = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
        tempCharacterData.LastUpdate      = reader.GetInt();
        int count = 0;

        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterAttribute();
            entry.Deserialize(reader);
            tempCharacterData.Attributes.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterBuff();
            entry.Deserialize(reader);
            tempCharacterData.Buffs.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterSkill();
            entry.Deserialize(reader);
            tempCharacterData.Skills.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterSkillUsage();
            entry.Deserialize(reader);
            tempCharacterData.SkillUsages.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterSummon();
            entry.Deserialize(reader);
            tempCharacterData.Summons.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterItem();
            entry.Deserialize(reader);
            tempCharacterData.EquipItems.Add(entry);
        }
        count = reader.GetShort();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterItem();
            entry.Deserialize(reader);
            tempCharacterData.NonEquipItems.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterHotkey();
            entry.Deserialize(reader);
            tempCharacterData.Hotkeys.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterQuest();
            entry.Deserialize(reader);
            tempCharacterData.Quests.Add(entry);
        }
        var equipWeapons = new EquipWeapons();

        equipWeapons.Deserialize(reader);
        tempCharacterData.EquipWeapons = equipWeapons;
        DevExtUtils.InvokeStaticDevExtMethods(ClassType, "DeserializeCharacterData", characterData, reader);

        tempCharacterData.ValidateCharacterData();
        tempCharacterData.CloneTo(characterData);
        return(characterData);
    }