Beispiel #1
0
        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);
        }