コード例 #1
0
ファイル: ModuleManager.cs プロジェクト: wovencode/Tools
        // -------------------------------------------------------------------------------
        // ModuleManager (Constructor)
        // -------------------------------------------------------------------------------
        static ModuleManager()
        {
            modules.Clear();

            // -- gather all modules
            DevExtUtils.InvokeStaticDevExtMethods(typeof(ModuleManager), "Constructor");

            // -- add/update all modules
            UpdateDefines(modules);
        }
コード例 #2
0
 public static T CloneTo <T>(this IBuildingSaveData from, T to) where T : IBuildingSaveData
 {
     to.Id          = from.Id;
     to.ParentId    = from.ParentId;
     to.DataId      = from.DataId;
     to.CurrentHp   = from.CurrentHp;
     to.Position    = from.Position;
     to.Rotation    = from.Rotation;
     to.CreatorId   = from.CreatorId;
     to.CreatorName = from.CreatorName;
     DevExtUtils.InvokeStaticDevExtMethods(ClassType, "CloneTo", from, to);
     return(to);
 }
コード例 #3
0
 public static T CloneTo <T>(this IPlayerCharacterData from, T to) where T : IPlayerCharacterData
 {
     to.Id              = from.Id;
     to.DataId          = from.DataId;
     to.EntityId        = from.EntityId;
     to.CharacterName   = from.CharacterName;
     to.Level           = from.Level;
     to.Exp             = from.Exp;
     to.CurrentHp       = from.CurrentHp;
     to.CurrentMp       = from.CurrentMp;
     to.CurrentStamina  = from.CurrentStamina;
     to.CurrentFood     = from.CurrentFood;
     to.CurrentWater    = from.CurrentWater;
     to.StatPoint       = from.StatPoint;
     to.SkillPoint      = from.SkillPoint;
     to.Gold            = from.Gold;
     to.UserGold        = from.UserGold;
     to.UserCash        = from.UserCash;
     to.PartyId         = from.PartyId;
     to.GuildId         = from.GuildId;
     to.GuildRole       = from.GuildRole;
     to.SharedGuildExp  = from.SharedGuildExp;
     to.EquipWeapons    = from.EquipWeapons;
     to.CurrentMapName  = from.CurrentMapName;
     to.CurrentPosition = from.CurrentPosition;
     to.RespawnMapName  = from.RespawnMapName;
     to.RespawnPosition = from.RespawnPosition;
     to.LastUpdate      = from.LastUpdate;
     to.Attributes      = new List <CharacterAttribute>(from.Attributes);
     to.Buffs           = new List <CharacterBuff>(from.Buffs);
     to.Hotkeys         = new List <CharacterHotkey>(from.Hotkeys);
     to.Quests          = new List <CharacterQuest>(from.Quests);
     to.EquipItems      = new List <CharacterItem>(from.EquipItems);
     to.NonEquipItems   = new List <CharacterItem>(from.NonEquipItems);
     to.Skills          = new List <CharacterSkill>(from.Skills);
     to.SkillUsages     = new List <CharacterSkillUsage>(from.SkillUsages);
     to.Summons         = new List <CharacterSummon>(from.Summons);
     DevExtUtils.InvokeStaticDevExtMethods(ClassType, "CloneTo", from, to);
     return(to);
 }
