Example #1
0
        public static void UnSpoil(OFBStand stand)
        {
            foreach (var stack in stand.Inventory.InventoryItems.Values)
            {
                foreach (var item in stack.List)
                {
                    if (item.Object.Value == 0)
                    {
                        ServingContainer      single = item.Object as ServingContainer;
                        ServingContainerGroup group  = item.Object as ServingContainerGroup;
                        int servingPrice             = stand.info.ServingPrice;

                        if (group != null)
                        {
                            group.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice * group.NumServingsLeft);
                            group.RemoveSpoilageAlarm();
                        }
                        else if (single != null)
                        {
                            single.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice);
                            single.RemoveSpoilageAlarm();
                        }
                    }
                }
            }
        }
Example #2
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);
        }
Example #3
0
        public static void UnSpoil(StoreSetRegister register, StoreSetBase storebase, ani_StoreRug rug, int servingPrice)
        {
            foreach (var stack in register.Inventory.InventoryItems.Values)
            {
                if (register != null)
                {
                    foreach (var item in stack.List)
                    {
                        // if (item.Object.Value == 0)
                        {
                            ServingContainer      single = item.Object as ServingContainer;
                            ServingContainerGroup group  = item.Object as ServingContainerGroup;

                            if (group != null)
                            {
                                group.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice * group.NumServingsLeft);
                                group.RemoveSpoilageAlarm();
                            }
                            else if (single != null)
                            {
                                single.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice);
                                single.RemoveSpoilageAlarm();
                            }
                        }
                    }
                }

                //if (rug != null)
                //{
                //    List<ObjectGuid> objectsICanBuyInDisplay = rug.GetObjectsICanBuyInDisplay(null);
                //    for (int i = 0; i < objectsICanBuyInDisplay.Count; i++)
                //    {
                //        GameObject gameObject = GlobalFunctions.ConvertGuidToObject<GameObject>(objectsICanBuyInDisplay[i]);
                //        if (gameObject != null)
                //        {
                //            CMStoreSet.PrintMessage(gameObject.GetType().ToString());
                //            if (gameObject.GetType() == typeof(ServingContainerGroup) || gameObject.GetType() == typeof(ServingContainerSingle))
                //            {
                //                CMStoreSet.PrintMessage("start unspoiling");
                //                ServingContainer single = gameObject as ServingContainer;
                //                ServingContainerGroup group = gameObject as ServingContainerGroup;

                //                if (group != null)
                //                {
                //                    group.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice * group.NumServingsLeft);
                //                    group.RemoveSpoilageAlarm();
                //                }
                //                else if (single != null)
                //                {
                //                    single.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice);
                //                    single.RemoveSpoilageAlarm();
                //                }
                //            }
                //        }
                //    }
                //}
            }
        }
Example #4
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));
        }
Example #5
0
        public static bool TestIfObjectCanBeBoughtByActor(GameObject 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()));
        }
Example #6
0
            public override string GetInteractionName(Sim actor, CraftersConsignment target, InteractionObjectPair iop)
            {
                GameObject obj2 = GlobalFunctions.ConvertGuidToObject <GameObject>(this.mObject);

                if (obj2 == null)
                {
                    return(CraftersConsignment.LocalizeString(actor.IsFemale, "Buy", new object[0]));
                }
                ServingContainer container = obj2 as ServingContainer;

                if (container != null)
                {
                    return(CraftersConsignment.LocalizeString(actor.IsFemale, "BuyObjectForCost", new object[] { container.CookingProcess.RecipeNameFinal, this.mCost }));
                }
                return(CraftersConsignment.LocalizeString(actor.IsFemale, "BuyObjectForCost", new object[] { obj2.CatalogName, this.mCost }));
            }
