Esempio n. 1
0
        public static bool UseUpIngredientsForOneServing(Recipe recipe, Sim sim, ref List <Ingredient> chosenIngredients)
        {
            if (sim.Household == null || sim.Household.SharedFridgeInventory == null)
            {
                return(false);
            }

            //if Recipe is snack, replace it with a snack recipe
            bool isSnack = recipe.IsSnack;

            /*if (recipe.IsSnack)
             * {
             *  recipe = AniRecipe.ReturnSnackIngredientRecipe(sim, recipe);
             *
             *  if (recipe == null)
             *      return false;
             * }*/

            Inventory             inventory  = sim.Household.SharedFridgeInventory.Inventory;
            Inventory             inventory2 = sim.Inventory;
            List <Ingredient>     list       = new List <Ingredient>();
            List <Ingredient>     list2      = new List <Ingredient>();
            List <IngredientData> list3;
            int num = AniRecipe.CalculateCost(recipe, Recipe.GetCookableIngredients(inventory2), Recipe.GetCookableIngredients(inventory), ref list2, ref list, out list3, isSnack);

            if (num == -2147483648)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        public static bool PrepareTestResultCheckAndGrayedOutPieMenuSet(Recipe recipe, Sim sim, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            List <Ingredient> lotIngredients = null;
            Lot lotHome = sim.LotHome;

            Recipe chosenRecipe = null;
            bool   isSnack      = recipe.IsSnack;

            bool lotHasCounter   = Food.LotHasUsableCounter(sim.LotCurrent);
            bool lotHasStove     = Food.LotHasUsableStove(sim.LotCurrent);
            bool lotHasMicrowave = Food.LotHasUsableMicrowave(sim.LotCurrent);
            bool lotHasGrill     = Food.LotHasUsableGrill(sim.LotCurrent);

            if (lotHome.Household != null && lotHome.Household.SharedFridgeInventory != null && lotHome.Household.SharedFridgeInventory.Inventory != null)
            {
                lotIngredients = Recipe.GetCookableIngredients(lotHome.Household.SharedFridgeInventory.Inventory);
            }
            List <Ingredient> cookableIngredients = Recipe.GetCookableIngredients(sim.Inventory);

            //Find the correct recipes
            if ((!recipe.CookingProcessData.UsesAMicrowave || !sim.SimDescription.ChildOrBelow) && (!(recipe.Key == "VampireJuice") || sim.SimDescription.IsVampire) && recipe.DoesLotHaveRightTech(lotHasCounter, lotHasStove, lotHasMicrowave, lotHasGrill, Recipe.MealQuantity.Single) == Recipe.CanMakeFoodTestResult.Pass)
            {
                int cost = 0;
                chosenRecipe = AniRecipe.ReturnSnackIngredientRecipe(sim, recipe);

                if (chosenRecipe != null)
                {
                    cost = AniRecipe.CalculateCost(chosenRecipe, cookableIngredients, lotIngredients, isSnack);
                }
            }

            if (chosenRecipe == null)
            {
                return(false);
            }
            if (chosenRecipe != null && AniRecipe.CalculateCost(chosenRecipe, cookableIngredients, lotIngredients, isSnack) == -2147483648)
            {
                greyedOutTooltipCallback = delegate
                {
                    return(PrepareTestResultCheckAndGrayedOutPieMenuSet(sim, chosenRecipe, recipe.GenericName, isSnack));
                };

                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        protected void AddFoodPrepInteractions(InteractionObjectPair iop, Sim sim, List <InteractionObjectPair> results, GameObject objectClickedOn)
        {
            if (sim.Household == null)
            {
                return;
            }
            Lot lotHome = sim.LotHome;

            if (lotHome == null)
            {
                return;
            }
            Type          type             = (objectClickedOn != null) ? objectClickedOn.GetType() : null;
            bool          flag             = Reflection.IsTypeAssignableFrom(typeof(Stove), type);
            bool          flag2            = Reflection.IsTypeAssignableFrom(typeof(Microwave), type);
            bool          flag3            = Reflection.IsTypeAssignableFrom(typeof(Grill), type);
            bool          flag4            = Reflection.IsTypeAssignableFrom(typeof(FoodProcessor), type);
            List <Recipe> availableRecipes = Food.GetAvailableRecipes(iop.Target.LotCurrent, sim, false, false, false);

            Recipe.MealTime mealTime = flag3 ? Recipe.MealTime.DO_NOT_CHECK : Food.GetCurrentMealTime();
            string          currentMealTimeString = Food.GetCurrentMealTimeString();

            string[] menuPath = new string[]
            {
                Localization.LocalizeString("Gameplay/Objects/CookingObjects/Food:Have", new object[]
                {
                    currentMealTimeString
                })
            };
            string[] menuPath2 = new string[]
            {
                Localization.LocalizeString("Gameplay/Objects/CookingObjects/Food:Serve", new object[]
                {
                    currentMealTimeString
                })
            };
            string[] menuPath3 = new string[]
            {
                Localization.LocalizeString("Gameplay/Objects/CookingObjects/Food:Serve", new object[]
                {
                    Food.GetString(Food.StringIndices.Dessert)
                })
            };
            string[] menuPath4 = new string[]
            {
                Localization.LocalizeString("Gameplay/Objects/CookingObjects/Food:PetFood", new object[0])
            };
            List <Ingredient> lotIngredients = null;

            if (lotHome.Household != null && lotHome.Household.SharedFridgeInventory != null && lotHome.Household.SharedFridgeInventory.Inventory != null)
            {
                lotIngredients = Recipe.GetCookableIngredients(lotHome.Household.SharedFridgeInventory.Inventory);
            }
            List <Ingredient> cookableIngredients = Recipe.GetCookableIngredients(sim.Inventory);

            foreach (Recipe current in availableRecipes)
            {
                if (type == null || (current.CookingProcessData.UsesAStove && flag) || (current.CookingProcessData.UsesAMicrowave && flag2) || (current.CookingProcessData.UsesAGrill && flag3) || (current.AllowFoodProcessor && flag4))
                {
                    int cost = 0;

                    //If sim is not in the active household, skip the check
                    if (sim.IsNPC)
                    {
                        cost = current.CalculateCost(cookableIngredients, lotIngredients);
                    }
                    else
                    {
                        cost = AniRecipe.CalculateCost(current, cookableIngredients, lotIngredients, false);
                    }

                    string menuText = sim.HasTrait(TraitNames.Vegetarian) ? current.GenericVegetarianName : current.GenericName;
                    if (current.IsDessert)
                    {
                        if (current.CanMakeGroupServing)
                        {
                            InteractionObjectPair item = new InteractionObjectPair(this.Create(menuText, current, menuPath3, objectClickedOn, Recipe.MealDestination.SurfaceOrEat, Recipe.MealQuantity.Group, Recipe.MealRepetition.MakeOne, false, cost), iop.Target);
                            results.Add(item);
                        }
                    }
                    else
                    {
                        if (current.IsPetFood)
                        {
                            InteractionObjectPair item = new InteractionObjectPair(this.Create(menuText, current, menuPath4, objectClickedOn, Recipe.MealDestination.SurfaceOnly, Recipe.MealQuantity.Single, Recipe.MealRepetition.MakeOne, false, cost), iop.Target);
                            results.Add(item);
                        }
                        else
                        {
                            if (current.IsAvailableFor(mealTime))
                            {
                                if (current.CanMakeSingleServing && !flag3 && (!sim.HasTrait(TraitNames.Vegetarian) || current.IsVegetarian || current.HasVegetarianAlternative))
                                {
                                    InteractionObjectPair item = new InteractionObjectPair(this.Create(menuText, current, menuPath, objectClickedOn, Recipe.MealDestination.SurfaceOrEat, Recipe.MealQuantity.Single, Recipe.MealRepetition.MakeOne, false, cost), iop.Target);
                                    results.Add(item);
                                }
                                if (current.CanMakeGroupServing)
                                {
                                    InteractionObjectPair item = new InteractionObjectPair(this.Create(menuText, current, menuPath2, objectClickedOn, Recipe.MealDestination.SurfaceOrEat, Recipe.MealQuantity.Group, Recipe.MealRepetition.MakeOne, false, cost), iop.Target);
                                    results.Add(item);
                                }
                            }
                        }
                    }
                }
            }
        }