示例#1
0
        public override bool Run()
        {
            try
            {
                if (CheckForCancelAndCleanup())
                {
                    return(false);
                }
                if (!Target.RouteToOpen(this, true))
                {
                    return(false);
                }
                if (Target.InUse)
                {
                    Actor.AddExitReason(ExitReason.RouteFailed);
                    return(false);
                }
                mImpassableRegion.AddMember(Actor);
                mImpassableRegion.AddMember(Target);
                mImpassableRegion.UpdateFootprint();
                base.StandardEntry();
                if (Actor.SimDescription.TeenOrAbove && !ChosenRecipe.IsSnack)
                {
                    Actor.SkillManager.AddElement(SkillNames.Cooking);
                }
                bool flag = true;
                List <Ingredient> ingredientsUsed = new List <Ingredient>();

                //if (AniRecipe.UseUpIngredientsFrom(ChosenRecipe, Actor, ref ingredientsUsed, Quantity, ChosenRecipe.IsSnack) || Actor.IsNPC)
                if (AniRecipe.UseUpIngredientsFrom(ChosenRecipe, Actor, ref ingredientsUsed))
                {
                    //If the food is a snack, remove ingredient

                    /*if (ChosenRecipe.IsSnack && !Actor.IsNPC)
                     * {
                     *  Recipe snack = AniRecipe.ReturnSnackIngredientRecipe(Actor, ChosenRecipe);
                     *  if (snack != null)
                     *  {
                     *      //Create new temp ingredient list
                     *      foreach (var item in ingredientsUsed)
                     *      {
                     *          item.Destroy();
                     *      }
                     *      ingredientsUsed.Clear();
                     *  }
                     * }*/

                    //CommonMethods.PrintMessage("Snack: " + ChosenRecipe.IsSnack + " / " + ingredientsUsed.Count.ToString());

                    Fridge.EnterStateMachine(this);
                    IRemovableFromFridgeAsInitialRecipeStep removableFromFridgeAsInitialRecipeStep = GlobalFunctions.CreateObjectOutOfWorld(ChosenRecipe.ObjectToCreateInFridge, ChosenRecipe.ModelCodeVersion) as IRemovableFromFridgeAsInitialRecipeStep;
                    GameObject gameObject = removableFromFridgeAsInitialRecipeStep as GameObject;
                    gameObject.AddToUseList(Actor);
                    try
                    {
                        Target.PutOnFridgeShelf(gameObject);
                        mThingToPrepareOrEat = (removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess);
                        mThingToPrepareOrEat.CookingProcess = new CookingProcess(ChosenRecipe, ingredientsUsed, ObjectClickedOn, Target.LotCurrent, Destination, Quantity, Repetition, MenuText, MenuPath, removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess, Actor);
                        removableFromFridgeAsInitialRecipeStep.InitializeForRecipe(ChosenRecipe, false);
                        CookingProcess.MoveToNextStep(removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess, Actor);
                        base.SetActor(removableFromFridgeAsInitialRecipeStep.ActorNameForFridge, gameObject);
                        if (mbWasHaveSomething)
                        {
                            base.AnimateSim("Ponder");
                        }
                        base.AnimateSim("Remove - " + removableFromFridgeAsInitialRecipeStep.ActorNameForFridge);
                        TriggerWatchCookingReactionBroadcaster();
                    }
                    catch (Exception ex)
                    {
                        if (ex == null)
                        {
                        }
                        gameObject.Destroy();
                        throw;
                    }
                    CarrySystem.EnterWhileHolding(Actor, removableFromFridgeAsInitialRecipeStep, false);
                    if (CheckForCancelAndCleanup())
                    {
                        return(false);
                    }

                    /*if (Actor.HasTrait(TraitNames.NaturalCook))
                     * {
                     *  TraitTipsManager.ShowTraitTip(13271263770231522448uL, Actor, TraitTipsManager.TraitTipCounterIndex.NaturalCook, TraitTipsManager.kNaturalCookCountOfMealsCooked);
                     * }
                     * if (Actor.HasTrait(TraitNames.Vegetarian))
                     * {
                     *  TraitTipsManager.ShowTraitTip(13271263770231522928uL, Actor, TraitTipsManager.TraitTipCounterIndex.Vegetarian, TraitTipsManager.kVegetarianCountOfMealsCooked);
                     * }*/
                    PushNextInteraction(removableFromFridgeAsInitialRecipeStep, gameObject);
                    base.AnimateSim("Exit - Standing");
                }
                else
                {
                    flag = false;
                }

                base.StandardExit();
                if (flag)
                {
                    ActiveTopic.AddToSim(Actor, "Has Made Food");
                }
                return(flag);
            }
            catch (Exception ex)
            {
                CommonMethods.PrintMessage("Fridge: " + ex.Message);
                return(false);
            }
        }