public static void MergeOccults(OccultManager ths, OccultManager source) { Common.StringBuilder msg = new Common.StringBuilder("MergeOccults " + ths.mOwnerDescription.FullName + Common.NewLine); Traveler.InsanityWriteLog(msg); foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes))) { try { switch (type) { case OccultTypes.None: case OccultTypes.Ghost: break; default: if ((source.HasOccultType(type)) && (!ths.HasOccultType(type))) { msg += Common.NewLine + "A " + type; Traveler.InsanityWriteLog(msg); ths.MergeOccult(type); } if ((!source.HasOccultType(type)) && (ths.HasOccultType(type))) { msg += Common.NewLine + "B " + type; Traveler.InsanityWriteLog(msg); OccultTypeHelper.Remove(ths.mOwnerDescription, type, false); } break; } } catch (Exception e) { Common.Exception(ths.mOwnerDescription, null, "Type: " + type, e); } } }
public static void MergeOccults(OccultManager ths, OccultManager source) { Common.StringBuilder msg = new Common.StringBuilder("MergeOccults " + ths.mOwnerDescription.FullName + Common.NewLine); Traveler.InsanityWriteLog(msg); foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes))) { try { switch (type) { case OccultTypes.None: case OccultTypes.Ghost: break; default: if ((source.HasOccultType(type)) && (!ths.HasOccultType(type))) { msg += Common.NewLine + "A " + type; Traveler.InsanityWriteLog(msg); ths.MergeOccult(type); } if ((!source.HasOccultType(type)) && (ths.HasOccultType(type))) { msg += Common.NewLine + "B " + type; Traveler.InsanityWriteLog(msg); OccultTypeHelper.Remove(ths.mOwnerDescription, type, false); } break; } } catch (Exception e) { Common.Exception(ths.mOwnerDescription, null, "Type: " + type, e); } } }
public static bool IsValidOccult(SimDescription sim, List <OccultTypes> types) { if (sim == null) { return(false); } OccultManager manager = sim.OccultManager; if (manager == null) { return(false); } foreach (OccultTypes type in types) { if (manager.HasOccultType(type)) { return(true); } } return(false); }
/* * DebugString: "_NFixUp(): if (ListCollon.NullSimSimDescription == this)" * DebugString: "NMScript Exception Log * System.Exception: no message * #0: 0x0001f throw in Sims3.Gameplay.CAS.Sims3.Gameplay.CAS.SimDescription:Fixup () () #1: 0x00050 callvirt in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.RecoverMissingSims:PrivatePerformAction (bool) (9193E9C0 [0] ) #2: 0x00011 callvirt in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAction (bool) (9193E9C0 [0] ) #3: 0x00002 call in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAlarm () () #4: 0x0001b callvirt in NRaas.NRaas.Overwatch:OnTimer () () #5: 0x00000 in Sims3.Gameplay.Sims3.Gameplay.Function:Invoke () () #6: 0x00003 callvirt in NRaas.Common+FunctionTask:Simulate () () */ public void _NFixUp() { if (runI) { return; } if (ListCollon.NullSimSimDescription == this) { if (niec_native_func.cache_done_niecmod_native_debug_text_to_debugger) { niec_native_func.OutputDebugString("_NFixUp(): if (ListCollon.NullSimSimDescription == this)"); try { throw new Exception("no message"); } catch (Exception ex) { NiecException.SendTextExceptionToDebugger(ex); } } mIsValidDescription = false; NFinalizeDeath.SimDesc_NullToEmpty(this); mIsValidDescription = true; if (UnsafeFixNUllSimDESC) { var p = NFinalizeDeath.GetSafeSelectActor(); if (p != null && p.SimDescription != null) { mOutfits = p.SimDescription.Outfits; } if (!waitrunningtask01) { waitrunningtask01 = true; NiecTask.Perform(() => { for (int i = 0; i < 800; i++) { Simulator.Sleep(0); } waitrunningtask01 = false; NFinalizeDeath.SimDescCleanse(this, true, false); }); } } else if (!waitrunningtask01) { waitrunningtask01 = true; NiecTask.Perform(() => { for (int i = 0; i < 50; i++) { Simulator.Sleep(0); } waitrunningtask01 = false; NFinalizeDeath.SimDescCleanse(this, true, true); }); } return; } mIsValidDescription = true; if (base.TraitManager != null) { base.TraitManager.SetSimDescription(this); base.TraitManager.Fixup(); } if (CreatedSim != null && CreatedSim.Inventory != null) { foreach (TraitChip item in CreatedSim.Inventory.FindAll <TraitChip>(false)) { item.OnLoadFixup(); if (item.Owner == null) { item.SetOwner(this); } } } MiniSimDescription miniSimDescription = MiniSimDescription.Find(SimDescriptionId); if ((GameStates.IsTravelling || GameStates.IsEditingOtherTown) && miniSimDescription != null) { base.CASGenealogy = miniSimDescription.Genealogy; } if (GameObjectRelationships != null) { int i = 0; while (i < GameObjectRelationships.Count) { if (!Sims3.SimIFace.Objects.IsValid(GameObjectRelationships[i].GameObjectDescription.GameObject.ObjectId)) { GameObjectRelationships.RemoveAt(i); } else { i++; } } } if (mGenealogy == null) { mGenealogy = new Genealogy(this); } if (SkillManager == null) { SkillManager = new SkillManager(this); } else { SkillManager.OnLoadFixup(); } if (CareerManager == null) { CareerManager = new CareerManager(this); } else { CareerManager.OnLoadFixup(); } if (VisaManager == null) { VisaManager = new VisaManager(this); } else { VisaManager.OnLoadFixup(); } if (CelebrityManager == null) { CelebrityManager = new CelebrityManager(SimDescriptionId); } else if (CelebrityManager.Owner == null) { CelebrityManager.ResetOwnerSimDescription(SimDescriptionId); } if (LifeEventManager == null || !LifeEventManager.IsValid) { LifeEventManager = new LifeEventManager(this); } LifeEventManager.ClearInvalidActiveNodes(); if (OccultManager == null) { OccultManager = new OccultManager(this); } else { OccultManager.OnLoadFixup(); } if (IsPet) { if (PetManager == null) { PetManager = CreatePetManager(); } } else if (PetManager != null) { PetManager.Dispose(); PetManager = null; } if (IsEP11Bot) { if (TraitChipManager == null) { TraitChipManager = new TraitChipManager(this); } else if (TraitChipManager.Owner == null) { TraitChipManager.ResetOwnerSimDescription(SimDescriptionId); } TraitChipManager.OnLoadFixup(); } else if (TraitChipManager != null) { TraitChipManager.Dispose(); TraitChipManager = null; } AssignSchool(); if (mSimDescriptionId == 0) { MakeUniqueId(); } if (ReadBookDataList == null) { ReadBookDataList = new Dictionary <string, ReadBookData>(); } PushAgingEnabledToAgingManager(); if (mInitialShape.Owner == null || mCurrentShape.Owner == null || mInitialShape.Owner != this || mCurrentShape.Owner != this) { mInitialShape.Owner = (mCurrentShape.Owner = this); } if (OpportunityHistory == null) { OpportunityHistory = new OpportunityHistory(); } if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile && !Household.IsTravelImport && !GameStates.IsIdTravelling(SimDescriptionId)) { mDisplayedShape.Owner = mCurrentShape.Owner; mDisplayedShape.Fit = mCurrentShape.Fit; mDisplayedShape.Weight = mCurrentShape.Weight; mDisplayedShape.Pregnant = mCurrentShape.Pregnant; ResetLifetimeHappinessStatistics(); mHomeWorld = GameUtils.GetCurrentWorld(); } if (mHomeWorld == WorldName.Undefined) { mHomeWorld = GameUtils.GetCurrentWorld(); } if (RelicStats == null) { RelicStats = new RelicStatTracking(this); } RelicStats.SetSimDescription(this); if (TombStats == null) { TombStats = new TombStatTracking(this); } TombStats.SetSimDescription(this); if (Singing == null) { Singing = new SingingInfo(this); } Singing.SetSimDesctiption(this); if (AssignedRole != null) { AssignedRole.OnLoadFixUp(); } Lot lot = LotManager.GetLot(mVirtualLotId); if (lot != null) { lot.VirtualMoveIn(this); } if (Species == CASAgeGenderFlags.None) { Species = CASAgeGenderFlags.Human; } if (!CASLogic.GetSingleton().IsMusicTypeInstalled(FavoriteMusic)) { RandomizeFavoriteMusic(); } if (GetCurrentOutfits() != null) { OutfitCategories[] array = new OutfitCategories[5] { OutfitCategories.None, OutfitCategories.All, OutfitCategories.CategoryMask, OutfitCategories.PrimaryCategories, OutfitCategories.PrimaryHorseCategories }; foreach (var outfitCategories in array) { if (GetOutfitCount(outfitCategories) > 0) { RemoveOutfits(outfitCategories, false); if (base.mMaternityOutfits != null) { base.mMaternityOutfits.Remove(outfitCategories); } if (base.mOutfits != null) { base.mOutfits.Remove(outfitCategories); } } } } if (!GameUtils.IsInstalled(ProductVersion.EP4)) { Sim.PlayPretend.RemoveAllChildCostumeOutfits(this); if (CreatedSim != null && CreatedSim.CurrentOutfitCategory == OutfitCategories.ChildImagination) { CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday); } RemoveOutfits(OutfitCategories.ChildImagination, true); base.Outfits.Remove(OutfitCategories.ChildImagination); if (SpoiledGiftHistory != null) { SpoiledGiftHistory.Clear(); SpoiledGiftHistory = null; } } if (CreatedSim != null && (OccultManager == null || !OccultManager.HasOccultType(OccultTypes.Vampire | OccultTypes.Genie | OccultTypes.Werewolf | OccultTypes.Ghost)) && mSkinToneKey.InstanceId == 15475186560318337848uL) { World.ObjectSetVisualOverride(CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null); } }
public Sim _NInstantiate(Vector3 position, ResourceKey outfitKey, bool addInitialObjects, bool forceAlwaysAnimate) { if (runI) { return(null); } if (NiecHelperSituation.__acorewIsnstalled__) { if (!Instantiator.kDontCallDGSACore && NFinalizeDeath.RUNIACORE != null) { NFinalizeDeath.RUNIACORE(false); } else { NFinalizeDeath.CheckNHSP(); } } if (CreatedSim != null) { return(CreatedSim); } if (AgingState != null) { bool isDefaultOutfit = outfitKey == mDefaultOutfitKey; AgingState.PreInstantiateSim(ref outfitKey); if (isDefaultOutfit) { mDefaultOutfitKey = outfitKey; } } Hashtable hashtable = new Hashtable(forceAlwaysAnimate ? 4 : 2); hashtable["simOutfitKey"] = outfitKey; hashtable["rigKey"] = CASUtils.GetRigKeyForAgeGenderSpecies(Age | Gender | Species); if (forceAlwaysAnimate) { hashtable["enableSimPoseProcessing"] = 1u; hashtable["animationRunsInRealtime"] = 1u; } string instanceName = "GameSim"; ProductVersion version = ProductVersion.BaseGame; if (Species != CASAgeGenderFlags.Human) { instanceName = "Game" + Species; version = ProductVersion.EP5; } bool shouldNullHousehold = false; if (Household == null) { mHousehold = Household.NpcHousehold ?? Household.ActiveHousehold; shouldNullHousehold = true; } Sim sim = GlobalFunctions.CreateObjectWithOverrides(instanceName, version, position, 0, Vector3.UnitZ, hashtable, new SimInitParameters(this)) as Sim; if (sim != null) { sim.mSimDescription = this; this.mSim = sim; if (sim.SimRoutingComponent != null) { sim.SimRoutingComponent.EnableDynamicFootprint(); sim.SimRoutingComponent.ForceUpdateDynamicFootprint(); } try { if (sim.IsSelectable) { sim.AddInitialObjects(true); } } catch (ResetException) { throw; } catch (Exception) { } PushAgingEnabledToAgingManager(); if (OccultManager != null) { OccultManager.SetupForInstantiatedSim(); } if (GameUtils.IsFutureWorld()) { CauseEffectService.ApplyCauseAndEffectModsToSim(sim); } if (IsAlien) { World.ObjectSetVisualOverride(sim.ObjectId, eVisualOverrideTypes.Alien, null); } if (EventTracker.sInstance != null) { EventTracker.SendEvent(EventTypeId.kSimInstantiated, null, sim); } MiniSimDescription miniSimDescription = MiniSimDescription.Find(SimDescriptionId); if (miniSimDescription != null && (GameStates.IsTravelling || mHomeWorld != GameUtils.GetCurrentWorld())) { miniSimDescription.UpdateInWorldRelationships(this); } if (HealthManager != null) { HealthManager.Startup(); } if (Household.RoommateManager != null && Household.RoommateManager.IsNPCRoommate(SimDescriptionId)) { Household.RoommateManager.AddRoommateInteractions(sim); } } if (OccultManager != null && SkinToneKey.InstanceId == 15475186560318337848uL && !OccultManager.HasOccultType(OccultTypes.Vampire) && !OccultManager.HasOccultType(OccultTypes.Werewolf) && !IsGhost) { World.ObjectSetVisualOverride(CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null); } if (Household != null && Household.IsAlienHousehold) { (Sims3.UI.Responder.Instance.HudModel as HudModel).OnSimCurrentWorldChanged(true, this); } if (shouldNullHousehold && mHousehold == Household.NpcHousehold) { mHousehold = null; } sim.mSimDescription = this; this.mSim = sim; return(sim); }
public static bool Remove(SimDescription sim, OccultTypes type, bool alterOutfit) { if (sim.OccultManager == null) { return(false); } if (sim.CreatedSim != null) { try { if (sim.CreatedSim.CurrentOutfitCategory == OutfitCategories.Special) { sim.CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday); } } catch { } } OccultVampire vampire = sim.OccultManager.GetOccultType(type) as OccultVampire; if (vampire != null) { if ((vampire.mOwningSim == null) || (vampire.mOwningSim.MapTagManager == null)) { vampire.mPreyMapTag = null; } } if (sim.GetOutfitCount(OutfitCategories.Everyday) == 1) { SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0); using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(OutfitCategories.Everyday, 1), outfit)) { } } if (type == OccultTypes.Unicorn) { OccultUnicornEx.OnRemoval(sim); } bool success = false; OccultManager occultManager = sim.OccultManager; try { if (occultManager.HasOccultType(type)) { occultManager.mCurrentOccultTypes ^= type; foreach (OccultBaseClass occultClass in occultManager.mOccultList) { if (type == occultClass.ClassOccultType) { if ((occultManager.mOwnerDescription.SupernaturalData != null) && (occultManager.mOwnerDescription.SupernaturalData.OccultType == type)) { occultManager.mOwnerDescription.RemoveSupernaturalData(); } OccultGenie genie = occultClass as OccultGenie; if (genie != null) { OccultGenieEx.OnRemoval(genie, occultManager.mOwnerDescription, alterOutfit); } else { OccultPlantSim plantSim = occultClass as OccultPlantSim; if (plantSim != null) { OccultPlantSimEx.OnRemoval(plantSim, occultManager.mOwnerDescription, alterOutfit); } else { occultClass.OnRemoval(occultManager.mOwnerDescription); } } occultManager.mOccultList.Remove(occultClass); occultManager.mIsLifetimeReward = false; if (occultManager.mOccultList.Count == 0x0) { occultManager.mOccultList = null; } break; } } (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged(); occultManager.UpdateOccultUI(); EventTracker.SendEvent(EventTypeId.kLostOccult, occultManager.mOwnerDescription.CreatedSim); } //occultManager.RemoveOccultType(type); success = true; } catch (Exception e) { bool showError = true; switch (type) { case OccultTypes.Genie: case OccultTypes.ImaginaryFriend: if (sim.CreatedSim == null) { showError = false; } break; } if (showError) { Common.Exception(sim, e); } } if (!success) { for (int i = occultManager.mOccultList.Count - 1; i >= 0; i--) { if (type == occultManager.mOccultList[i].ClassOccultType) { occultManager.mOccultList.RemoveAt(i); } (Sims3.UI.Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged(); sim.OccultManager.UpdateOccultUI(); } } TraitNames trait = TraitFromOccult(type); if (trait != TraitNames.Unknown) { sim.TraitManager.RemoveElement(trait); } return(success); }