コード例 #4
0
    public static void AddAllCharacterRelatesDataSurrogate(this SurrogateSelector surrogateSelector)
    {
        var playerCharacterDataSS = new PlayerCharacterSerializationSurrogate();
        var attributeSS           = new CharacterAttributeSerializationSurrogate();
        var buffSS       = new CharacterBuffSerializationSurrogate();
        var hotkeySS     = new CharacterHotkeySerializationSurrogate();
        var itemSS       = new CharacterItemSerializationSurrogate();
        var questSS      = new CharacterQuestSerializationSurrogate();
        var skillSS      = new CharacterSkillSerializationSurrogate();
        var skillUsageSS = new CharacterSkillUsageSerializationSurrogate();
        var summonSS     = new CharacterSummonSerializationSurrogate();

        surrogateSelector.AddSurrogate(typeof(PlayerCharacterData), new StreamingContext(StreamingContextStates.All), playerCharacterDataSS);
        surrogateSelector.AddSurrogate(typeof(CharacterAttribute), new StreamingContext(StreamingContextStates.All), attributeSS);
        surrogateSelector.AddSurrogate(typeof(CharacterBuff), new StreamingContext(StreamingContextStates.All), buffSS);
        surrogateSelector.AddSurrogate(typeof(CharacterHotkey), new StreamingContext(StreamingContextStates.All), hotkeySS);
        surrogateSelector.AddSurrogate(typeof(CharacterItem), new StreamingContext(StreamingContextStates.All), itemSS);
        surrogateSelector.AddSurrogate(typeof(CharacterQuest), new StreamingContext(StreamingContextStates.All), questSS);
        surrogateSelector.AddSurrogate(typeof(CharacterSkill), new StreamingContext(StreamingContextStates.All), skillSS);
        surrogateSelector.AddSurrogate(typeof(CharacterSkillUsage), new StreamingContext(StreamingContextStates.All), skillUsageSS);
        surrogateSelector.AddSurrogate(typeof(CharacterSummon), new StreamingContext(StreamingContextStates.All), summonSS);
        DevExtUtils.InvokeStaticDevExtMethods(ClassType, "AddAllCharacterRelatesDataSurrogate", surrogateSelector);
    }
コード例 #5
0
ファイル: DefinesManager.cs プロジェクト: Bystreet/Tools
 // -----------------------------------------------------------------------------------
 // DefinesManager (Constructor)
 // -----------------------------------------------------------------------------------
 static DefinesManager()
 {
     DevExtUtils.InvokeStaticDevExtMethods(typeof(DefinesManager), "Constructor");
 }
コード例 #6
0
    public static T ValidateCharacterData <T>(this T character) where T : IPlayerCharacterData
    {
        var             gameInstance = GameInstance.Singleton;
        PlayerCharacter database;

        if (!GameInstance.PlayerCharacters.TryGetValue(character.DataId, out database))
        {
            return(character);
        }
        // Validating character attributes
        short returningStatPoint  = 0;
        var   validAttributeIds   = new HashSet <int>();
        var   characterAttributes = character.Attributes;

        for (var i = characterAttributes.Count - 1; i >= 0; --i)
        {
            var characterAttribute = characterAttributes[i];
            var attributeDataId    = characterAttribute.dataId;
            // If attribute is invalid
            if (characterAttribute.GetAttribute() == null ||
                validAttributeIds.Contains(attributeDataId))
            {
                returningStatPoint += characterAttribute.amount;
                character.Attributes.RemoveAt(i);
            }
            else
            {
                validAttributeIds.Add(attributeDataId);
            }
        }
        character.StatPoint += returningStatPoint;
        // Add character's attributes
        var attributes = GameInstance.Attributes.Values;

        foreach (var attribute in attributes)
        {
            // This attribute is valid, so not have to add it
            if (validAttributeIds.Contains(attribute.DataId))
            {
                continue;
            }
            var characterAttribute = new CharacterAttribute();
            characterAttribute.dataId = attribute.DataId;
            characterAttribute.amount = 0;
            character.Attributes.Add(characterAttribute);
        }
        // Validating character skills
        short returningSkillPoint = 0;
        var   validSkillIds       = new HashSet <int>();
        var   characterSkills     = character.Skills;

        for (var i = characterSkills.Count - 1; i >= 0; --i)
        {
            var characterSkill = characterSkills[i];
            var skill          = characterSkill.GetSkill();
            // If skill is invalid or this character database does not have skill
            if (characterSkill.GetSkill() == null ||
                !database.CacheSkillLevels.ContainsKey(skill) ||
                validSkillIds.Contains(skill.DataId))
            {
                returningSkillPoint += characterSkill.level;
                character.Skills.RemoveAt(i);
            }
            else
            {
                validSkillIds.Add(skill.DataId);
            }
        }
        character.SkillPoint += returningSkillPoint;
        // Add character's skills
        var skillLevels = database.CacheSkillLevels;

        foreach (var skillLevel in skillLevels)
        {
            var skill = skillLevel.Key;
            // This skill is valid, so not have to add it
            if (validSkillIds.Contains(skill.DataId))
            {
                continue;
            }
            var characterSkill = new CharacterSkill();
            characterSkill.dataId = skill.DataId;
            characterSkill.level  = skillLevel.Value;
            character.Skills.Add(characterSkill);
        }
        // Validating character equip weapons
        var returningItems = new List <CharacterItem>();
        var equipWeapons   = character.EquipWeapons;
        var rightHand      = equipWeapons.rightHand;
        var leftHand       = equipWeapons.leftHand;

        if (rightHand.GetEquipmentItem() == null)
        {
            if (rightHand.IsValid())
            {
                returningItems.Add(rightHand);
            }
            equipWeapons.rightHand = CharacterItem.Empty;
        }
        if (leftHand.GetEquipmentItem() == null)
        {
            if (leftHand.IsValid())
            {
                returningItems.Add(leftHand);
            }
            equipWeapons.leftHand = CharacterItem.Empty;
        }
        // Validating character equip items
        var equipItems = character.EquipItems;

        for (var i = equipItems.Count - 1; i >= 0; --i)
        {
            var equipItem = equipItems[i];
            // If equipment is invalid
            if (equipItem.GetEquipmentItem() == null)
            {
                if (equipItem.IsValid())
                {
                    returningItems.Add(equipItem);
                }
                character.EquipItems.RemoveAt(i);
            }
        }
        // Return items to non equip items
        foreach (var returningItem in returningItems)
        {
            character.NonEquipItems.Add(returningItem);
        }
        // Validating character non equip items
        var nonEquipItems = character.NonEquipItems;

        for (var i = nonEquipItems.Count - 1; i >= 0; --i)
        {
            var nonEquipItem = nonEquipItems[i];
            // If equipment is invalid
            if (!nonEquipItem.IsValid())
            {
                character.NonEquipItems.RemoveAt(i);
            }
        }
        DevExtUtils.InvokeStaticDevExtMethods(ClassType, "ValidateCharacterData", character);
        return(character);
    }
