protected override bool SpecificTest(Sim a, Stove target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!target.CommonMakeTest(a) || target.HasGasLeak) { return(false); } Recipe.CanMakeFoodTestResult result = Food.CanMake(this.ChosenRecipe, true, true, Recipe.MealTime.DO_NOT_CHECK, this.Repetition, target.LotCurrent, a, this.Quantity, this.Cost, this.ObjectClickedOn); return(Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(a, this.ChosenRecipe, result, ref greyedOutTooltipCallback)); }
protected override bool SpecificTest(Sim a, Grill target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (a.Posture is SwimmingInPool) { return(false); } if (!target.CommonMakeTest(a)) { return(false); } if (this.ChosenRecipe == null) { return(a.IsNPC && target.LotCurrent.IsCommunityLot); } Recipe.CanMakeFoodTestResult result = Food.CanMake(this.ChosenRecipe, true, !target.LotCurrent.IsCommunityLot, Recipe.MealTime.DO_NOT_CHECK, this.Repetition, target.LotCurrent, a, this.Quantity, this.Cost, this.ObjectClickedOn); return(Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(a, this.ChosenRecipe, result, ref greyedOutTooltipCallback)); }
protected override bool SpecificTest(Sim a, Microwave target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!target.MakeSomethingStandardTests()) { return(false); } if (this.ChosenRecipe != null && !this.ChosenRecipe.IsSnack) { Recipe.CanMakeFoodTestResult result = Food.CanMake(this.ChosenRecipe, true, true, Recipe.MealTime.DO_NOT_CHECK, this.Repetition, target.LotCurrent, a, this.Quantity, this.Cost, this.ObjectClickedOn); return(Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(a, this.ChosenRecipe, result, ref greyedOutTooltipCallback)); } if (this.ChosenRecipe != null && this.ChosenRecipe.IsSnack) { return(CommonMethods.PrepareTestResultCheckAndGrayedOutPieMenuSet(this.ChosenRecipe, a, ref greyedOutTooltipCallback)); } return(true); }
protected override bool SpecificTest(Sim a, Fridge target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (target.FridgeInventory == null && target.LotCurrent != null && !target.LotCurrent.IsCommunityLot) { return(false); } if (isAutonomous && a.SimDescription.IsFrankenstein) { return(false); } if (this.ChosenRecipe != null && !this.ChosenRecipe.IsSnack) { Recipe.CanMakeFoodTestResult result = Food.CanMake(this.ChosenRecipe, true, true, Recipe.MealTime.DO_NOT_CHECK, this.Repetition, target.LotCurrent, a, this.Quantity, this.Cost, this.ObjectClickedOn); return(Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(a, this.ChosenRecipe, result, ref greyedOutTooltipCallback)); } if (this.ChosenRecipe != null && this.ChosenRecipe.IsSnack) { return(CommonMethods.PrepareTestResultCheckAndGrayedOutPieMenuSet(this.ChosenRecipe, a, ref greyedOutTooltipCallback)); } return(!target.InUse); }
public static Recipe ChooseRecipeRandomly(Lot lotToCookOn, Sim sim, Recipe.MealQuantity quantity, bool forTesting) { if (lotToCookOn == null) { return(null); } List <Ingredient> simIngredients = Recipe.GetCookableIngredients(sim.Inventory); List <Ingredient> lotIngredients = sim.Household != null && sim.Household.SharedFridgeInventory != null?Recipe.GetCookableIngredients(sim.Household.SharedFridgeInventory.Inventory) : new List <Ingredient>(); if (GameUtils.IsInstalled(ProductVersion.EP3) && !sim.SimDescription.IsVampire) { Predicate <Ingredient> vampireFruit = (i => i.Key == "VampireFruit"); simIngredients.RemoveAll(vampireFruit); lotIngredients.RemoveAll(vampireFruit); } if (simIngredients.Count + lotIngredients.Count == 0) { return(null); } List <Ingredient> list = null; Predicate <Recipe> p = (r => r.BuildIngredientList(simIngredients, lotIngredients, ref list, ref list).Count == 0); Recipe recipe = null; if (sim.SimDescription.IsVampire) { recipe = Recipe.NameToRecipeHash[GameUtils.IsInstalled(ProductVersion.EP7) ? "VampireJuiceEP7" : "VampireJuice"]; } else if (sim.SimDescription.IsZombie) { recipe = Recipe.NameToRecipeHash["BrainFreeze"]; } if (recipe != null) { return(p(recipe) ? recipe : null); } bool lotHasCounter = Food.LotHasUsableCounter(lotToCookOn); bool lotHasMicrowave = Food.LotHasUsableMicrowave(lotToCookOn); //For testing purposes quicker to test snacks first since they only require 1 ingredient. if (forTesting) { recipe = ChooseRandomSnack(sim, lotHasCounter, lotHasMicrowave, p, true); if (recipe != null) { return(recipe); } } if (!lotToCookOn.IsCommunityLot) { List <Recipe> availableRecipes = new List <Recipe>(); bool lotHasStove = Food.LotHasUsableStove(lotToCookOn); bool lotHasGrill = Food.LotHasUsableGrill(lotToCookOn); Recipe.MealTime mealTime = Food.GetCurrentMealTime(); bool flag = sim.HasTrait(TraitNames.Vegetarian); Cooking cooking = sim.SkillManager.GetSkill <Cooking>(SkillNames.Cooking); if (cooking != null && cooking.IsHiddenSkill() && cooking.SkillLevel >= 1) { foreach (string current in cooking.KnownRecipes) { Recipe r; if (Recipe.NameToRecipeHash.TryGetValue(current, out r) && !r.IsPetFood && (!flag || r.IsVegetarian) && Food.CanMake(r, false, true, mealTime, Recipe.MealRepetition.MakeOne, lotToCookOn, sim, Recipe.MealQuantity.DoNotCheck, lotHasCounter, lotHasStove, lotHasMicrowave, lotHasGrill, 0) == Recipe.CanMakeFoodTestResult.Pass && p(r)) { if (forTesting) { return(r); } availableRecipes.Add(r); } } } else if (sim.SimDescription.TeenOrAbove && quantity == Recipe.MealQuantity.Group) { foreach (Recipe current2 in Recipe.IntroRecipes) { if ((!flag || current2.IsVegetarian) && Food.CanMake(current2, false, true, mealTime, Recipe.MealRepetition.MakeOne, lotToCookOn, sim, Recipe.MealQuantity.DoNotCheck, lotHasCounter, lotHasStove, lotHasMicrowave, lotHasGrill, 0) == Recipe.CanMakeFoodTestResult.Pass && p(current2)) { if (forTesting) { return(current2); } availableRecipes.Add(current2); } } } if (availableRecipes.Count > 0) { if (RandomUtil.RandomChance(Food.kChanceOfChoosingFavoriteFood)) { FavoriteFoodType favoriteFood = sim.SimDescription.FavoriteFood; if (favoriteFood != FavoriteFoodType.None) { foreach (Recipe current3 in availableRecipes) { if (current3.Favorite == favoriteFood) { return(current3); } } } } if (quantity == Recipe.MealQuantity.Group) { p = (r => r.CanMakeGroupServing); } else { p = (r => r.CanMakeSingleServing); } List <Recipe> limitedRecipes = availableRecipes.FindAll(p); return(RandomUtil.GetRandomObjectFromList <Recipe>(limitedRecipes.Count > 0 ? limitedRecipes : availableRecipes)); } } if (!forTesting) { return(ChooseRandomSnack(sim, lotHasCounter, lotHasMicrowave, p, false)); } return(null); }