Пример #1
0
        public static string ExtractRecipeKeyFromSlot(CraftersConsignmentDisplay display, int num, Slot slot, out Quality quality)
        {
            GameObject containedObject = display.GetContainedObject(slot) as GameObject;

            if (containedObject != null)
            {
                if (containedObject is IFoodContainer) //|| containedObject is ServingContainer)
                {
                    ServingContainer container = containedObject as ServingContainer;
                    if (container != null)
                    {
                        CookingProcess containerConfig = container.CookingProcess;
                        if (containerConfig != null)
                        {
                            quality = containerConfig.Quality;
                            return(containerConfig.RecipeKey);
                        }
                        else
                        {
                            Common.Notify("Unable to find recipe for food in slot " + num + ". The catalog name was " + containedObject.CatalogName);
                        }
                    }
                    else
                    {
                        Common.Notify("Encountered food that was unidentifyable in slot " + num + ". The catalog name was " + containedObject.CatalogName);
                    }
                }
            }

            quality = Quality.Any;
            return(null);
        }
Пример #2
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));
        }
Пример #3
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);
            }
        }
        public override bool Run()
        {
            if (this.CheckForCancelAndCleanup())
            {
                return(false);
            }
            if (!Target.RouteToOpen(this, true))
            {
                return(false);
            }
            if (Target.InUse)
            {
                this.Actor.AddExitReason(ExitReason.RouteFailed);
                return(false);
            }
            this.mImpassableRegion.AddMember(this.Actor);
            this.mImpassableRegion.AddMember(this.Target);
            this.mImpassableRegion.UpdateFootprint();
            base.StandardEntry();

            bool flag = true;
            List <Ingredient> ingredientsUsed = new List <Ingredient>();

            if (this.ChosenRecipe.UseUpIngredientsFrom(this.Actor, ref ingredientsUsed, Recipe.MealQuantity.Single) || this.Actor.IsNPC)
            {
                Fridge.EnterStateMachine(this);
                TrueBlood  trueBlood  = GlobalFunctions.CreateObjectOutOfWorld(this.ChosenRecipe.ObjectToCreateInFridge, this.ChosenRecipe.CodeVersion) as TrueBlood;
                GameObject gameObject = trueBlood as GameObject;
                gameObject.AddToUseList(this.Actor);
                try
                {
                    this.Target.PutOnFridgeShelf(gameObject);
                    trueBlood.InitializeForRecipe(this.ChosenRecipe);
                    Recipe.MealDestination destination = Recipe.MealDestination.SurfaceOrEat;
                    CookingProcess         process     = new CookingProcess(ChosenRecipe, new List <Ingredient>(), Target, Actor.LotCurrent, destination,
                                                                            Recipe.MealQuantity.Single, Recipe.MealRepetition.MakeOne, "Tru Blood", new String[] { }, trueBlood, Actor, false);
                    trueBlood.CookingProcess = process;
                    CookingProcess.MoveToNextStep(trueBlood, Actor);
                    base.SetActor(trueBlood.ActorNameForFridge, gameObject);

                    base.AnimateSim("Remove - " + trueBlood.ActorNameForFridge);
                }
                catch
                {
                    gameObject.Destroy();
                    throw;
                }
                CarrySystem.EnterWhileHolding(this.Actor, trueBlood, false);
                if (this.CheckForCancelAndCleanup())
                {
                    return(false);
                }
                if (this.Actor.HasTrait(TraitNames.NaturalCook))
                {
                    TraitTipsManager.ShowTraitTip(13271263770231522448uL, this.Actor, TraitTipsManager.TraitTipCounterIndex.NaturalCook, TraitTipsManager.kNaturalCookCountOfMealsCooked);
                }

                InteractionDefinition warmUp = PutBloodToMicrowave.Singleton;
                Actor.InteractionQueue.PushAsContinuation(warmUp, gameObject, true);
                base.AnimateSim("Exit - Standing");
            }
            else
            {
                flag = false;
            }
            base.StandardExit();
            if (flag)
            {
                ActiveTopic.AddToSim(this.Actor, "Has Made Food");
            }
            return(flag);
        }