// From SimDescription.Instantiate private static Sim Perform(SimDescription ths, Vector3 position, ResourceKey outfitKey, bool forceAlwaysAnimate, OnReset reset) { Household.HouseholdSimsChangedCallback changedCallback = null; Household changedHousehold = null; bool isChangingWorlds = GameStates.sIsChangingWorlds; bool isLifeEventManagerEnabled = LifeEventManager.sIsLifeEventManagerEnabled; Corrections.RemoveFreeStuffAlarm(ths); using (SafeStore store = new SafeStore(ths, SafeStore.Flag.LoadFixup | SafeStore.Flag.Selectable | SafeStore.Flag.Unselectable)) { try { // Stops the memories system from interfering LifeEventManager.sIsLifeEventManagerEnabled = false; // Stops UpdateInformationKnownAboutRelationships() GameStates.sIsChangingWorlds = true; if (ths.Household != null) { changedCallback = ths.Household.HouseholdSimsChanged; changedHousehold = ths.Household; ths.Household.HouseholdSimsChanged = null; } if (ths.CreatedSim != null) { AttemptToPutInSafeLocation(ths.CreatedSim, false); if (reset != null) { ths.CreatedSim.SetObjectToReset(); reset(ths.CreatedSim, false); } return(ths.CreatedSim); } if (ths.AgingState != null) { bool flag = outfitKey == ths.mDefaultOutfitKey; ths.AgingState.SimBuilderTaskDeferred = false; ths.AgingState.PreInstantiateSim(ref outfitKey); if (flag) { ths.mDefaultOutfitKey = outfitKey; } } int capacity = forceAlwaysAnimate ? 0x4 : 0x2; Hashtable overrides = new Hashtable(capacity); overrides["simOutfitKey"] = outfitKey; overrides["rigKey"] = CASUtils.GetRigKeyForAgeGenderSpecies((ths.Age | ths.Gender) | ths.Species); if (forceAlwaysAnimate) { overrides["enableSimPoseProcessing"] = 0x1; overrides["animationRunsInRealtime"] = 0x1; } string instanceName = "GameSim"; ProductVersion version = ProductVersion.BaseGame; if (ths.Species != CASAgeGenderFlags.Human) { instanceName = "Game" + ths.Species; version = ProductVersion.EP5; } SimInitParameters initData = new SimInitParameters(ths); Sim target = GlobalFunctions.CreateObjectWithOverrides(instanceName, version, position, 0x0, Vector3.UnitZ, overrides, initData) as Sim; if (target != null) { if (target.SimRoutingComponent == null) { // Performed to ensure that a useful error message is produced when the Sim construction fails target.OnCreation(); target.OnStartup(); } target.SimRoutingComponent.EnableDynamicFootprint(); target.SimRoutingComponent.ForceUpdateDynamicFootprint(); ths.PushAgingEnabledToAgingManager(); /* This code is idiotic * if ((ths.Teen) && (target.SkillManager != null)) * { * Skill skill = target.SkillManager.AddElement(SkillNames.Homework); * while (skill.SkillLevel < SimDescription.kTeenHomeworkSkillStartLevel) * { * skill.ForceGainPointsForLevelUp(); * } * } */ // Custom OccultTypeHelper.SetupForInstantiatedSim(ths.OccultManager); if (ths.IsAlien) { World.ObjectSetVisualOverride(target.ObjectId, eVisualOverrideTypes.Alien, null); } AttemptToPutInSafeLocation(target, false); EventTracker.SendEvent(EventTypeId.kSimInstantiated, null, target); /* * MiniSimDescription description = MiniSimDescription.Find(ths.SimDescriptionId); * if ((description == null) || (!GameStates.IsTravelling && (ths.mHomeWorld == GameUtils.GetCurrentWorld()))) * { * return target; * } * description.UpdateInWorldRelationships(ths); */ if (ths.HealthManager != null) { ths.HealthManager.Startup(); } if (((ths.SkinToneKey.InstanceId == 15475186560318337848L) && !ths.OccultManager.HasOccultType(OccultTypes.Vampire)) && (!ths.OccultManager.HasOccultType(OccultTypes.Werewolf) && !ths.IsGhost)) { World.ObjectSetVisualOverride(ths.CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null); } if (ths.Household.IsAlienHousehold) { (Sims3.UI.Responder.Instance.HudModel as HudModel).OnSimCurrentWorldChanged(true, ths); } if (Household.RoommateManager.IsNPCRoommate(ths.SimDescriptionId)) { Household.RoommateManager.AddRoommateInteractions(target); } } return(target); } finally { LifeEventManager.sIsLifeEventManagerEnabled = isLifeEventManagerEnabled; GameStates.sIsChangingWorlds = isChangingWorlds; if ((changedHousehold != null) && (changedCallback != null)) { changedHousehold.HouseholdSimsChanged = changedCallback; if (changedHousehold.HouseholdSimsChanged != null) { changedHousehold.HouseholdSimsChanged(Sims3.Gameplay.CAS.HouseholdEvent.kSimAdded, ths.CreatedSim, 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); }