コード例 #1
0
        public LevelUpInfo GetLevelUpInfo(Farmer who, Skill skill, int skillLevel)
        {
            string dataKey = $"{skill.ID}/{skillLevel}";
            IDictionary <string, string> levelUpData = ModEntry.Instance.Helper.Content.Load <Dictionary <string, string> >("Data/LevelUps", ContentSource.GameContent);

            ICollection <string>     extraInformationLines = null;
            ICollection <Profession> professions           = null;

            if (levelUpData.TryGetValue(dataKey, out string data))
            {
                string[] parts = data.Split('/');

                if (parts.Length < FIELD_COUNT_LEVELS)
                {
                    ModEntry.Instance.Monitor.Log($"Failed to parse level up {dataKey}: {data}", LogLevel.Info);
                }
                else
                {
                    extraInformationLines = FindExtraInformationLines(parts[FIELD_LEVELS_EXTRA_INFO]);
                    professions           = FindProfessions(who, parts[FIELD_LEVELS_PROFS]);
                    // TODO handle mail
                }
            }

            int bigCraftableCount         = 0;
            List <CraftingRecipe> recipes = FindRecipes(skill, skillLevel, false, ref bigCraftableCount);

            recipes.AddRange(FindRecipes(skill, skillLevel, true, ref bigCraftableCount));

            LevelUpInfo info = new LevelUpInfo(skill, skillLevel, extraInformationLines, recipes, bigCraftableCount, professions);

            return(info);
        }
コード例 #2
0
        public static void ReplaceLevelUpMenu(SkillsAndProfessionsDataManager dataManager, StardewValley.Menus.LevelUpMenu levelUpMenu)
        {
            int skillID    = ModEntry.Instance.Helper.Reflection.GetField <int>(levelUpMenu, "currentSkill").GetValue();
            int skillLevel = ModEntry.Instance.Helper.Reflection.GetField <int>(levelUpMenu, "currentLevel").GetValue();

            dataManager.LoadData();
            Skill skill = dataManager.GetSkillByID(skillID);

            if (skill == null)
            {
                ModEntry.Instance.Monitor.Log($"Can't level up. Failed to find skill with ID {skillID}.", LogLevel.Error);
            }
            else
            {
                LevelUpInfo levelUp = dataManager.GetLevelUpInfo(Game1.player, skill, skillLevel);
                Game1.activeClickableMenu = new LevelUpInfoMenu(levelUp);
            }
        }