protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<PreferenceFood.Item> allOptions = new List<PreferenceFood.Item>(); foreach (FavoriteFoodType type in Enum.GetValues(typeof(FavoriteFoodType))) { if ((type == FavoriteFoodType.None) || (type == FavoriteFoodType.Count)) continue; allOptions.Add(new PreferenceFood.Item(type, (me.FavoriteFood == type) ? 1 : 0)); } PreferenceFood.Item choice = new CommonSelection<PreferenceFood.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) return false; mFavoriteFood = choice.Value; } me.mFavouriteFoodType = mFavoriteFood; if (PlumbBob.SelectedActor == me.CreatedSim) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List <PreferenceFood.Item> allOptions = new List <PreferenceFood.Item>(); foreach (FavoriteFoodType type in Enum.GetValues(typeof(FavoriteFoodType))) { if ((type == FavoriteFoodType.None) || (type == FavoriteFoodType.Count)) { continue; } allOptions.Add(new PreferenceFood.Item(type, (me.FavoriteFood == type) ? 1 : 0)); } PreferenceFood.Item choice = new CommonSelection <PreferenceFood.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } mFavoriteFood = choice.Value; } me.mFavouriteFoodType = mFavoriteFood; if (PlumbBob.SelectedActor == me.CreatedSim) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId); } return(true); }
public void OnFavoritesUpdatedProxy(FavoriteMusicType music, FavoriteFoodType food, Color color) { try { if (FavoritesUpdated != null) { FavoritesUpdated(music, food, color); } } catch (Exception e) { Common.Exception("OnFavoritesUpdatedProxy", e); } }
public void RequestSetFavoriteFood(FavoriteFoodType favoriteFood) { mCASModel.RequestSetFavoriteFood(favoriteFood); }
public void RequestRandomFavorites(FavoriteFoodType food, FavoriteMusicType music, Color color) { mCASModel.RequestRandomFavorites(food, music, color); }
public IRecipe GetRecipe(FavoriteFoodType food) { return mCASModel.GetRecipe(food); }
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); }