Example #1
0
        public override bool SpecificTest(Sim actor, WoodFireOven target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            if (isAutonomous)
            {
                if (target.InUse)
                {
                    return(false);
                }
                if (actor.IsSelectable)
                {
                    mWOFoodInfo = null;

                    List <Ingredient> simIngredients = Recipe.GetCookableIngredients(actor.Inventory);
                    List <Ingredient> lotIngredients = actor.Household != null && actor.Household.SharedFridgeInventory != null?Recipe.GetCookableIngredients(actor.Household.SharedFridgeInventory.Inventory) : new List <Ingredient>();

                    List <Ingredient> list = null;
                    Recipe.MealTime   time = Food.GetCurrentMealTime();

                    int     num   = RandomUtil.GetInt(13);
                    int     num2  = 0;
                    Cooking skill = actor.SkillManager.GetSkill <Cooking>(SkillNames.Cooking);
                    Recipe  recipe;
                    WoodFireOven.WOFoodInfo wOFoodInfo;
                    while (true)
                    {
                        wOFoodInfo = WoodFireOven.WOFoodInfos[num];
                        if (Recipe.NameToRecipeHash.TryGetValue(wOFoodInfo.mName, out recipe) && (recipe.CookingSkillLevelRequired == 0 || (skill != null && skill.SkillLevel >= recipe.CookingSkillLevelRequired)) &&
                            recipe.IsAvailableFor(time) && recipe.BuildIngredientList(simIngredients, lotIngredients, ref list, ref list).Count == 0)
                        {
                            break;
                        }
                        if (++num2 >= 14)
                        {
                            return(false);
                        }
                        if (++num >= 14)
                        {
                            num = 0;
                        }
                    }
                    target.mCurrentRecipe = recipe;
                    ChosenRecipe          = recipe;
                    mWOFoodInfo           = wOFoodInfo;
                    return(true);
                }
            }
            return(base.SpecificTest(actor, target, isAutonomous, ref greyedOutTooltipCallback) &&
                   (Cost == 0 || Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(actor, ChosenRecipe, Recipe.CanMakeFoodTestResult.Fail_NeedIngredients, ref greyedOutTooltipCallback)));
        }
        public override bool SpecificTest(Sim actor, WoodFireOven target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            if (isAutonomous)
            {
                if (target.InUse)
                {
                    return false;
                }
                if (actor.IsSelectable)
                {
                    mWOFoodInfo = null;

                    List<Ingredient> simIngredients = Recipe.GetCookableIngredients(actor.Inventory);
                    List<Ingredient> lotIngredients = actor.Household != null && actor.Household.SharedFridgeInventory != null ? Recipe.GetCookableIngredients(actor.Household.SharedFridgeInventory.Inventory) : new List<Ingredient>();
                    List<Ingredient> list = null;
                    Recipe.MealTime time = Food.GetCurrentMealTime();

                    int num = RandomUtil.GetInt(13);
                    int num2 = 0;
                    Cooking skill = actor.SkillManager.GetSkill<Cooking>(SkillNames.Cooking);
                    Recipe recipe;
                    WoodFireOven.WOFoodInfo wOFoodInfo;
                    while (true)
                    {
                        wOFoodInfo = WoodFireOven.WOFoodInfos[num];
                        if (Recipe.NameToRecipeHash.TryGetValue(wOFoodInfo.mName, out recipe) && (recipe.CookingSkillLevelRequired == 0 || (skill != null && skill.SkillLevel >= recipe.CookingSkillLevelRequired))
                            && recipe.IsAvailableFor(time) && recipe.BuildIngredientList(simIngredients, lotIngredients, ref list, ref list).Count == 0)
                        {
                            break;
                        }
                        if (++num2 >= 14)
                        {
                            return false;
                        }
                        if (++num >= 14)
                        {
                            num = 0;
                        }
                    }
                    target.mCurrentRecipe = recipe;
                    ChosenRecipe = recipe;
                    mWOFoodInfo = wOFoodInfo;
                    return true;
                }
            }
            return base.SpecificTest(actor, target, isAutonomous, ref greyedOutTooltipCallback)
                && (Cost == 0 || Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(actor, ChosenRecipe, Recipe.CanMakeFoodTestResult.Fail_NeedIngredients, ref greyedOutTooltipCallback));
        }
        public override void AddInteractions(InteractionObjectPair iop, Sim actor, WoodFireOven target, List<InteractionObjectPair> results)
        {
            List<Ingredient> simIngredients = Recipe.GetCookableIngredients(actor.Inventory);
            List<Ingredient> lotIngredients = actor.Household != null && actor.Household.SharedFridgeInventory != null ? Recipe.GetCookableIngredients(actor.Household.SharedFridgeInventory.Inventory) : new List<Ingredient>();
            List<Ingredient> list = null;

            Recipe.MealTime currentMealTime = Food.GetCurrentMealTime();
            string[] menuPath = new string[]
                {
                    WoodFireOven.LocalizeString("Serve") /*+ " " + Food.GetMealTimeString(currentMealTime)*/ + Localization.Ellipsis
                };
            foreach (WoodFireOven.WOFoodInfo info in WoodFireOven.WOFoodInfos)
            {
                Recipe current;
                if (Recipe.NameToRecipeHash.TryGetValue(info.mName, out current) && current.IsAvailableFor(currentMealTime))
                {
                    int cost = current.BuildIngredientList(simIngredients, lotIngredients, ref list, ref list).Count == 0 ? 0 : -1;
                    results.Add(new InteractionObjectPair(new OverridedWOBakeDefinition(current.GenericName, current, menuPath, target, Recipe.MealDestination.SurfaceAndCallToMeal, Recipe.MealQuantity.Group, Recipe.MealRepetition.MakeOne, false, cost), iop.Target));
                }
            }
        }
Example #4
0
        public override void AddInteractions(InteractionObjectPair iop, Sim actor, WoodFireOven target, List <InteractionObjectPair> results)
        {
            List <Ingredient> simIngredients = Recipe.GetCookableIngredients(actor.Inventory);
            List <Ingredient> lotIngredients = actor.Household != null && actor.Household.SharedFridgeInventory != null?Recipe.GetCookableIngredients(actor.Household.SharedFridgeInventory.Inventory) : new List <Ingredient>();

            List <Ingredient> list = null;

            Recipe.MealTime currentMealTime = Food.GetCurrentMealTime();
            string[]        menuPath        = new string[]
            {
                WoodFireOven.LocalizeString("Serve") /*+ " " + Food.GetMealTimeString(currentMealTime)*/ + Localization.Ellipsis
            };
            foreach (WoodFireOven.WOFoodInfo info in WoodFireOven.WOFoodInfos)
            {
                Recipe current;
                if (Recipe.NameToRecipeHash.TryGetValue(info.mName, out current) && current.IsAvailableFor(currentMealTime))
                {
                    int cost = current.BuildIngredientList(simIngredients, lotIngredients, ref list, ref list).Count == 0 ? 0 : -1;
                    results.Add(new InteractionObjectPair(new OverridedWOBakeDefinition(current.GenericName, current, menuPath, target, Recipe.MealDestination.SurfaceAndCallToMeal, Recipe.MealQuantity.Group, Recipe.MealRepetition.MakeOne, false, cost), iop.Target));
                }
            }
        }