Exemplo n.º 1
0
        public static void InitializeAvatar(PreparedFoodAvatar preparedFoodAvatar)
        {
            if (string.IsNullOrEmpty(preparedFoodAvatar.worlditem.Subcategory))
            {
                //get a random category
                preparedFoodAvatar.worlditem.Props.Local.Subcategory = Get.PreparedFoodList[UnityEngine.Random.Range(0, Get.PreparedFoodList.LastIndex())].Name;
            }

            PreparedFood preparedFood = null;

            if (!mPreparedFoodLookup.TryGetValue(preparedFoodAvatar.worlditem.Subcategory, out preparedFood))
            {
                Debug.Log("Couldn't initialize prepared food avatar " + preparedFoodAvatar.name);
                return;
            }
            preparedFoodAvatar.Props = preparedFood;
            //set up the prepared food states
            WIState rawState    = preparedFoodAvatar.worlditem.States.GetState("Raw");
            WIState cookedState = preparedFoodAvatar.worlditem.States.GetState("Cooked");

            cookedState.Enabled = true;
            if (preparedFood.CanBeRaw)
            {
                //if it can be raw / cooked
                //indicate this with a suffix
                cookedState.Suffix = "Cooked";
                rawState.Suffix    = "Raw";
                rawState.Enabled   = true;
                preparedFoodAvatar.worlditem.States.DefaultState = "Raw";
            }
            else
            {
                //otherwise just show up as the normal name
                cookedState.Suffix = string.Empty;
                rawState.Enabled   = false;
                preparedFoodAvatar.worlditem.States.DefaultState = "Cooked";
            }

            //set up the edible properties
            FoodStuff foodStuff = preparedFoodAvatar.worlditem.Get <FoodStuff>();

            foodStuff.State.ConsumeOnEat = true;

            /*foodStuff.State.PotentialProps.Clear();
             * if (preparedFood.CanBeRaw) {
             *              foodStuff.State.PotentialProps.Add(preparedFood.RawProps);
             * }
             * //set the cook time regardless since food can still be burned
             */
            foodStuff.CookTimeRTSeconds = preparedFood.RTCookDuration;
            //foodStuff.State.PotentialProps.Add(preparedFood.CookedProps);
            foodStuff.RefreshFoodStuffProps();
            //the foodstuff will update itself based on whether the state is raw / cooked
        }
Exemplo n.º 2
0
        internal static bool CheckIfHasFood(PreparedFood food)
        {
            if (food == null)
            {
                return(false);
            }
            ServingContainer servingContainer = food as ServingContainer;
            Snack            snack            = food as Snack;

            return((servingContainer == null || servingContainer.HasFood) && (snack == null || snack.HasFood));
        }
Exemplo n.º 3
0
        public static bool TestIfObjectCanBeBoughtByActor(IGameObject obj, Sim actor)
        {
            /*ServingContainer container = obj as ServingContainer;
             * if (container != null)
             * {
             *  return container.AmountLeft == AmountLeftState.Full;
             * }
             *
             * Snack snackContainer = obj as Snack;
             * return ((snackContainer != null) && (snackContainer.HasFoodLeft()));*/
            PreparedFood food = obj as PreparedFood;

            return(food != null && food.HasFoodLeft());
        }
Exemplo n.º 4
0
        public static bool InitializePreparedFoodGameObject(GameObject preparedFoodParentObject, string preparedFoodName, bool createCollider, ref Bounds itemBounds)
        {
            PreparedFood pf = null;

            if (!mPreparedFoodLookup.TryGetValue(preparedFoodName, out pf))
            {
                Debug.Log("Couldn't find prepared food name " + preparedFoodName);
                return(false);
            }

            CreateFoodStateChild(preparedFoodParentObject, "Raw", pf, createCollider, ref itemBounds);
            CreateFoodStateChild(preparedFoodParentObject, "Cooked", pf, createCollider, ref itemBounds);
            return(true);
        }
