コード例 #1
0
 protected virtual void PushNextInteraction(IRemovableFromFridgeAsInitialRecipeStep thingToEatOrPrepare, GameObject thingToEatOrPrepareAsScriptObject)
 {
     this.Actor.InteractionQueue.PushAsContinuation(thingToEatOrPrepare.FollowupInteraction, thingToEatOrPrepareAsScriptObject, true);
 }
コード例 #2
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);
            }
        }