Ejemplo n.º 1
0
        public static bool AddComponent <C>(GameObject ths, params object[] args)
            where C : ObjectComponent
        {
            Type cType         = typeof(C);
            bool staticAllowed = true;// Simulator.GetProxy(ths.ObjectId) == null;

            if (!ths.AddComponentInternal(cType, staticAllowed, args))
            {
                return(false);
            }

            if (ths.mObjComponents != null)
            {
                Type type = typeof(C);
                for (int i = 0x0; i < ths.mObjComponents.Count; i++)
                {
                    ObjectComponent component = ths.mObjComponents[i];
                    if (component is C)
                    {
                        component.OnStartup();
                        break;
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public ScriptExecuteType _InitInit(bool postLoad)
        {
            if (mbInited)
            {
                return(GetScriptExecuteType());
            }

            mbInited = true;

            mProduct = UserToolUtils.GetProduct(UserToolUtils.BuildBuyProductType.Object, GetResourceKey());
            if (mProduct != null)
            {
                mbProductInited = true;
            }

            if (mActorsUsingMe != null)
            {
                while (mActorsUsingMe.Remove(null))
                {
                }
            }

            if (postLoad)
            {
                if (mRoutingReferenceList != null)
                {
                    int i = 0;
                    while (i < mRoutingReferenceList.Count)
                    {
                        if (mRoutingReferenceList[i] == null || !Sims3.SimIFace.Objects.IsValid(mRoutingReferenceList[i].ObjectId))
                        {
                            mRoutingReferenceList.RemoveAt(i);
                        }
                        else
                        {
                            i++;
                        }
                    }
                }

                try
                {
                    OnLoad();
                }
                catch (Exception)
                {
                    if (!isAwcore)
                    {
                        if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || SCOSR.IsScriptCore2020())
                        {
                            throw;
                        }
                    }
                }
            }
            else
            {
                try
                {
                    OnCreation();
                }
                catch (Exception)
                {
                    if (!isAwcore)
                    {
                        if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || SCOSR.IsScriptCore2020())
                        {
                            throw;
                        }
                    }
                }
            }

            try
            {
                if (AddToLot())
                {
                    LotManager.PlaceObjectOnLot(this, base.Proxy.ObjectId);
                }
            }
            catch (Exception)
            {
                if (!isAwcore)
                {
                    if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || SCOSR.IsScriptCore2020())
                    {
                        throw;
                    }
                }
            }

            try
            {
                OnStartup();
            }
            catch (Exception)
            {
                if (!NiecHelperSituation.__acorewIsnstalled__)
                {
                    if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || SCOSR.IsScriptCore2020())
                    {
                        throw;
                    }
                }
            }

            if (mObjComponents != null)
            {
                try
                {
                    int j = 0;
                    while (j < mObjComponents.Count)
                    {
                        ObjectComponent objectComponent = mObjComponents[j];
                        if (objectComponent != null)
                        {
                            if (postLoad)
                            {
                                objectComponent.OnLoad();
                            }
                            objectComponent.OnStartup();
                            j++;
                        }
                        else
                        {
                            mObjComponents.RemoveAt(j);
                        }
                    }
                    if (mObjComponents.Count == 0)
                    {
                        mObjComponents = null;
                    }
                }
                catch (Exception)
                {
                    if (!NiecHelperSituation.__acorewIsnstalled__)
                    {
                        if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || SCOSR.IsScriptCore2020())
                        {
                            throw;
                        }
                    }
                }
            }

            try
            {
                if (!postLoad && LotManager.sIsBuildBuyModeOn)
                {
                    SetOwnerLot(LotManager.ActiveLot);
                }
                UpdateOwnerLot(LotCurrent);
            }
            catch (Exception)
            {
                mLotCurrent = LotManager.sWorldLot;
                if (!isAwcore)
                {
                    if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || SCOSR.IsScriptCore2020())
                    {
                        throw;
                    }
                }
            }
            if (isAwcore)
            {
                Sim obj_Sim = ((object)this) as Sim;
                if (obj_Sim != null)
                {
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mAutonomy);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mBuffManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mMoodManager);
                    if (obj_Sim.mInteractionQueue != null)
                    {
                        NFinalizeDeath.AddItemToList(gcList, obj_Sim.mInteractionQueue);
                        NFinalizeDeath.AddItemToList(gcList, obj_Sim.mInteractionQueue.mInteractionList);
                    }
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mLookAtManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mIdleManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mThoughtBalloonManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mSocialComponent);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mSnubManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mMapTagManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mDreamsAndPromisesManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mDreamsAndPromisesManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mDeepSnowEffectManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mFlags);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.SleepDreamManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mCelebrity);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mActorsUsingMe);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mClothingReactionBroadcaster);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mOpportunityManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mPosture);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mActiveSwitchOutfitHelper);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mMapTagManager);
                    NFinalizeDeath.AddItemToList(gcList, obj_Sim.mSimCommodityInteractionMap);
                }
            }
            return(GetScriptExecuteType());
        }