Example #7
0
        public static int BasePriceFinalPriceDiff(GameObject obj, bool singleServingOnly, out int FinalPrice, out int BasePrice)
        {
            CraftersConsignment display = obj.Parent as CraftersConsignment;

            if (display == null)
            {
                BasePrice  = 0;
                FinalPrice = 0;
                return(0);
            }

            BasePrice = 0;
            if (obj != null)
            {
                ServingContainer container = obj as ServingContainer;
                if (container != null)
                {
                    float kSingleServingBasePrice = 0f;
                    if (singleServingOnly || container is ISingleServingContainer)
                    {
                        kSingleServingBasePrice = CraftersConsignment.kSingleServingBasePrice;
                    }
                    else
                    {
                        kSingleServingBasePrice = CraftersConsignment.kGroupServingBasePrice;
                    }
                    kSingleServingBasePrice *= CraftersConsignment.kFoodQualityMuliplier[QualityHelper.GetQualityIndex(container.GetQuality())];
                    BasePrice = (int)kSingleServingBasePrice;
                }

                Snack snackContainer = obj as Snack;
                if (snackContainer != null)
                {
                    float kSingleServingBasePrice = CraftersConsignment.kSingleServingBasePrice;
                    kSingleServingBasePrice *= CraftersConsignment.kFoodQualityMuliplier[QualityHelper.GetQualityIndex(Quality.Perfect)];
                    BasePrice = (int)kSingleServingBasePrice;
                }
            }
            float num2 = CraftersConsignment.ConvertMarkupToPercent(display.mMarkup);
            float num3 = ((float)BasePrice) * num2;

            num3      -= num3 * display.mSaleDiscount;
            FinalPrice = (int)num3;
            return(BasePrice - FinalPrice);
        }
Example #8
0
        public static void InitInteractions(GameObject obj)
        {
            ServingContainer container = obj as ServingContainer;

            if (container != null)
            {
                // EA fail
                container.RemoveInteractionByType(ServingContainerGroup.CallToMeal.Singleton);
            }

            WeddingCake cake = obj as WeddingCake;

            if (cake != null)
            {
                cake.RemoveInteractionByType(WeddingCake.CutWeddingCake.Singleton);
            }

            Snack container2 = obj as Snack;

            if (container2 != null)
            {
                if (obj != null)
                {
                    obj.RemoveInteractionByType(CraftersConsignment.ChildObjectBrowseStub.Singleton);
                    obj.RemoveInteractionByType(CraftersConsignment.ChildObjectPurchaseStub.Singleton);
                    obj.AddInteraction(CraftersConsignment.ChildObjectBrowseStub.Singleton);
                    obj.AddInteraction(CraftersConsignment.ChildObjectPurchaseStub.Singleton);

                    obj.RemoveInteractionByType(Sims3.Gameplay.Objects.CookingObjects.Eat.Singleton);
                    obj.RemoveInteractionByType(Snack_CleanUp.Singleton);
                }

                ISpoilable spoil = container2 as ISpoilable;
                if (spoil != null)
                {
                    spoil.UpdateSpoilageTime(true, -1f);
                }
            }
        }
Example #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);
        }