コード例 #7
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);
    }
コード例 #8
0
 public static void SerializeCharacterData <T>(this T characterData, NetDataWriter writer) where T : IPlayerCharacterData
 {
     writer.Put(characterData.Id);
     writer.Put(characterData.DataId);
     writer.Put(characterData.EntityId);
     writer.Put(characterData.CharacterName);
     writer.Put(characterData.Level);
     writer.Put(characterData.Exp);
     writer.Put(characterData.CurrentHp);
     writer.Put(characterData.CurrentMp);
     writer.Put(characterData.CurrentStamina);
     writer.Put(characterData.CurrentFood);
     writer.Put(characterData.CurrentWater);
     writer.Put(characterData.StatPoint);
     writer.Put(characterData.SkillPoint);
     writer.Put(characterData.Gold);
     writer.Put(characterData.PartyId);
     writer.Put(characterData.GuildId);
     writer.Put(characterData.GuildRole);
     writer.Put(characterData.SharedGuildExp);
     writer.Put(characterData.CurrentMapName);
     writer.Put(characterData.CurrentPosition.x);
     writer.Put(characterData.CurrentPosition.y);
     writer.Put(characterData.CurrentPosition.z);
     writer.Put(characterData.RespawnMapName);
     writer.Put(characterData.RespawnPosition.x);
     writer.Put(characterData.RespawnPosition.y);
     writer.Put(characterData.RespawnPosition.z);
     writer.Put(characterData.LastUpdate);
     writer.Put((byte)characterData.Attributes.Count);
     foreach (var entry in characterData.Attributes)
     {
         entry.Serialize(writer);
     }
     writer.Put((byte)characterData.Buffs.Count);
     foreach (var entry in characterData.Buffs)
     {
         entry.Serialize(writer);
     }
     writer.Put((byte)characterData.Skills.Count);
     foreach (var entry in characterData.Skills)
     {
         entry.Serialize(writer);
     }
     writer.Put((byte)characterData.SkillUsages.Count);
     foreach (var entry in characterData.SkillUsages)
     {
         entry.Serialize(writer);
     }
     writer.Put((byte)characterData.Summons.Count);
     foreach (var entry in characterData.Summons)
     {
         entry.Serialize(writer);
     }
     writer.Put((byte)characterData.EquipItems.Count);
     foreach (var entry in characterData.EquipItems)
     {
         entry.Serialize(writer);
     }
     writer.Put((short)characterData.NonEquipItems.Count);
     foreach (var entry in characterData.NonEquipItems)
     {
         entry.Serialize(writer);
     }
     writer.Put((byte)characterData.Hotkeys.Count);
     foreach (var entry in characterData.Hotkeys)
     {
         entry.Serialize(writer);
     }
     writer.Put((byte)characterData.Quests.Count);
     foreach (var entry in characterData.Quests)
     {
         entry.Serialize(writer);
     }
     characterData.EquipWeapons.Serialize(writer);
     DevExtUtils.InvokeStaticDevExtMethods(ClassType, "SerializeCharacterData", characterData, writer);
 }
