public bool HandleCost(Sim sim)
            {
                if (sim != null && sim.SimDescription.ChildOrAbove && mDoorCost > 0)
                {
                    if (GoHere.Settings.mGlobalIgnoreDoorCostFilterOption.Count > 0)
                    {
                        if (FilterHelper.DoesSimMatchFilters(sim.SimDescription.SimDescriptionId, GoHere.Settings.mGlobalIgnoreDoorCostFilterOption, false))
                        {
                            return(false);
                        }
                    }

                    Household owningHousehold = sim.LotCurrent.Household;
                    if (owningHousehold == null)
                    {
                        List <PropertyData> list = RealEstateManager.AllPropertiesFromAllHouseholds();
                        for (int k = 0; k < list.Count; k++)
                        {
                            if (((list[k] != null) && (sim.LotCurrent.LotId == list[k].LotId)) && ((list[k].Owner != null) && (list[k].Owner.OwningHousehold != null)))
                            {
                                owningHousehold = list[k].Owner.OwningHousehold;
                                break;
                            }
                        }
                    }

                    if (sim.Household == null || (sim.Household != null && owningHousehold != sim.Household))
                    {
                        if (sim.FamilyFunds > mDoorCost)
                        {
                            sim.ModifyFunds(-mDoorCost);
                        }
                        else
                        {
                            sim.UnpaidBills += mDoorCost;
                        }

                        if (owningHousehold != null)
                        {
                            owningHousehold.ModifyFamilyFunds(mDoorCost);
                        }

                        return(true);
                    }
                }

                return(false);
            }
示例#2
0
        public static List <Lot> GetPurchaseableLots(StoryProgressionObject manager, Household buyer)
        {
            Dictionary <ulong, bool> owned = new Dictionary <ulong, bool>();

            foreach (PropertyData data in RealEstateManager.AllPropertiesFromAllHouseholds())
            {
                owned[data.LotId] = true;
            }

            List <Lot> list = new List <Lot>();

            foreach (Lot lot in LotManager.AllLots)
            {
                if (lot.IsWorldLot)
                {
                    continue;
                }

                if (lot.Household == buyer)
                {
                    continue;
                }

                if (lot.LotType != LotType.Residential)
                {
                    continue;
                }

                if (!IsRentable(manager, lot))
                {
                    continue;
                }

                if (owned.ContainsKey(lot.LotId))
                {
                    continue;
                }

                if (buyer.FamilyFunds < GetPurchaseLotCost(lot))
                {
                    continue;
                }

                list.Add(lot);
            }

            return(list);
        }
示例#3
0
        private new void OnSelection(UIBinInfo lotInfo)
        {
            if (lotInfo.HouseholdId == ulong.MaxValue)
            {
                if ((mInfo != null) && (mFrom != InfoSource.Unknown))
                {
                    LotValidity lotValidity = mModel.GetLotValidity(lotInfo.LotId);

                    // EA Standard does not distinguish between vacation and private lots, messing up [StoryProgression] rental systems
                    foreach (PropertyData data in RealEstateManager.AllPropertiesFromAllHouseholds())
                    {
                        if (data.PropertyType == RealEstatePropertyType.VacationHome)
                        {
                            continue;
                        }

                        if (data.LotId == lotInfo.LotId)
                        {
                            Simulator.AddObject(new OneShotFunctionWithParams(WarnLotGeneric, lotInfo));
                            return;
                        }
                    }

                    mModel.CenterCamera(lotInfo.LotId);
                    if (mInfo.LotId != ulong.MaxValue)
                    {
                        bool allow = false;
                        if (lotValidity == LotValidity.Valid)
                        {
                            allow = true;
                        }
                        else if ((Mover.Settings.mAllowGreaterThanEight) && (!mModel.LotContentsWillFit(mInfo, lotInfo.LotId)))
                        {
                            allow = true;
                        }

                        if (allow)
                        {
                            mPlacing = true;
                            EditTownController.Instance.ShowUI(false);
                            UIManager.DarkenBackground(true);
                            Sims3.UI.Responder.Instance.DisableQuit();
                            Simulator.AddObject(new OneShotFunctionWithParams(PlaceLotTask, lotInfo));
                        }
                        else if (!mModel.LotContentsWillFit(mInfo, lotInfo.LotId))
                        {
                            Simulator.AddObject(new OneShotFunctionWithParams(WarnTooBig, lotInfo));
                        }
                        else
                        {
                            Simulator.AddObject(new OneShotFunctionWithParams(WarnLotGeneric, lotInfo));
                        }
                    }
                    else if (mInfo.HouseholdId != ulong.MaxValue)
                    {
                        if (lotValidity == LotValidity.Unavailable)
                        {
                            if ((!Mover.Settings.mFreeRealEstate) && (mInfo.HouseholdFunds < lotInfo.LotWorth))
                            {
                                Simulator.AddObject(new OneShotFunctionWithParams(WarnInsufficientFunds, lotInfo));
                                return;
                            }
                        }

                        if (lotValidity != LotValidity.Invalid)
                        {
                            mPlacing = true;
                            Simulator.AddObject(new OneShotFunctionWithParams(ConfirmPurchaseTaskEx, lotInfo));
                            return;
                        }
                    }
                }
            }
            else if (mInfo.LotId == ulong.MaxValue)
            {
                if (mFrom == InfoSource.Clipboard)
                {
                    mModel.CenterCamera(lotInfo.LotId);
                    GameEntryMovingModelEx.MergeHouseholds(EditTownController.Instance, mInfo, lotInfo);
                }
                else
                {
                    mModel.CenterCamera(lotInfo.LotId);
                    Simulator.AddObject(new OneShotFunctionWithParams(PlaceHouseholdTaskEx, lotInfo));
                }
            }
        }
示例#4
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();
        }