public static Urnstone SimToPlayableGhost(SimDescription me, SimDescription.DeathType deathType) { Urnstone urnstone = FindGhostsGrave(me); if (urnstone == null) { urnstone = PrivateCreateGrave(me); if (urnstone == null) { return(null); } } if (!Inventories.TryToMove(urnstone, me.CreatedSim)) { MoveToMausoleum(urnstone); } me.IsGhost = true; me.SetDeathStyle(deathType, true); if (me.CreatedSim != null) { urnstone.GhostSetup(me.CreatedSim, true); if (!me.IsEP11Bot) { me.AgingEnabled = true; me.PushAgingEnabledToAgingManager(); } } return(urnstone); }
// Lacks the "greater than eight" restriction public static bool GhostToPlayableGhost(Urnstone ths, Household newHousehold, Vector3 ghostPosition) { SimDescription simDescription = ths.DeadSimsDescription; if (!simDescription.IsValidDescription) { simDescription.Fixup(); } if (simDescription.Household != null) { simDescription.Household.Remove(simDescription, !simDescription.Household.IsSpecialHousehold); } if (!newHousehold.Contains(simDescription)) { newHousehold.Add(simDescription); } Sim ghost = Instantiation.Perform(simDescription, ghostPosition, null, null); if (ghost == null) return false; ths.GhostSetup(ghost, true); ths.RemoveMourningRelatedBuffs(ghost); simDescription.ShowSocialsOnSim = true; simDescription.IsNeverSelectable = false; simDescription.Marryable = true; simDescription.Contactable = true; if (!simDescription.IsEP11Bot) { simDescription.AgingEnabled = true; simDescription.AgingState.ResetAndExtendAgingStage(0f); simDescription.PushAgingEnabledToAgingManager(); } string failureReason; if (!Inventories.TryToMove(ths, ghost.Inventory, true, out failureReason)) { Common.DebugNotify(failureReason); } //Inventories.TryToMove(ths, ghost); if (simDescription.Child || simDescription.Teen) { simDescription.AssignSchool(); } if (ghost.IsSelectable) { ghost.OnBecameSelectable(); } return true; }
public static bool GhostSpawn(Urnstone me, Lot lot) { if (me.DeadSimsDescription == null) { return(false); } if (!me.DeadSimsDescription.IsValidDescription) { me.DeadSimsDescription.Fixup(); } Vector3 position; if (me.DeadSimsDescription.ToddlerOrBelow) { position = lot.EntryPoint(); } else if (!me.InInventory) { position = me.Position; } else { position = Service.GetPositionInRandomLot(lot); } Household.NpcHousehold.Add(me.DeadSimsDescription); Sim sim = Instantiation.Perform(me.DeadSimsDescription, position, null, null); sim.SetOpacity(0f, 0f); ActiveTopic.AddToSim(sim, "Ghost"); me.GhostSetup(sim, true); if (!me.InInventory) { sim.GreetSimOnLot(me.LotCurrent); Audio.StartObjectSound(me.ObjectId, "sting_ghost_appear", false); } sim.FadeIn(); me.CreateAlarmReturnToGrave(false); return(true); }
public void Dispose(bool postLoad, bool isReset) { try { if (mWasFutureSim) { mSim.TraitManager.AddHiddenElement(TraitNames.FutureSim); } if (mSim.CreatedSim != null) { BuffManager buffManager = mSim.CreatedSim.BuffManager; if ((buffManager != null) && (mBuffs != null)) { foreach (BuffInstance buff in mBuffs) { buffManager.AddBuff(buff.Guid, buff.mEffectValue, buff.mTimeoutCount, buff.mTimeoutPaused, buff.mAxisEffected, buff.mBuffOrigin, false); } } if ((mInventory != null) && (mSim.CreatedSim.Inventory != null)) { Inventories.RestoreInventoryFromList(mSim.CreatedSim.Inventory, mInventory, true); } if (mDreamStore != null) { mDreamStore.Restore(mSim.CreatedSim); } if (mSafeStore != null) { mSafeStore.Dispose(); } if (mSim.DeathStyle != SimDescription.DeathType.None) { Urnstone stone = Urnstones.FindGhostsGrave(mSim); if (stone != null) { stone.GhostSetup(mSim.CreatedSim, true); } } mSim.CreatedSim.ReservedVehicle = mReservedVehicle; } } catch (Exception e) { Common.Exception(mSim, null, "Inventory", e); } // Must be after the opportunities are restored if ((mOpportunitiesChanged != null) && (OpportunityTrackerModel.gSingleton != null)) { OpportunityTrackerModel.gSingleton.OpportunitiesChanged = mOpportunitiesChanged; } try { if (!postLoad) { if ((mSim.CreatedSim != null) && (mSim.CreatedSim.OpportunityManager != null) && (mSim.CreatedSim.OpportunityManager.Count > 0)) { OpportunityTrackerModel.FireOpportunitiesChanged(); } } } catch (Exception e) { Common.Exception(mSim, null, "FireOpportunitiesChanged", e); } EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false; mSim.mGenealogy = mGenealogy; if (mDoll != null) { mDoll.mOwner = mSim; if (SimTypes.IsSelectable(mSim)) { try { mDoll.OnOwnerBecameSelectable(); } catch (Exception e) { Common.Exception(mSim, e); SimDescription sim = mDoll.GetLiveFormSimDescription(); if (sim != null) { new FixInvisibleTask(sim).AddToSimulator(); } } } } if ((mSim.CreatedSim != null) && (mSim.CreatedSim.Motives != null)) { if (mAcademicPerformance != -101) { mSim.CreatedSim.Motives.CreateMotive(CommodityKind.AcademicPerformance); Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.AcademicPerformance); if (motive != null) { motive.Value = mAcademicPerformance; } } if (mUniversityStudy != -101) { mSim.CreatedSim.Motives.CreateMotive(CommodityKind.UniversityStudy); Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.UniversityStudy); if (motive != null) { motive.Value = mUniversityStudy; } } } Relationships.RestoreRelations(mSim, mRelations); if ((mSim.TraitChipManager != null) && (mChips != null)) { for (int i = 0; i < mChips.Length; i++) { if (mChips[i] == null) { continue; } Common.StringBuilder name = new Common.StringBuilder(); try { name.Append(mChips[i].GetLocalizedName()); mSim.TraitChipManager.AddTraitChip(mChips[i], i); } catch (Exception e) { Common.Exception(mSim, null, name, e); } } } sChangingWorldsSuppression.Pop(); if ((mChangedHousehold != null) && (mChangedCallback != null)) { mChangedHousehold.HouseholdSimsChanged = mChangedCallback; } }
// Lacks the "greater than eight" restriction public static bool GhostToPlayableGhost(Urnstone ths, Household newHousehold, Vector3 ghostPosition) { SimDescription simDescription = ths.DeadSimsDescription; if (!simDescription.IsValidDescription) { simDescription.Fixup(); } if (simDescription.Household != null) { simDescription.Household.Remove(simDescription, !simDescription.Household.IsSpecialHousehold); } if (!newHousehold.Contains(simDescription)) { newHousehold.Add(simDescription); } Sim ghost = Instantiation.Perform(simDescription, ghostPosition, null, null); if (ghost == null) { return(false); } ths.GhostSetup(ghost, true); ths.RemoveMourningRelatedBuffs(ghost); simDescription.ShowSocialsOnSim = true; simDescription.IsNeverSelectable = false; simDescription.Marryable = true; simDescription.Contactable = true; if (!simDescription.IsEP11Bot) { simDescription.AgingEnabled = true; simDescription.AgingState.ResetAndExtendAgingStage(0f); simDescription.PushAgingEnabledToAgingManager(); } string failureReason; if (!Inventories.TryToMove(ths, ghost.Inventory, true, out failureReason)) { Common.DebugNotify(failureReason); } //Inventories.TryToMove(ths, ghost); if (simDescription.Child || simDescription.Teen) { simDescription.AssignSchool(); } if (ghost.IsSelectable) { ghost.OnBecameSelectable(); } return(true); }
protected static bool DelayedKill(Sim actor, Sim target, SimDescription.DeathType deathType) { if (actor == target) { target.SimDescription.SetDeathStyle(deathType, true); Urnstone urnstone = Urnstone.CreateGrave(target.SimDescription, false, true); if (urnstone != null) { if (!target.Inventory.TryToAdd(urnstone, false)) { urnstone.Destroy(); return(false); } urnstone.GhostSetup(target, true); } } else { List <IRabbitHolePartnershipDeed> list = Inventories.QuickDuoFind <IRabbitHolePartnershipDeed, GameObject>(target.Inventory); if ((list != null) && (list.Count > 0x0)) { Sim sim = null; float minValue = float.MinValue; foreach (Sim sim2 in Households.AllHumans(target.Household)) { if (sim2 != target) { float liking = -100f; Relationship relationship = Relationship.Get(target, sim2, false); if (relationship != null) { liking = relationship.LTR.Liking; } if (liking > minValue) { minValue = liking; sim = sim2; } } } foreach (IRabbitHolePartnershipDeed deed in list) { target.Inventory.RemoveByForce(deed); if (sim != null) { sim.Inventory.TryToAdd(deed, false); } else { deed.Destroy(); } } } InteractionInstance entry = Urnstone.KillSim.Singleton.CreateInstance(target, target, new InteractionPriority(InteractionPriorityLevel.MaxDeath, 0f), false, false); (entry as Urnstone.KillSim).simDeathType = deathType; target.InteractionQueue.Add(entry); } return(true); }
public static bool GhostSpawn(Urnstone me, Lot lot) { if (me.DeadSimsDescription == null) { return false; } if (!me.DeadSimsDescription.IsValidDescription) { me.DeadSimsDescription.Fixup(); } Vector3 position; if (me.DeadSimsDescription.ToddlerOrBelow) { position = lot.EntryPoint(); } else if (!me.InInventory) { position = me.Position; } else { position = Service.GetPositionInRandomLot(lot); } Household.NpcHousehold.Add(me.DeadSimsDescription); Sim sim = Instantiation.Perform(me.DeadSimsDescription, position, null, null); sim.SetOpacity(0f, 0f); ActiveTopic.AddToSim(sim, "Ghost"); me.GhostSetup(sim, true); if (!me.InInventory) { sim.GreetSimOnLot(me.LotCurrent); Audio.StartObjectSound(me.ObjectId, "sting_ghost_appear", false); } sim.FadeIn(); me.CreateAlarmReturnToGrave(false); return true; }