Exemplo 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);
        }
Exemplo n.º 2
0
 public override bool Run()
 {
     Microwave_Have.Definition definition = base.InteractionDefinition as Microwave_Have.Definition;
     if (definition.ChosenRecipe.RecipeClassName == "MicrowaveOnlyMeal")
     {
         if (!AniRecipe.HasRequiredIngredients(definition.ChosenRecipe, Actor))
         {
             return(false);
         }
         return(Microwave.CreateRecipeObjectAndPutInMicrowave(Actor, Target, definition.ChosenRecipe, null, null, Target, definition.Destination, definition.Quantity, definition.Repetition, false, 0));
     }
     return(AniRecipe.ForcePushFridgeHave(Actor, Target, definition.ChosenRecipe, definition.Destination, definition.Quantity, definition.Repetition));
 }
Exemplo n.º 3
0
 /*private new bool StartCookingProcessWithFoodTray(string menuText, string[] menuPath, Recipe.MealDestination destination, Recipe.MealQuantity quantity, Recipe.MealRepetition repetition)
  * {
  *  List<Ingredient> ingredientsUsed = new List<Ingredient>();
  *  if (!Actor.IsNPC && !AniRecipe.UseUpIngredientsFrom(ChosenRecipe, Actor, ref ingredientsUsed, quantity, false))
  *  {
  *      return false;
  *  }
  *  Actor.SkillManager.AddElement(SkillNames.Cooking);
  *  FoodTray foodTray = (FoodTray)GlobalFunctions.CreateObject("FoodTray", Vector3.OutOfWorld, 0, Vector3.UnitZ);
  *  foodTray.CookingProcess = new CookingProcess(ChosenRecipe, ingredientsUsed, Target, Target.LotCurrent, destination, quantity, repetition, menuText, menuPath, foodTray, Actor);
  *  foodTray.CreateFoodProp(Slots.Hash("Slot_0"), foodTray.CookingProcess.Recipe.ModelsAndMaterials.GrillModel_FoodTray);
  *  CookingProcess.MoveToNextStep(foodTray, Actor);
  *  CookingProcess.MoveToNextStep(foodTray, Actor);
  *  CookingProcess.MoveToNextStep(foodTray, Actor);
  *  StateMachineClient stateMachineClient = StateMachineClient.Acquire(Actor.Proxy.ObjectId, "Grill");
  *  if (stateMachineClient == null)
  *  {
  *      return false;
  *  }
  *  stateMachineClient.AddInterest<TraitNames>(TraitNames.Clumsy);
  *  stateMachineClient.SetActor("x", Actor);
  *  stateMachineClient.SetActor("FoodTray", foodTray);
  *  stateMachineClient.EnterState("x", "Enter - Hands Empty");
  *  stateMachineClient.RequestState("x", "Take Out Food Tray");
  *  stateMachineClient.RequestState("x", "Exit - Holding Food Tray");
  *  if (Actor.HasExitReason(ExitReason.Canceled))
  *  {
  *      CarrySystem.EnterWhileHolding(Actor, foodTray);
  *      Food.PutHeldObjectDownOnCounterTableOrFloor(Actor, SurfaceType.Normal);
  *      return false;
  *  }
  *  CarrySystem.EnterWhileHolding(Actor, foodTray);
  *  InteractionInstance instance =  FoodTray_Prepare.Singleton.CreateInstance(foodTray, Actor, Actor.InheritedPriority(), base.Autonomous, true);
  *  return Actor.InteractionQueue.PushAsContinuation(instance, true);
  * }
  * public override void Init(ref InteractionInstanceParameters parameters)
  * {
  *  base.Init(ref parameters);
  *  OverridedGrill_Have.Definition definition = base.InteractionDefinition as OverridedGrill_Have.Definition;
  *  if (definition.ChosenRecipe == null)
  *  {
  *      ChosenRecipe = RandomUtil.GetRandomObjectFromList<Recipe>(new List<Recipe>
  *                      {
  *                              Recipe.NameToRecipeHash["HotDog"],
  *                              Recipe.NameToRecipeHash["Hamburger"],
  *                              Recipe.NameToRecipeHash["Cheesesteak"],
  *                              Recipe.NameToRecipeHash["GrilledSalmon"],
  *                              Recipe.NameToRecipeHash["TriTipSteak"]
  *                      });
  *      return;
  *  }
  *  ChosenRecipe = definition.ChosenRecipe;
  * }
  * public override bool OnLoadFixup()
  * {
  *  return ChosenRecipe != null && ChosenRecipe.OnLoadFixup() && base.OnLoadFixup();
  * }*/
 public override bool Run()
 {
     Grill_Have.Definition definition = base.InteractionDefinition as Grill_Have.Definition;
     if (Target.LotCurrent.IsCommunityLot)
     {
         if (!AniRecipe.HasRequiredIngredients(ChosenRecipe, Actor))
         {
             return(false);
         }
         return(StartCookingProcessWithFoodTray(null, null, definition.Destination, Recipe.MealQuantity.Group, definition.Repetition));
     }
     return(AniRecipe.ForcePushFridgeHave(Actor, Target, ChosenRecipe, definition.Destination, Recipe.MealQuantity.Group, definition.Repetition));
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        private bool StartCookingProcessWithFoodTray(string menuText, string[] menuPath, Recipe.MealDestination destination, Recipe.MealQuantity quantity, Recipe.MealRepetition repetition)
        {
            List <Ingredient> ingredientsUsed = new List <Ingredient>();

            if (!this.Actor.IsNPC && !AniRecipe.UseUpIngredientsFrom(this.ChosenRecipe, this.Actor, ref ingredientsUsed, quantity, false))
            {
                return(false);
            }
            this.Actor.SkillManager.AddElement(SkillNames.Cooking);
            FoodTray foodTray = (FoodTray)GlobalFunctions.CreateObject("FoodTray", Vector3.OutOfWorld, 0, Vector3.UnitZ);

            foodTray.CookingProcess = new CookingProcess(this.ChosenRecipe, ingredientsUsed, this.Target, this.Target.LotCurrent, destination, quantity, repetition, menuText, menuPath, foodTray, this.Actor);
            foodTray.CreateFoodProp(Slots.Hash("Slot_0"), foodTray.CookingProcess.Recipe.ModelsAndMaterials.GrillModel_FoodTray);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            StateMachineClient stateMachineClient = StateMachineClient.Acquire(this.Actor.Proxy.ObjectId, "Grill");

            if (stateMachineClient == null)
            {
                return(false);
            }
            stateMachineClient.AddInterest <TraitNames>(TraitNames.Clumsy);
            stateMachineClient.SetActor("x", this.Actor);
            stateMachineClient.SetActor("FoodTray", foodTray);
            stateMachineClient.EnterState("x", "Enter - Hands Empty");
            stateMachineClient.RequestState("x", "Take Out Food Tray");
            stateMachineClient.RequestState("x", "Exit - Holding Food Tray");
            if (this.Actor.HasExitReason(ExitReason.Canceled))
            {
                CarrySystem.EnterWhileHolding(this.Actor, foodTray);
                Food.PutHeldObjectDownOnCounterTableOrFloor(this.Actor, SurfaceType.Normal);
                return(false);
            }
            CarrySystem.EnterWhileHolding(this.Actor, foodTray);
            InteractionInstance instance = FoodTray_Prepare.Singleton.CreateInstance(foodTray, this.Actor, this.Actor.InheritedPriority(), base.Autonomous, true);

            return(this.Actor.InteractionQueue.PushAsContinuation(instance, true));
        }
Exemplo n.º 7
0
 public override bool Run()
 {
     Stove_Have.Definition definition = base.InteractionDefinition as Stove_Have.Definition;
     TraitFunctions.CheckForNeuroticAnxiety(Actor, TraitFunctions.NeuroticTraitAnxietyType.Stove);
     return(AniRecipe.ForcePushFridgeHave(Actor, Target, definition.ChosenRecipe, definition.Destination, definition.Quantity, definition.Repetition));
 }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
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);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
 public override bool Run()
 {
     FoodProcessor.FoodProcessor_Have.Definition definition = base.InteractionDefinition as FoodProcessor.FoodProcessor_Have.Definition;
     return AniRecipe.ForcePushFridgeHave(Actor, Target, definition.ChosenRecipe, definition.Destination, definition.Quantity, definition.Repetition);
 }