コード例 #1
0
        public static void GetPathToItemRec(Item target, bool includeSkills, ref TechTreePath path, int number = 1)
        {
            var recipes = CraftingComponent.RecipesForItem(target.GetType());

            if (recipes.Any())
            {
                if (path.Items.ContainsKey(target.GetType()))
                {
                    path.Items[target.GetType()] += number;
                }
                else
                {
                    path.Items.Add(target.GetType(), number);
                }
                foreach (RequiresSkillAttribute skill in recipes.First().RequiredSkills)
                {
                    if (skill.Level <= skill.SkillItem.MaxLevel)
                    {
                        GetPathToSkillRec(skill.SkillItem, includeSkills, ref path, skill.Level);
                    }
                }
                foreach (var ingredient in recipes.First().Ingredients)
                {
                    GetPathToItemRec(ingredient.Item, includeSkills, ref path, (int)ingredient.Quantity.GetBaseValue * number);
                }
            }
            else
            {
                if (path.BaseItems.ContainsKey(target.GetType()))
                {
                    path.BaseItems[target.GetType()] += number;
                }
                else
                {
                    path.BaseItems.Add(target.GetType(), number);
                }
            }
        }