Example #1
0
        public static void AlterPetPool()
        {
            if (!GameUtils.IsInstalled(ProductVersion.EP5))
            {
                return;
            }

            Common.StringBuilder msg = new Common.StringBuilder();

            foreach (KeyValuePair <PetPoolType, PetPoolConfig> element in PetPoolManager.sPetConfigManager)
            {
                msg += Common.NewLine + element.Key;

                int poolSize = Settings.GetMaximumPoolSize(element.Key);
                if (poolSize == -1)
                {
                    continue;
                }

                msg += Common.NewLine + " Maximum: " + poolSize;

                element.Value.mEP5Range[1]        = poolSize;
                element.Value.mEP5Range[2]        = poolSize;
                element.Value.mOtherWorldRange[1] = poolSize;
                element.Value.mOtherWorldRange[2] = poolSize;

                List <SimDescription> destroyed = PetPoolManager.GetPetsByType(element.Key);

                int remove = PetPoolManager.GetPoolSize(element.Key) - poolSize;

                msg += Common.NewLine + " Remove: " + remove;

                if (remove > 0)
                {
                    PetPoolManager.RefreshPool(element.Key, remove);

                    List <SimDescription> remaining = PetPoolManager.GetPetsByType(element.Key);
                    if (remaining != null)
                    {
                        foreach (SimDescription remain in remaining)
                        {
                            destroyed.Remove(remain);
                        }
                    }

                    int destroyedCount = 0;
                    foreach (SimDescription destroy in destroyed)
                    {
                        if (ServiceCleanup.AttemptServiceDisposal(destroy, false, "Too Many " + element.Key))
                        {
                            destroyedCount++;
                        }
                        else
                        {
                            Household.PetHousehold.Add(destroy);
                        }
                    }

                    msg += Common.NewLine + " Destroyed: " + destroyedCount;
                }

                PetPool pool;
                if (PetPoolManager.TryGetPetPool(element.Key, out pool))
                {
                    if (pool.mSimDescriptionIds == null)
                    {
                        // Setting this off null will ensure that MaximumThresholdReached() returns TRUE for a size of "0"
                        pool.mSimDescriptionIds = new List <ulong>();

                        msg += Common.NewLine + " Repooled";
                    }
                }
            }

            Common.DebugNotify(msg);
        }
Example #2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (mNewSim != null)
            {
                return(base.PrivateUpdate(frame));
            }

            if (GetValue <PetAdoptionScenario.UsePetPoolOption, bool>())
            {
                PetPoolType poolType = PetPoolType.None;
                switch (Species)
                {
                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    poolType = PetPoolType.AdoptDog;
                    break;

                case CASAgeGenderFlags.Cat:
                    poolType = PetPoolType.AdoptCat;
                    break;

                case CASAgeGenderFlags.Horse:
                    poolType = PetPoolType.AdoptHorse;
                    break;
                }

                List <SimDescription> choices = PetPoolManager.GetPetsByType(poolType);
                if ((choices != null) && (choices.Count > 0))
                {
                    CASAgeGenderFlags ages = Ages;
                    for (int i = choices.Count - 1; i >= 0; i--)
                    {
                        if ((ages & choices[i].Age) != choices[i].Age)
                        {
                            choices.RemoveAt(i);
                        }
                        else if (choices[i].Species != Species)
                        {
                            choices.RemoveAt(i);
                        }
                    }

                    if (choices.Count == 0)
                    {
                        IncStat("No Matching In Pool");
                    }
                    else
                    {
                        mNewSim = RandomUtil.GetRandomObjectFromList(choices);

                        PetPoolManager.RemovePet(poolType, mNewSim, true);
                    }

                    return(base.PrivateUpdate(frame));
                }
                else
                {
                    IncStat("Pool Empty: " + poolType);
                }
            }

            if (Manager.GetValue <ScheduledImmigrationScenario.GaugeOption, int>() > 0)
            {
                return(base.PrivateUpdate(frame));
            }
            else
            {
                IncStat("Immigration Disabled");
                return(false);
            }
        }