Exemplo n.º 5
0
                public override bool Test(Sim a, JapLowDinnerTable target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    ObjectGuid containedObject = Slots.GetContainedObject(target.ObjectId, 2820733094u);

                    if (containedObject == ObjectGuid.InvalidObjectGuid)
                    {
                        return(false);
                    }
                    PreparedFood preparedFood = containedObject.ObjectFromId <PreparedFood>();

                    if (!JapLowDinnerTable.CheckIfHasFood(preparedFood))
                    {
                        return(false);
                    }
                    if (!JapLowDinnerTable.kServeOrEatSpoiledFood && preparedFood.IsSpoiled)
                    {
                        return(false);
                    }
                    if (JapLowDinnerTable.kOnlyRecipesThatUseFork && (preparedFood.CookingProcess == null || preparedFood.CookingProcess.Recipe == null || preparedFood.CookingProcess.Recipe.Utensil != "fork"))
                    {
                        return(false);
                    }
                    if (!JapLowDinnerTable.kServeOrEatBurntFood && preparedFood.CookingProcess != null && preparedFood.CookingProcess.FoodState == FoodCookState.Burnt)
                    {
                        return(false);
                    }
                    if (target.ActorsUsingMe.Contains(a))
                    {
                        return(false);
                    }
                    if (target.InUse && target.ActorsUsingMe.Count >= 4)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback("No Free Spots");
                        return(false);
                    }
                    if (isAutonomous)
                    {
                        if (a.SimDescription.IsRobot)
                        {
                            return(false);
                        }
                        if (a.BuffManager.HasElement(BuffNames.Stuffed))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
Exemplo n.º 6
0
            public override void AddInteractions(InteractionObjectPair iop, Sim actor, CraftersConsignment target, List <InteractionObjectPair> results)
            {
                List <ObjectGuid> objectsICanBuyInDisplay = DisplayHelper.GetObjectsICanBuyInDisplay(actor, target);

                if (objectsICanBuyInDisplay.Count == 1)
                {
                    PreparedFood food = GlobalFunctions.ConvertGuidToObject <PreparedFood>(objectsICanBuyInDisplay[0]);
                    if (food != null)
                    {
                        results.Add(new InteractionObjectPair(new BuyFoodDefinition(food), iop.Target, iop.Tuning));
                    }
                }
                else if (objectsICanBuyInDisplay.Count > 0)
                {
                    results.Add(iop);
                }
            }
Exemplo n.º 7
0
        public override void OnModsLoadStart()
        {
            Mods.Get.Runtime.LoadAvailableMods(PreparedFoodList, "PreparedFood");
            for (int i = 0; i < PreparedFoodList.Count; i++)
            {
                PreparedFood pf = PreparedFoodList[i];
                mPreparedFoodLookup.Add(PreparedFoodList[i].Name, pf);
                //create the foodstuff props
                FoodStuffProps rawProps    = null;
                FoodStuffProps cookedProps = new FoodStuffProps();
                if (pf.CanBeRaw)
                {
                    rawProps                 = new FoodStuffProps();
                    rawProps.Name            = "Raw";
                    rawProps.ConditionName   = "FoodPoisoning";
                    rawProps.ConditionChance = 0.75f;
                    rawProps.Type            = FoodStuffEdibleType.Edible;
                    rawProps.IsLiquid        = pf.IsLiquid;
                    rawProps.HungerRestore   = PlayerStatusRestore.B_OneFifth;
                    pf.RawProps              = rawProps;
                }
                cookedProps                           = new FoodStuffProps();
                cookedProps.Name                      = "Cooked";
                cookedProps.ConditionName             = "WellRested";
                cookedProps.ConditionChance           = 0.15f;
                cookedProps.Type                      = FoodStuffEdibleType.Edible | FoodStuffEdibleType.WellFed;
                cookedProps.IsLiquid                  = pf.IsLiquid;
                cookedProps.HungerRestore             = pf.HungerRestore;
                cookedProps.CustomStatusKeeperRestore = "Strength";
                cookedProps.CustomRestore             = PlayerStatusRestore.F_Full;
                pf.CookedProps                        = cookedProps;
            }

            //initialize the prepared food pieces
            for (int i = 0; i < 9; i++)                                      //KLUDGE move this to a global so it works for all blueprints regardless of length
            {
                Transform nextIngredientPivot = PlatePrefab.transform.FindChild("Ingredient_" + i.ToString());
                IngredientOffsets.Add(nextIngredientPivot.localPosition);
            }

            for (int i = 0; i < BakedGoodsPrefabs.Count; i++)
            {
                MeshRenderer mr = BakedGoodsPrefabs[i].GetComponent <MeshRenderer>();
                BakedGoodsMaterials.Add(mr.sharedMaterial);
            }
        }
Exemplo n.º 8
0
 public void AddIngredient(PreparedFood food)
 {
     contents_food.Add(food);
     contents_string.Add(food.GetComponent <Item_all>().GetName());
     //Debug.Log("Added " + food.GetComponent<Item_all>().GetName());
 }
Exemplo n.º 9
0
        public override bool Run()
        {
            if (!base.Actor.RouteToObjectRadialRange(base.Target, 0f, base.Target.MaxProximityBeforeSwiping()))
            {
                //Honestly just plain annoying to watch, especially since sims love this interaction so much
                //base.Actor.PlayRouteFailure();
                return(false);
            }
            base.Actor.RouteTurnToFace(base.Target.Position);
            base.StandardEntry();
            base.BeginCommodityUpdates();
            List <ObjectGuid> objectsICanBuyInDisplay = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);

            RandomUtil.RandomizeListOfObjects <ObjectGuid>(objectsICanBuyInDisplay);
            for (int i = 0; base.Actor.HasNoExitReason() && (i < objectsICanBuyInDisplay.Count); i++)
            {
                ObjectGuid guid   = objectsICanBuyInDisplay[i];
                GameObject target = GlobalFunctions.ConvertGuidToObject <GameObject>(guid);
                if (target != null)
                {
                    base.Actor.RouteTurnToFace(target.Position);
                    int priority = 100;
                    base.Actor.LookAtManager.SetInteractionLookAt(target, priority, LookAtJointFilter.HeadBones | LookAtJointFilter.TorsoBones);
                    bool flag = RandomUtil.RandomChance01(CraftersConsignment.kBrowseChanceOfDislikingObject);
                    ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.BalloonData(target.GetThumbnailKey());
                    if (flag)
                    {
                        bd.LowAxis = ThoughtBalloonAxis.kDislike;
                    }
                    base.Actor.ThoughtBalloonManager.ShowBalloon(bd);
                    string state = "1";
                    if (flag)
                    {
                        state = RandomUtil.GetRandomStringFromList(new string[] { "3", "5", "CantStandArtTraitReaction" });
                    }
                    else
                    {
                        state = RandomUtil.GetRandomStringFromList(new string[] { "0", "1", "2" });
                    }
                    base.EnterStateMachine("viewobjectinteraction", "Enter", "x");
                    base.AnimateSim(state);
                    base.AnimateSim("Exit");
                    base.Actor.LookAtManager.ClearInteractionLookAt();
                }
            }
            if (base.Autonomous && !base.Actor.IsSelectable)
            {
                float chance = CraftersConsignment.kBrowseBaseChanceOfBuyingObjectWithoutSale + base.Target.mSaleDiscount;
                if (RandomUtil.RandomChance01(chance))
                {
                    List <ObjectGuid> randomList = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
                    if (randomList.Count > 0)
                    {
                        ObjectGuid randomObjectFromList = RandomUtil.GetRandomObjectFromList <ObjectGuid>(randomList);
                        if (randomObjectFromList != ObjectGuid.InvalidObjectGuid)
                        {
                            PurchaseItemEx.Definition continuationDefinition = null;
                            if (Actor.Motives.IsHungry())
                            {
                                PreparedFood food = GlobalFunctions.ConvertGuidToObject <PreparedFood>(randomObjectFromList);
                                if (food != null)
                                {
                                    continuationDefinition = new PurchaseItemEx.BuyFoodDefinition(food);
                                }
                            }
                            if (continuationDefinition == null)
                            {
                                continuationDefinition = new PurchaseItemEx.Definition(randomObjectFromList, false);
                            }
                            base.TryPushAsContinuation(continuationDefinition);
                        }
                    }
                }
            }
            if (!base.Autonomous)
            {
                List <ObjectGuid> list3 = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
                if (objectsICanBuyInDisplay.Count > 0)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseItemsForPurchaseHeading", new object[0]));
                    for (int j = 0; j < list3.Count; j++)
                    {
                        GameObject obj3 = GlobalFunctions.ConvertGuidToObject <GameObject>(list3[j]);
                        if (obj3 != null)
                        {
                            ServingContainer container = obj3 as ServingContainer;
                            if (container != null)
                            {
                                builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseLineItem", new object[] { container.CookingProcess.RecipeNameFinal, DisplayHelper.ComputeFinalPriceOnObject(list3[j]) }));
                            }
                            else
                            {
                                Common.Notify("BrowseEx for " + obj3.CatalogName);
                                builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseLineItem", new object[] { obj3.CatalogName, DisplayHelper.ComputeFinalPriceOnObject(list3[j]) }));
                            }
                        }
                    }
                    base.Actor.ShowTNSIfSelectable(builder.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive);
                }
            }
            base.EndCommodityUpdates(true);
            base.StandardExit();
            return(true);
        }
