public static void RemoveMSD(ulong id) { MiniSimDescription.RemoveMSD(id); if (FutureDescendantService.sPersistableData != null) { if (FutureDescendantService.sPersistableData.DescendantHouseholdsMap != null) { FutureDescendantService.sPersistableData.DescendantHouseholdsMap.Remove(id); } } CauseEffectService instance = CauseEffectService.GetInstance(); if (instance != null) { if (CauseEffectService.sPersistableData != null) { if (CauseEffectService.sPersistableData.TimeTravelerSimID == id) { CauseEffectService.sPersistableData.TimeTravelerSimID = 0; } } List <ITimeStatueUiData> timeStatueData = instance.GetTimeAlmanacTimeStatueData(); if (timeStatueData != null) { foreach (ITimeStatueUiData data in timeStatueData) { TimeStatueRecordData record = data as TimeStatueRecordData; if (record == null) { continue; } if (record.mRecordHolderId == id) { record.mRecordHolderId = 0; } } } } }
public void OnWorldLoadFinished() { Overwatch.Log("CleanupCauseEffect"); CauseEffectService instance = CauseEffectService.GetInstance(); if (instance != null) { ulong timeTravelerSimID = instance.GetTimeTravelerSimID(); if (MiniSimDescription.Find(timeTravelerSimID) == null) { CauseEffectService.sPersistableData.TimeTravelerSimID = 0; Overwatch.Log(" Removed Corrupt Time Traveler Referece"); } List <ITimeStatueUiData> timeStatueData = instance.GetTimeAlmanacTimeStatueData(); if (timeStatueData != null) { foreach (ITimeStatueUiData data in timeStatueData) { TimeStatueRecordData record = data as TimeStatueRecordData; if (record == null) { continue; } if (MiniSimDescription.Find(record.mRecordHolderId) == null) { record.mRecordHolderId = 0; Overwatch.Log(" Removed Corrupt Record Holder Referece"); } } } } }
public static void Perform() { Dictionary <ulong, bool> taxiDrivers = new Dictionary <ulong, bool>(); List <ulong> paps = new List <ulong>(); if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null)) { for (int i = 0; i < CarNpcManager.Singleton.NpcDriversManager.mDescPools.Length; i++) { Stack <SimDescription> stack = CarNpcManager.Singleton.NpcDriversManager.mDescPools[i]; if (stack == null) { continue; } NpcDriversManager.NpcDrivers type = (NpcDriversManager.NpcDrivers)(i + 0x95d01441); while (stack.Count > 10) { SimDescription sim = stack.Pop(); try { AttemptServiceDisposal(sim, false, "Too Many " + type); } catch (Exception e) { Common.Exception(sim, e); } } foreach (SimDescription sim in stack) { if (taxiDrivers.ContainsKey(sim.SimDescriptionId)) { continue; } taxiDrivers.Add(sim.SimDescriptionId, true); } } } Dictionary <ulong, bool> statueSims = new Dictionary <ulong, bool>(); CauseEffectService instance = CauseEffectService.GetInstance(); if (instance != null) { statueSims[instance.GetTimeTravelerSimID()] = true; List <ITimeStatueUiData> timeStatueData = instance.GetTimeAlmanacTimeStatueData(); if (timeStatueData != null) { foreach (ITimeStatueUiData data in timeStatueData) { TimeStatueRecordData record = data as TimeStatueRecordData; if (record == null) { continue; } statueSims[record.mRecordHolderId] = true; } } } foreach (SimDescription sim in new List <SimDescription> (Households.All(Household.NpcHousehold))) { try { if (SimTypes.IsDead(sim)) { continue; } if (taxiDrivers.ContainsKey(sim.SimDescriptionId)) { continue; } CommonCorrections(sim); if (SimTypes.InServicePool(sim, ServiceType.GrimReaper)) { continue; } if (statueSims.ContainsKey(sim.SimDescriptionId)) { continue; } uint spanLevel = 0; OptionsModel.GetOptionSetting("AgingInterval", out spanLevel); float averageElderAge = AgingManager.Singleton.GetAverageSimLifespanInDays((int)spanLevel); ServiceType type = ServiceType.None; if (sim.CreatedByService != null) { type = sim.CreatedByService.ServiceType; } if (AgingManager.Singleton.GetCurrentAgeInDays(sim) > averageElderAge) { if (sim.LotHome == null) { bool isRole = sim.AssignedRole != null; AttemptServiceDisposal(sim, true, "Too Old " + (!isRole ? type.ToString() : sim.AssignedRole.Type.ToString())); } } if (sim.AssignedRole != null && sim.AssignedRole is RolePaparazzi) { paps.Add(sim.SimDescriptionId); } if (sim.AssignedRole != null) { continue; } if (SimTypes.IsOccult(sim, OccultTypes.ImaginaryFriend)) { bool found = false; foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects <ImaginaryDoll>()) { if (sim.SimDescriptionId == doll.mLiveStateSimDescId) { found = true; break; } } if (found) { continue; } AttemptServiceDisposal(sim, false, "Imaginary"); } else if (SimTypes.IsOccult(sim, OccultTypes.Genie)) { bool found = false; foreach (GenieLamp lamp in Sims3.Gameplay.Queries.GetObjects <GenieLamp>()) { if (sim == lamp.mGenieDescription) { found = true; break; } } if (found) { continue; } AttemptServiceDisposal(sim, false, "Genie"); } else if (sim.IsBonehilda) { bool found = false; foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>()) { if (sim == coffin.mBonehilda) { found = true; break; } } if (found) { continue; } AttemptServiceDisposal(sim, false, "BoneHilda"); } else if ((sim.AssignedRole == null) && (!SimTypes.InServicePool(sim))) { AttemptServiceDisposal(sim, false, "No Purpose"); } else if ((type != ServiceType.None) && (sim.Age & ServiceNPCSpecifications.GetAppropriateAges(type.ToString())) == CASAgeGenderFlags.None) { AttemptServiceDisposal(sim, false, "Wrong Age " + type); } else if (!ServiceNPCSpecifications.ShouldUseServobot(type.ToString()) && sim.IsEP11Bot) { AttemptServiceDisposal(sim, false, "Not EP11 Bot " + type); } } catch (Exception e) { Common.Exception(sim, e); } } // kill extra paps if (paps.Count > Register.Settings.mMaximumPaparazzi) { int count = paps.Count; while (count > Register.Settings.mMaximumPaparazzi && count > 0) { SimDescription sim = SimDescription.Find(paps[0]); if (sim != null) { AttemptServiceDisposal(sim, false, "Too many Paparazzi"); } paps.Remove(paps[0]); count = count - 1; } } foreach (SimDescription sim in new List <SimDescription> (Households.All(Household.PetHousehold))) { try { if (SimTypes.IsDead(sim)) { continue; } CommonCorrections(sim); if ((sim.IsDeer) || (sim.IsRaccoon)) { if (sim.AssignedRole == null) { AttemptServiceDisposal(sim, false, "Roleless"); } else if (sim.Elder) { AttemptServiceDisposal(sim, true, "Elder"); } } else { bool noPool; PetPoolType pool = SimTypes.GetPetPool(sim, out noPool); if ((!noPool) && (pool == PetPoolType.None)) { AttemptServiceDisposal(sim, false, "Not Pooled"); } } } catch (Exception e) { Common.Exception(sim, e); } } }
public static void ShowTimeAlmanacDialog() { if (!Responder.Instance.IsGameStatePending || !Responder.Instance.IsGameStateShuttingDown) { ICauseEffectUiData causeEffectData = null; List <ITimeStatueUiData> timeStatueData = null; List <IDescendantHouseholdUiData> descendantHouseholdInfo = null; CauseEffectService instance = CauseEffectService.GetInstance(); if (instance != null) { causeEffectData = instance.GetTimeAlmanacCauseEffectData(); timeStatueData = instance.GetTimeAlmanacTimeStatueData(); } FutureDescendantService service2 = GetInstance(); if (service2 != null) { // custom descendantHouseholdInfo = GetTimeAlamanacDescendantHouseholdData(service2); } Sim currentSim = PlumbBob.SelectedActor; TimeAlmanacDialog.TimeAlmanacResult result = TimeAlmanacDialog.Show(currentSim.ObjectId, causeEffectData, descendantHouseholdInfo, timeStatueData); bool flag = currentSim.OpportunityManager.HasOpportunity(OpportunityCategory.Special); bool flag2 = result != TimeAlmanacDialog.TimeAlmanacResult.DoNothing; if (flag2 && flag) { string promptText = Localization.LocalizeString(currentSim.IsFemale, "Ui/Caption/TimeAlmanac:ChangeEventPrompt", new object[] { currentSim, currentSim.OpportunityManager.GetActiveOpportunity(OpportunityCategory.Special).Name }); string buttonTrue = Localization.LocalizeString("Ui/Caption/Global:Yes", new object[0]); string buttonFalse = Localization.LocalizeString("Ui/Caption/Global:No", new object[0]); flag2 = TwoButtonDialog.Show(promptText, buttonTrue, buttonFalse); if (flag2) { currentSim.OpportunityManager.CancelOpportunityByCategory(OpportunityCategory.Special); } } if (flag2) { switch (result) { case TimeAlmanacDialog.TimeAlmanacResult.DoNothing: break; case TimeAlmanacDialog.TimeAlmanacResult.TrashOpportunity: currentSim.OpportunityManager.ClearLastOpportunity(OpportunityCategory.Special); currentSim.OpportunityManager.AddOpportunityNow(OpportunityNames.EP11_Trigger_DystopiaFuture, true, false); return; case TimeAlmanacDialog.TimeAlmanacResult.MeteorOpportunity: if (CauseEffectWorldState.kUtopiaState != instance.GetCurrentCauseEffectWorldState()) { if (CauseEffectWorldState.kDystopiaState == instance.GetCurrentCauseEffectWorldState()) { currentSim.OpportunityManager.ClearLastOpportunity(OpportunityCategory.Special); currentSim.OpportunityManager.AddOpportunityNow(OpportunityNames.EP11_Undo_DystopiaFuture, true, false); return; } break; } currentSim.OpportunityManager.ClearLastOpportunity(OpportunityCategory.Special); unchecked { currentSim.OpportunityManager.AddOpportunityNow((OpportunityNames)(-5928144135704983787L), true, false); } return; case TimeAlmanacDialog.TimeAlmanacResult.RainbowOpportunity: currentSim.OpportunityManager.ClearLastOpportunity(OpportunityCategory.Special); currentSim.OpportunityManager.AddOpportunityNow(OpportunityNames.EP11_Trigger_UtopiaFuture, true, false); break; default: return; } } } }