コード例 #9
0
    public static T SetNewPlayerCharacterData <T>(this T character, string characterName, int dataId, int entityId) where T : IPlayerCharacterData
    {
        var             gameInstance = GameInstance.Singleton;
        PlayerCharacter database;

        if (!GameInstance.PlayerCharacters.TryGetValue(dataId, out database))
        {
            return(character);
        }
        // Player character database
        var playerCharacter = database as PlayerCharacter;
        // Attributes
        var attributes = GameInstance.Attributes.Values;

        foreach (var attribute in attributes)
        {
            var characterAttribute = new CharacterAttribute();
            characterAttribute.dataId = attribute.DataId;
            characterAttribute.amount = 0;
            character.Attributes.Add(characterAttribute);
        }
        var skillLevels = playerCharacter.CacheSkillLevels;

        foreach (var skillLevel in skillLevels)
        {
            var characterSkill = new CharacterSkill();
            characterSkill.dataId = skillLevel.Key.DataId;
            characterSkill.level  = skillLevel.Value;
            character.Skills.Add(characterSkill);
        }
        // Right hand & left hand items
        var rightHandEquipItem = playerCharacter.rightHandEquipItem;
        var leftHandEquipItem  = playerCharacter.leftHandEquipItem;
        var equipWeapons       = new EquipWeapons();

        // Right hand equipped item
        if (rightHandEquipItem != null)
        {
            var newItem = CharacterItem.Create(rightHandEquipItem);
            equipWeapons.rightHand = newItem;
        }
        // Left hand equipped item
        if (leftHandEquipItem != null)
        {
            var newItem = CharacterItem.Create(leftHandEquipItem);
            equipWeapons.leftHand = newItem;
        }
        character.EquipWeapons = equipWeapons;
        // Armors
        var armorItems = playerCharacter.armorItems;

        foreach (var armorItem in armorItems)
        {
            if (armorItem == null)
            {
                continue;
            }
            var newItem = CharacterItem.Create(armorItem);
            character.EquipItems.Add(newItem);
        }
        // General data
        character.DataId        = dataId;
        character.EntityId      = entityId;
        character.CharacterName = characterName;
        character.Level         = 1;
        var stats = character.GetStats();

        character.CurrentHp      = (int)stats.hp;
        character.CurrentMp      = (int)stats.mp;
        character.CurrentStamina = (int)stats.stamina;
        character.CurrentFood    = (int)stats.food;
        character.CurrentWater   = (int)stats.water;
        character.Gold           = gameInstance.startGold;
        // Inventory
        var startItems = gameInstance.startItems;

        foreach (var startItem in startItems)
        {
            if (startItem.item == null || startItem.amount <= 0)
            {
                continue;
            }
            var amount = startItem.amount;
            if (amount > startItem.item.maxStack)
            {
                amount = startItem.item.maxStack;
            }
            var newItem = CharacterItem.Create(startItem.item, 1, amount);
            character.NonEquipItems.Add(newItem);
        }
        // Position
        var startMap = playerCharacter.StartMap;

        character.CurrentMapName  = startMap.scene.SceneName;
        character.RespawnMapName  = startMap.scene.SceneName;
        character.CurrentPosition = startMap.startPosition;
        character.RespawnPosition = startMap.startPosition;
        DevExtUtils.InvokeStaticDevExtMethods(ClassType, "SetNewCharacterData", character, characterName, dataId, entityId);
        return(character);
    }
コード例 #10
0
 /// <summary>Call this from inside the method you are hooking into.</summary>
 /// <typeparam name="T">(optional)</typeparam> <param name="obj"></param> <param name="baseMethodName"></param> <param name="args"></param>
 public static void HookMethod <T>(this T obj, string baseMethodName, params object[] args)
 {
     DevExtUtils.InvokeInstanceDevExtMethods(obj, baseMethodName, args);
 }
コード例 #11
0
 // -------------------------------------------------------------------------------
 // Constructor Hooks
 // -------------------------------------------------------------------------------
 static void Constructor()
 {
     DevExtUtils.InvokeStaticDevExtMethods(typeof(ModuleManager), nameof(Constructor));
 }