Exemplo n.º 10
0
 public static bool GetPreparedFood(string preparedFoodName, out PreparedFood preparedFood)
 {
     return(mPreparedFoodLookup.TryGetValue(preparedFoodName, out preparedFood));
 }
Exemplo n.º 11
0
        protected static void CreateFoodStateChild(GameObject preparedFoodParentObject, string stateChildName, PreparedFood pf, bool createCollider, ref Bounds itemBounds)
        {
            List <Renderer> renderers = new List <Renderer>();

            preparedFoodParentObject.layer = Globals.LayerNumWorldItemActive;
            GameObject preparedFoodGameObject = preparedFoodParentObject.FindOrCreateChild(stateChildName).gameObject;

            switch (pf.FoodType)
            {
            default:
            case PreparedFoodType.BakedGoods:
                GameObject bakedGood = Get.CreateBakedGood(preparedFoodGameObject, pf.BakedGoodsIndex, renderers);
                if (pf.BakedGoodsToppings)
                {
                    Vector3   offset          = Vector3.zero;
                    Transform offsetTransform = bakedGood.transform.FindChild("ToppingsOffset");
                    if (offsetTransform != null)
                    {
                        offset = offsetTransform.localPosition;
                    }
                    Get.CreateToppings(Get.ToppingsPrefab, Get.ToppingMaterial, bakedGood, pf.ToppingColor, offset, renderers);
                }
                break;

            case PreparedFoodType.PlateOrBowl:
                switch (pf.FoodStyle)
                {
                case PreparedFoodStyle.PlateIngredients:
                case PreparedFoodStyle.BowlIngredients:
                    //if we haven't already looked up the ingredients
                    //based on the blueprint
                    //do that now before sending it over
                    if (pf.Ingredients == null)
                    {
                        Get.FindIngredients(pf);
                    }
                    Get.CreateIngredients(Get.CreatePlate(preparedFoodGameObject, renderers), pf.Ingredients, renderers);
                    break;

                case PreparedFoodStyle.PlateMound:
                    Get.CreateFood(Get.MoundFoodPrefab, Get.CreatePlate(preparedFoodGameObject, renderers), pf.BaseTextureName, pf.BaseTextureColor, Get.MoundFoodOffsetPlate, renderers);
                    break;

                case PreparedFoodStyle.PlateMoundToppings:
                    GameObject plateMoundToppings = Get.CreateBowl(preparedFoodGameObject, renderers);
                    Get.CreateFood(Get.MoundFoodPrefab, plateMoundToppings, pf.BaseTextureName, pf.BaseTextureColor, Get.MoundFoodOffsetPlate, renderers);
                    Get.CreateToppings(Get.ChunksPrefab, Get.ChunksMaterial, plateMoundToppings, pf.ToppingColor, Get.ChunksOffsetBowl, renderers);
                    break;

                case PreparedFoodStyle.BowlFlat:
                    Get.CreateFood(Get.FlatFoodPrefab, Get.CreateBowl(preparedFoodGameObject, renderers), pf.BaseTextureName, pf.BaseTextureColor, Get.FlatFoodOffsetBowl, renderers);
                    break;

                case PreparedFoodStyle.BowlMound:
                    Get.CreateFood(Get.MoundFoodPrefab, Get.CreateBowl(preparedFoodGameObject, renderers), pf.BaseTextureName, pf.BaseTextureColor, Get.MoundFoodOffsetBowl, renderers);
                    break;

                case PreparedFoodStyle.BowlFlatToppings:
                    GameObject bowlFlatToppings = Get.CreateBowl(preparedFoodGameObject, renderers);
                    Get.CreateFood(Get.FlatFoodPrefab, bowlFlatToppings, pf.BaseTextureName, pf.BaseTextureColor, Get.FlatFoodOffsetBowl, renderers);
                    Get.CreateToppings(Get.ChunksPrefab, Get.ChunksMaterial, bowlFlatToppings, pf.ToppingColor, Get.ChunksOffsetBowl, renderers);
                    break;

                case PreparedFoodStyle.BowlMoundToppings:
                    GameObject bowlMoundToppings = Get.CreateBowl(preparedFoodGameObject, renderers);
                    Get.CreateFood(Get.MoundFoodPrefab, bowlMoundToppings, pf.BaseTextureName, pf.BaseTextureColor, Get.MoundFoodOffsetBowl, renderers);
                    Get.CreateToppings(Get.ChunksPrefab, Get.ChunksMaterial, bowlMoundToppings, pf.ToppingColor, Get.ChunksOffsetBowl, renderers);
                    break;

                default:
                    break;
                }
                break;
            }
            preparedFoodGameObject.layer = Globals.LayerNumWorldItemActive;
            itemBounds.center            = preparedFoodGameObject.transform.position;
            itemBounds.size = Vector3.zero;
            for (int i = 0; i < renderers.Count; i++)
            {
                itemBounds.Encapsulate(renderers[i].bounds);
            }
            if (createCollider)
            {
                BoxCollider bc = preparedFoodGameObject.GetOrAdd <BoxCollider>();
                bc.size = itemBounds.size;
            }
        }
Exemplo n.º 12
0
        protected void FindIngredients(PreparedFood preparedFood)
        {
            List <GenericWorldItem> ingredients = new List <GenericWorldItem>();

            preparedFood.Ingredients = ingredients;
        }