public static Urnstone CreateGrave(SimDescription me, SimDescription.DeathType deathType, bool ignoreExisting, bool report) { Urnstone urnstone = FindGhostsGrave(me); if ((urnstone != null) && (!ignoreExisting)) { if ((urnstone.InInventory) || (urnstone.InWorld)) { return(urnstone); } } Household originalHousehold = me.Household; bool addOnly = false; if (urnstone == null) { urnstone = PrivateCreateGrave(me); if (urnstone == null) { return(null); } } else { addOnly = true; } bool success = MoveToMausoleum(urnstone); if (!success) { if (me.CreatedSim != null) { if (Inventories.TryToMove(urnstone, me.CreatedSim.Inventory)) { success = true; } } if ((!success) && (Sim.ActiveActor != null)) { if (Inventories.TryToMove(urnstone, Sim.ActiveActor.Inventory)) { success = true; } } if (!success) { return(null); } } if (report) { Common.Notify(Common.Localize("ForceKill:Success", me.IsFemale, new object[] { me })); } if ((addOnly) && (!ignoreExisting)) { return(urnstone); } if ((originalHousehold == Household.ActiveHousehold) && (me.CreatedSim != null)) { HudModel model = HudController.Instance.Model as HudModel; foreach (SimInfo info in model.mSimList) { if (info.mGuid == me.CreatedSim.ObjectId) { model.RemoveSimInfo(info); model.mSimList.Remove(info); break; } } } if (me.CreatedSim != null) { me.CreatedSim.Destroy(); } if (originalHousehold != null) { originalHousehold.Remove(me, !originalHousehold.IsSpecialHousehold); } if (me.DeathStyle == SimDescription.DeathType.None) { if (me.IsHuman) { switch (deathType) { case SimDescription.DeathType.None: case SimDescription.DeathType.PetOldAgeBad: case SimDescription.DeathType.PetOldAgeGood: deathType = SimDescription.DeathType.OldAge; break; } } else { switch (deathType) { case SimDescription.DeathType.None: case SimDescription.DeathType.OldAge: deathType = SimDescription.DeathType.PetOldAgeGood; break; } } me.SetDeathStyle(deathType, true); } me.IsNeverSelectable = true; me.Contactable = false; me.Marryable = false; if (me.CreatedSim == PlumbBob.SelectedActor) { LotManager.SelectNextSim(); } if (me.CareerManager != null) { me.CareerManager.LeaveAllJobs(Sims3.Gameplay.Careers.Career.LeaveJobReason.kDied); } urnstone.OnHandToolMovement(); Urnstone.FinalizeSimDeath(me, originalHousehold); int num = ((int)Math.Floor((double)SimClock.ConvertFromTicks(SimClock.CurrentTime().Ticks, TimeUnit.Minutes))) % 60; urnstone.MinuteOfDeath = num; return(urnstone); }
public static bool Perform(SimDescription sim, bool cleanse) { if (sim == null) { return(false); } Common.StringBuilder msg = new Common.StringBuilder("Perform" + Common.NewLine); Household house = sim.Household; try { Sim createdSim = sim.CreatedSim; if (createdSim != null) { createdSim.ReservedVehicle = null; } if (PetAdoption.sNeighborAdoption != null) { if (PetAdoption.sNeighborAdoption.mMother == sim) { try { PetAdoption.ResetNeighborAdoption(); } catch (Exception e) { Common.Exception(sim, e); } finally { PetAdoption.sNeighborAdoption = null; } } else { PetAdoption.sNeighborAdoption.mPetsToAdopt.Remove(sim); } } foreach (Service service in Services.AllServices) { try { if (service == null) { continue; } msg += Common.NewLine + "Service: " + service.GetType(); if (sim.CreatedSim != null) { service.RemoveAssignment(sim.CreatedSim); } service.RemovePreferredSim(sim); service.mPool.Remove(sim); ResortWorker resortWorker = service as ResortWorker; if (resortWorker != null) { if (resortWorker.mWorkerInfo != null) { List <ObjectGuid> remove = new List <ObjectGuid>(); foreach (KeyValuePair <ObjectGuid, ResortWorker.WorkerInfo> info in resortWorker.mWorkerInfo) { if ((info.Value.CurrentSimDescriptionID == sim.SimDescriptionId) || (info.Value.DesiredSimDescriptionID == sim.SimDescriptionId)) { remove.Add(info.Key); } } foreach (ObjectGuid rem in remove) { resortWorker.mWorkerInfo[rem] = new ResortWorker.WorkerInfo(); } } } } catch (Exception e) { Common.Exception(sim, null, msg, e); } } msg += Common.NewLine + "A"; List <Household> houses = new List <Household>(); if (house != null) { houses.Add(house); } foreach (Household check in Household.sHouseholdList) { if (check == house) { continue; } if (check.Contains(sim)) { houses.Add(check); } } foreach (Household remove in houses) { Household.HouseholdSimsChangedCallback changedCallback = null; try { changedCallback = remove.HouseholdSimsChanged; remove.HouseholdSimsChanged = null; remove.Remove(sim, !remove.IsSpecialHousehold); } finally { remove.HouseholdSimsChanged = changedCallback; } } msg += Common.NewLine + "B"; try { if (cleanse) { if (sim.LifeEventManager != null) { sim.LifeEventManager.Purge(); } } } catch (Exception e) { Common.Exception(sim, null, msg, e); } msg += Common.NewLine + "C"; RemoveSimDescriptionRelationships(sim); msg += Common.NewLine + "D"; PetPoolManager.RemoveIdFromPool(sim.SimDescriptionId); msg += Common.NewLine + "E"; try { if (sim.CareerManager != null) { sim.CareerManager.LeaveAllJobs(Career.LeaveJobReason.kDied); } } catch (Exception e) { sim.CareerManager.mJob = null; sim.CareerManager.mSchool = null; Common.Exception(sim, null, msg, e); } msg += Common.NewLine + "F"; if (sim.CASGenealogy == null) { // Necessary to stop an error in MidLifeCrisisManager sim.mGenealogy = new Genealogy(sim); } msg += Common.NewLine + "G"; try { if (sim.Partner != null) { sim.Partner.Partner = null; } sim.Partner = null; } catch (Exception e) { Common.Exception(sim, null, msg, e); } msg += Common.NewLine + "H"; if (sim.DeathStyle != SimDescription.DeathType.None) { // Passing in a household can invoke the social worker, so don't bother Urnstone.FinalizeSimDeath(sim, null /*house*/); } msg += Common.NewLine + "I"; Urnstone urnstone = Urnstones.FindGhostsGrave(sim); msg += Common.NewLine + "J"; if ((cleanse) && (urnstone != null)) { if (urnstone.InInventory) { Inventory inventory = Inventories.ParentInventory(urnstone); if (inventory != null) { inventory.RemoveByForce(urnstone); } } if (urnstone.DeadSimsDescription != null) { urnstone.DeadSimsDescription.Fixup(); } try { urnstone.Dispose(); } catch (Exception e) { Common.DebugException(sim, null, msg, e); } urnstone.Destroy(); } msg += Common.NewLine + "K"; if ((FakeMetaAutonomy.Instance != null) && (FakeMetaAutonomy.Instance.mPool != null)) { FakeMetaAutonomy.Instance.mPool.Remove(sim); } msg += Common.NewLine + "L"; if (Sims3.Gameplay.Services.FakeMetaAutonomy.mToDestroy != null) { Sims3.Gameplay.Services.FakeMetaAutonomy.mToDestroy.Remove(sim); } msg += Common.NewLine + "M"; if ((houses.Contains(Household.ActiveHousehold)) && (sim.CreatedSim != null)) { HudModel model = HudController.Instance.Model as HudModel; foreach (SimInfo info in model.mSimList) { if (info.mGuid == sim.CreatedSim.ObjectId) { model.RemoveSimInfo(info); model.mSimList.Remove(info); break; } } } msg += Common.NewLine + "N"; try { if (sim.AssignedRole != null) { sim.AssignedRole.RemoveSimFromRole(); } } catch (Exception e) { Common.DebugException(sim, null, msg, e); sim.AssignedRole = null; } msg += Common.NewLine + "O1"; if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null)) { foreach (Stack <SimDescription> stack in CarNpcManager.Singleton.NpcDriversManager.mDescPools) { if (stack == null) { continue; } List <SimDescription> sims = new List <SimDescription>(); bool found = false; foreach (SimDescription stackSim in stack) { if (stackSim == sim) { found = true; } else { sims.Add(stackSim); } } if (found) { stack.Clear(); foreach (SimDescription stackSim in sims) { stack.Push(stackSim); } } } } msg += Common.NewLine + "O2"; if (cleanse) { sim.Dispose(); } msg += Common.NewLine + "P"; if ((house != null) && (createdSim != null)) { house.OnMemberChanged(sim, createdSim); } return(true); } catch (Exception e) { Common.Exception(sim, null, msg, e); if (house != null) { Household.HouseholdSimsChangedCallback changedCallback = null; try { changedCallback = house.HouseholdSimsChanged; house.HouseholdSimsChanged = null; house.Add(sim); } finally { house.HouseholdSimsChanged = changedCallback; } } return(false); } }