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); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List <IApplyOptionItem> services = new List <IApplyOptionItem>(); foreach (ServiceType type in Enum.GetValues(typeof(ServiceType))) { int count = 0; bool found = false; foreach (Service service in Services.AllServices) { if (service.ServiceType == type) { count = service.mPool.Count; found = true; break; } } if (!found) { continue; } services.Add(new StatusServiceType.Item(type, count)); } foreach (PetPoolType type in Enum.GetValues(typeof(PetPoolType))) { if (PetPoolManager.IsPoolFull(type)) { continue; } int count = PetPoolManager.GetPoolSize(type); services.Add(new StatusPetPool.Item(type, count)); } if (GameUtils.IsInstalled(ProductVersion.EP10)) { services.Add(new MermaidServiceItem(CommonSpace.Helpers.Households.NumSims(Household.MermaidHousehold))); } IApplyOptionItem selection = new CommonSelection <IApplyOptionItem>(Name, me.FullName, services).SelectSingle(); if (selection == null) { return(false); } mPool = selection; } List <IMiniSimDescription> list = new List <IMiniSimDescription>(); list.Add(me); if (!AddSim.TestForRemainingActive(list)) { Common.Notify(Common.Localize("AddSim:ActiveFail")); return(false); } mPool.Apply(me); return(true); }