Example #10
0
        public static void RestockDisplay(CraftersConsignmentDisplay display, out Common.StringBuilder debug)
        {
            debug = new Common.StringBuilder("Display: " + display.CatalogName + Common.NewLine + "ObjectID:" + display.ObjectId);
            if (qualites.Count == 0)
            {
                InitLists();
            }

            List <int> slotsToSkipForWeddingCakeSetupOnChiller = new List <int> {
                23, 25
            };
            List <int> slotsToSkipForWeddingCakeSetupOnRack = new List <int> {
                0, 2, 4
            };
            List <int> slotsForWeddingCakesChiller = new List <int> {
                21, 22, 24
            };
            List <int> slotsForWeddingCakesOnRack = new List <int> {
                1, 3
            };
            // wedding cake slots are included in these so they get stocked... if the cakes are disabled, they will be skipped properly
            List <int> slotsForElegantStockingOnRack = new List <int> {
                1, 3, 5, 8, 9, 11, 13, 14, 17, 18, 20, 22, 23, 26
            };
            List <int> slotsForElegantStockingOnChiller = new List <int> {
                0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 22, 24
            };
            Recipe randomRestockRecipe = null;

            if (display.LotCurrent != null)
            {
                debug += Common.NewLine + "LotCurrent: " + display.LotCurrent.Name;
            }

            if (!display.InWorld)
            {
                debug += Common.NewLine + "Display not in world";
                return;
            }

            if (Cupcake.Settings.IsDisplayExempt(display.ObjectId))
            {
                debug += Common.NewLine + "Display has auto restock disabled";
                return;
            }

            bool random = false;

            if (!Cupcake.Settings.HasSettings(display.ObjectId))
            {
                debug += Common.NewLine + "Display has no user defined settings.";
                random = true;
            }

            if (!Cupcake.Settings.mAffectActive && random)
            {
                if (display.LotCurrent == null)
                {
                    debug += Common.NewLine + "LotCurrent null";
                    return;
                }

                if (display.LotCurrent.LotId == Household.ActiveHousehold.LotId)
                {
                    debug += Common.NewLine + "On active household lot";
                    return;
                }

                List <PropertyData> list = RealEstateManager.AllPropertiesFromAllHouseholds();
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] != null && display.LotCurrent.LotId == list[i].LotId && list[i].Owner != null && list[i].Owner.OwningHousehold == Household.ActiveHousehold)
                    {
                        debug += Common.NewLine + "On owned lot";
                        return;
                    }
                }
            }

            DisplayHelper.DisplayTypes displayType;
            Dictionary <int, Slot>     slots = DisplayHelper.GetEmptyOrFoodSlots(display, out displayType);

            foreach (KeyValuePair <int, Slot> slot in slots)
            {
                debug += Common.NewLine + "Slot: " + slot.Key;
                if (displayType == DisplayHelper.DisplayTypes.Chiller)
                {
                    if (!Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key))
                    {
                        if (slot.Key > 20 && !Cupcake.Settings.mStockWeddingCakes)
                        {
                            debug += Common.NewLine + "Wedding cakes disabled, skipping top shelf";
                            continue;
                        }

                        if (Cupcake.Settings.mStockWeddingCakes && slotsToSkipForWeddingCakeSetupOnChiller.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slots for presentable wedding cake setup";
                            continue;
                        }

                        if (Cupcake.Settings.mElegantRestock && !slotsForElegantStockingOnChiller.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slot for elegant restocking";
                            continue;
                        }
                    }
                }

                if (displayType == DisplayHelper.DisplayTypes.Rack)
                {
                    if (!Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key))
                    {
                        if (Cupcake.Settings.mStockWeddingCakes && slotsToSkipForWeddingCakeSetupOnRack.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slots for presentable wedding cake setup";
                            continue;
                        }

                        if (Cupcake.Settings.mElegantRestock && !slotsForElegantStockingOnRack.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slot for elegant restocking";
                            continue;
                        }
                    }
                }

                GameObject containedObject = display.GetContainedObject(slot.Value) as GameObject;
                if (containedObject == null)
                {
                    Dictionary <string, List <Quality> > settings = Cupcake.Settings.GetDisplaySettingsForSlot(display.ObjectId, slot.Key);

                    Recipe         recipe    = null;
                    IFoodContainer container = null;
                    Quality        quality   = Quality.Perfect;
                    if (random && !Cupcake.Settings.mDisableRandomAutoRestock && (!Cupcake.Settings.mOneRecipePerDisplayOnRandom || (Cupcake.Settings.mOneRecipePerDisplayOnRandom && randomRestockRecipe == null)))
                    {
                        debug += Common.NewLine + "Random";
                        if (Cupcake.Settings.mRandomRestockSettings.Count > 0)
                        {
                            if (Cupcake.Settings.Debugging)
                            {
                                debug += Common.NewLine + "Choices:";
                                foreach (KeyValuePair <string, List <Quality> > val in Cupcake.Settings.mRandomRestockSettings)
                                {
                                    debug += Common.NewLine + val.Key;
                                    foreach (Quality val2 in val.Value)
                                    {
                                        debug += Common.NewLine + val2.ToString();
                                    }
                                }
                            }

                            if (Recipe.NameToRecipeHash.Count > 0)
                            {
                                string pick = RandomUtil.GetRandomObjectFromList <string>(new List <string>(Cupcake.Settings.mRandomRestockSettings.Keys));
                                if (Recipe.NameToRecipeHash.ContainsKey(pick))
                                {
                                    recipe = Recipe.NameToRecipeHash[pick];

                                    debug += Common.NewLine + "Fetching random recipe...";
                                    debug += Common.NewLine + "Pick: " + recipe.Key;

                                    quality = RandomUtil.GetRandomObjectFromList <Quality>(Cupcake.Settings.mRandomRestockSettings[pick]);
                                    debug  += Common.NewLine + "Fetching random quality...";
                                    debug  += Common.NewLine + "Pick: " + quality.ToString();
                                }
                                else
                                {
                                    debug += Common.NewLine + "Failed to find defined recipe";
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            if (goodies.Count > 0)
                            {
                                recipe = RandomUtil.GetRandomObjectFromList <Recipe>(goodies);
                                debug += Common.NewLine + "Fetching random bakery recipe...";
                                debug += Common.NewLine + "Pick: " + recipe.SpecificNameKey;
                                debug += Common.NewLine + "Quality: Always Perfect";
                            }
                        }

                        randomRestockRecipe = recipe;
                    }

                    if (random && Cupcake.Settings.mOneRecipePerDisplayOnRandom && randomRestockRecipe != null)
                    {
                        debug += Common.NewLine + "OneRecipePerDisplayOnRandom = true" + Common.NewLine + "Last Recipe: " + randomRestockRecipe.GenericName;
                        recipe = randomRestockRecipe;
                    }

                    if (settings != null)
                    {
                        debug += Common.NewLine + "Reading user settings...";

                        if (Cupcake.Settings.Debugging)
                        {
                            debug += Common.NewLine + "Choices:";
                            foreach (KeyValuePair <string, List <Quality> > val in settings)
                            {
                                debug += Common.NewLine + val.Key;
                                foreach (Quality val2 in val.Value)
                                {
                                    debug += Common.NewLine + val2.ToString();
                                }
                            }
                        }

                        string pick = "";
                        if (settings.Count > 0)
                        {
                            List <string> tempList = new List <string>();
                            tempList.AddRange(settings.Keys);

                            pick = RandomUtil.GetRandomObjectFromList <string>(tempList);

                            if (Recipe.NameToRecipeHash.ContainsKey(pick))
                            {
                                recipe = Recipe.NameToRecipeHash[pick];
                                debug += Common.NewLine + "Fetching random recipe...";
                                debug += Common.NewLine + "Pick: " + recipe.Key;
                            }
                            else
                            {
                                debug += Common.NewLine + "Failed to find defined recipe: " + pick;
                                continue;
                            }
                        }
                        else
                        {
                            debug += Common.NewLine + "Settings for slot was 0 count.";
                            continue;
                        }

                        quality = RandomUtil.GetRandomObjectFromList <Quality>(Cupcake.Settings.mDisplayRestockSettings[display.ObjectId][slot.Key][pick]);
                        debug  += Common.NewLine + "Fetching random quality...";
                        debug  += Common.NewLine + "Pick: " + quality.ToString();
                    }

                    bool tryCake = false;
                    if (random && Cupcake.Settings.mStockWeddingCakes && !Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key))
                    {
                        List <string> cakes = new List <string> {
                            "BSBakeWeddingCake", "WeddingCakeSliceDOT07"
                        };
                        tryCake = true;

                        if (GameUtils.IsInstalled(ProductVersion.EP4))
                        {
                            cakes.Add("Wedding Cake Slice");
                        }

                        if ((displayType == DisplayHelper.DisplayTypes.Chiller && slotsForWeddingCakesChiller.Contains(slot.Key)) || (displayType == DisplayHelper.DisplayTypes.Rack && slotsForWeddingCakesOnRack.Contains(slot.Key)))
                        {
                            debug += Common.NewLine + "Wedding cake slot";
                            recipe = null;
                            while (recipe == null)
                            {
                                string pick = RandomUtil.GetRandomObjectFromList <string>(cakes);
                                if (!Recipe.NameToRecipeHash.TryGetValue(pick, out recipe))
                                {
                                    // for folks with out of date mods
                                    if (pick == "BSBakeWeddingCake")
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (recipe != null)
                    {
                        if (quality == Quality.Any)
                        {
                            // EA standard apparently doesn't handle this correctly...
                            quality = RandomUtil.GetRandomObjectFromList <Quality>(qualites);
                        }

                        // Catalog recipes
                        IGameObject cake = null;
                        if (recipe.Key == "WeddingCakeSliceDOT07")
                        {
                            debug += Common.NewLine + "Attempt at Monte Vista cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingDOT07", ~ProductVersion.Undefined);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingDOT07", ProductVersion.BaseGame);
                            }
                        }
                        else if (recipe.Key == "Wedding Cake Slice")
                        {
                            debug += Common.NewLine + "Attempt at Generations cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingTraditional", ProductVersion.EP4);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingTraditional", ProductVersion.BaseGame);
                            }
                        }
                        else if (((tryCake && cake is FailureObject) || recipe.Key == "BSBakeWeddingCake"))
                        {
                            debug += Common.NewLine + "Attempt at Store Wedding cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingBakery", ~ProductVersion.Undefined);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingBakery", ProductVersion.BaseGame);
                            }
                        }
                        else if (recipe.Key == "BSBakeBirthdayCake")
                        {
                            debug += Common.NewLine + "Attempt at Store Birthday cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("FoodBirthdayCakeBakery", ~ProductVersion.Undefined);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("FoodBirthdayCakeBakery", ProductVersion.BaseGame);
                            }
                        }
                        else
                        {
                            container = recipe.CreateFinishedFood(recipe.CanMakeGroupServing ? Recipe.MealQuantity.Group : Recipe.MealQuantity.Single, quality);
                        }

                        if (cake != null)
                        {
                            if (cake is FailureObject)
                            {
                                debug += Common.NewLine + "Cake was FailureObject";
                                try
                                {
                                    cake.Destroy();
                                }
                                catch { }
                                continue;
                            }

                            debug += Common.NewLine + "Cake success";
                            DisplayHelper.ParentToSlot(cake as GameObject, slot.Value, display);
                            cake.AddToWorld();
                            InitInteractions(cake as GameObject);
                        }

                        if (container != null)
                        {
                            if (container is FailureObject)
                            {
                                debug += Common.NewLine + "Container was FailureObject";
                                try
                                {
                                    container.Destroy();
                                }
                                catch { }
                                continue;
                            }

                            DisplayHelper.ParentToSlot(container as GameObject, slot.Value, display);
                            container.SetGeometryState(recipe.SingleServingContainer); // this is how EA sets it, don't ask
                            container.AddToWorld();

                            ServingContainer container2 = container as ServingContainer;
                            if (container2 != null)
                            {
                                int[] numArray = new int[] { 0, 0, 0, 0, 0, 0, 15, 30, 0x2d, 60, 0x4b, 100, 0x65 };
                                container2.CookingProcess.FoodPoints = numArray[(int)quality];
                                container2.CookingProcess.FoodState  = FoodCookState.Cooked;
                                container2.FoodCookStateChanged(container2.CookingProcess.FoodState);
                            }

                            InitInteractions(container as GameObject);

                            debug += Common.NewLine + "Success: " + recipe.GenericName + Common.NewLine + quality.ToString();
                        }
                    }
                }
                else
                {
                    debug += Common.NewLine + "Slot contained object: " + containedObject.CatalogName;
                }
            }
            display.AddInteractionsToChildObjects();
        }
