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); }
public static bool UseUpIngredientsForOneServing(Recipe recipe, Sim sim, ref List <Ingredient> chosenIngredients, bool isSnack) { if (sim.Household == null || sim.Household.SharedFridgeInventory == 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; //If recipe is a snack, repalce recipe. if (recipe.IsSnack) { recipe = AniRecipe.ReturnSnackIngredientRecipe(sim, recipe); if (recipe == null) { return(false); } } int num = CalculateCost(recipe, Recipe.GetCookableIngredients(inventory2), Recipe.GetCookableIngredients(inventory), ref list2, ref list, out list3, isSnack); if (num == -2147483648) { return(false); } if (!sim.IsNPC) { foreach (Ingredient current in list2) { inventory2.RemoveByForce(current); } foreach (Ingredient current2 in list) { inventory.RemoveByForce(current2); } chosenIngredients.AddRange(list2); chosenIngredients.AddRange(list); if (num > 0) { return(false); } } return(true); }
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); }
public override bool Run() { try { if (this.CheckForCancelAndCleanup()) { return(false); } if (!this.Target.RouteToOpen(this, true)) { return(false); } if (this.Target.InUse) { this.Actor.AddExitReason(ExitReason.RouteFailed); return(false); } this.mImpassableRegion.AddMember(this.Actor); this.mImpassableRegion.AddMember(this.Target); this.mImpassableRegion.UpdateFootprint(); base.StandardEntry(); if (this.Actor.SimDescription.TeenOrAbove && !this.ChosenRecipe.IsSnack) { this.Actor.SkillManager.AddElement(SkillNames.Cooking); } bool flag = true; List <Ingredient> ingredientsUsed = new List <Ingredient>(); if (AniRecipe.UseUpIngredientsFrom(this.ChosenRecipe, this.Actor, ref ingredientsUsed, this.Quantity, this.ChosenRecipe.IsSnack) || this.Actor.IsNPC) { //If the food is a snack, remove ingredient if (this.ChosenRecipe.IsSnack && !this.Actor.IsNPC) { Recipe snack = AniRecipe.ReturnSnackIngredientRecipe(this.Actor, this.ChosenRecipe); if (snack != null) { //Create new temp ingredient list foreach (var item in ingredientsUsed) { item.Destroy(); } ingredientsUsed.Clear(); } } //CommonMethods.PrintMessage("Snack: " + this.ChosenRecipe.IsSnack + " / " + ingredientsUsed.Count.ToString()); Fridge.EnterStateMachine(this); IRemovableFromFridgeAsInitialRecipeStep removableFromFridgeAsInitialRecipeStep = GlobalFunctions.CreateObjectOutOfWorld(this.ChosenRecipe.ObjectToCreateInFridge, this.ChosenRecipe.ModelCodeVersion) as IRemovableFromFridgeAsInitialRecipeStep; GameObject gameObject = removableFromFridgeAsInitialRecipeStep as GameObject; gameObject.AddToUseList(this.Actor); try { this.Target.PutOnFridgeShelf(gameObject); this.mThingToPrepareOrEat = (removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess); this.mThingToPrepareOrEat.CookingProcess = new CookingProcess(this.ChosenRecipe, ingredientsUsed, this.ObjectClickedOn, this.Target.LotCurrent, this.Destination, this.Quantity, this.Repetition, this.MenuText, this.MenuPath, removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess, this.Actor); removableFromFridgeAsInitialRecipeStep.InitializeForRecipe(this.ChosenRecipe, false); CookingProcess.MoveToNextStep(removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess, this.Actor); base.SetActor(removableFromFridgeAsInitialRecipeStep.ActorNameForFridge, gameObject); if (this.mbWasHaveSomething) { base.AnimateSim("Ponder"); } base.AnimateSim("Remove - " + removableFromFridgeAsInitialRecipeStep.ActorNameForFridge); this.TriggerWatchCookingReactionBroadcaster(); } catch (Exception ex) { if (ex == null) { } gameObject.Destroy(); throw; } CarrySystem.EnterWhileHolding(this.Actor, removableFromFridgeAsInitialRecipeStep, false); if (this.CheckForCancelAndCleanup()) { return(false); } if (this.Actor.HasTrait(TraitNames.NaturalCook)) { TraitTipsManager.ShowTraitTip(13271263770231522448uL, this.Actor, TraitTipsManager.TraitTipCounterIndex.NaturalCook, TraitTipsManager.kNaturalCookCountOfMealsCooked); } if (this.Actor.HasTrait(TraitNames.Vegetarian)) { TraitTipsManager.ShowTraitTip(13271263770231522928uL, this.Actor, TraitTipsManager.TraitTipCounterIndex.Vegetarian, TraitTipsManager.kVegetarianCountOfMealsCooked); } this.PushNextInteraction(removableFromFridgeAsInitialRecipeStep, gameObject); base.AnimateSim("Exit - Standing"); } else { flag = false; } base.StandardExit(); if (flag) { ActiveTopic.AddToSim(this.Actor, "Has Made Food"); } return(flag); } catch (Exception ex) { CommonMethods.PrintMessage("Fridge: " + ex.Message); return(false); } }