Example #11
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="obj"></param>
            /// <returns></returns>
            public static float ReturnItemPrice(GameObject obj)
            {
                bool           isFood       = false;
                float          objectValue  = (float)obj.Value;
                SimDescription productMaker = CommonMethods.ReturnCreaotrSimDescription(obj);

                //Food has no value by default
                if (objectValue == 0)
                {
                    ServingContainer pf = obj as ServingContainer;
                    if (pf != null)
                    {
                        //Set price depending on quality
                        pf.RemoveSpoilageAlarm();
                        //   StyledNotification.Show(new StyledNotification.Format(pf.Cost + " " + pf.FoodQuality, StyledNotification.NotificationStyle.kGameMessagePositive));
                        isFood = true;
                        switch (pf.FoodQuality)
                        {
                        case Quality.Foul:
                        case Quality.Horrifying:
                        case Quality.Bad:
                        case Quality.Putrid:
                            objectValue = AddMenuItem.ReturnFoodPriceBad();
                            break;

                        case Quality.Nice:
                        case Quality.VeryNice:
                            objectValue = AddMenuItem.ReturnFoodPriceNice();
                            break;

                        case Quality.Great:
                        case Quality.Outstanding:
                        case Quality.Excellent:
                            objectValue = AddMenuItem.ReturnFoodPriceGreat();
                            break;

                        case Quality.Perfect:
                            objectValue = AddMenuItem.ReturnFoodPricePerfect();
                            break;

                        default:
                            objectValue = AddMenuItem.ReturnFoodPriceDefault();
                            break;
                        }
                    }
                }

                //If the product has no maker, multiply by 1.3
                float priceIncrease = objectValue * (1 + (float)AddMenuItem.ReturnProfitForNoneGrownGoods() / 100);

                if (productMaker == null && !isFood)
                {
                    if (priceIncrease < (objectValue + 1))
                    {
                        objectValue += 1;
                    }
                    else
                    {
                        objectValue = priceIncrease;
                    }
                }
                else if (obj.GetType() == typeof(Ingredient))
                {
                    objectValue *= (1 + (float)AddMenuItem.ReturnProfitForIngredients() / 100);
                }

                return(objectValue);
            }