Beispiel #1
0
        public void Dispose()
        {
            try{
                mSim.AssignedRole      = mRole;
                mSim.IsNeverSelectable = mNeverSelectable;
                if (mSim.CelebrityManager != null)
                {
                    mSim.CelebrityManager.ScheduleOpportunityCallIfNecessary();
                }
                if (mOpportunities != null)
                {
                    mOpportunities.Dispose();
                }
                if ((mSchool != null) &&
                    (mSim.CareerManager != null))
                {
                    mSim.CareerManager.mSchool = mSchool;
                }
                if ((mCareer != null) &&
                    (mSim.CareerManager != null) &&
                    (mSim.Occupation == null))
                {
                    mSim.CareerManager.mJob = mCareer;
                    if (mSim.Occupation != null)
                    {
                        using (BaseWorldReversion reversion = new BaseWorldReversion()){
                            if ((mFlags & Flag.LoadFixup) == Flag.LoadFixup)
                            {
                                mSim.Occupation.OnLoadFixup(false);
                            }
                            if (((mFlags & Flag.Selectable) == Flag.Selectable) &&
                                (!mSim.IsNeverSelectable &&
                                 mSim.Household == Household.ActiveHousehold))
                            {
                                using (SuppressCreateHousehold suppress = new SuppressCreateHousehold()){
                                    bool careerLoc = true;
                                    if (mSim.Occupation is Career)
                                    {
                                        careerLoc = (mSim.Occupation.CareerLoc != null);
                                    }
                                    if (careerLoc)
                                    {
                                        FixCareer(mSim.Occupation, false);
                                        mSim.Occupation.OnOwnerBecameSelectable();
                                    }
                                }
                            }
                            else
                            if ((mFlags & Flag.Unselectable) == Flag.Unselectable)
                            {
                                using (SuppressCreateHousehold suppress = new SuppressCreateHousehold()){
                                    //  [NRaas:]Fix for script error in GhostHunter:ApplyCareerSpecificModifiersToXp where
                                    // owner Sim is not null checked and breaks when this is ran during age up.
                                    ActiveCareerLevelStaticData
                                                data       = null;
                                    int         experience = 0;
                                    GhostHunter hunter     = null;
                                    try{
                                        hunter = mSim.Occupation as GhostHunter;
                                        if (hunter != null)
                                        {
                                            data = hunter.GetCurrentLevelStaticDataForActiveCareer();
                                            if (data != null)
                                            {
                                                experience = data.DailyPerfectJobBonusExperience;
                                                data.DailyPerfectJobBonusExperience = 0;
                                            }
                                        }
                                        mSim.Occupation.OnOwnerBecameUnselectable();
                                    }catch (Exception exception) {
                                        //  Get stack trace for the exception. with source file information
                                        var st = new StackTrace(exception, true);
                                        //  Get the top stack frame
                                        var frame = st.GetFrame(0);
                                        //  Get the line number from the stack frame
                                        var line = frame.GetFileLineNumber();
                                        Alive.WriteLog(exception.Message + "\n\n" +
                                                       exception.StackTrace + "\n\n" +
                                                       exception.Source + "\n\n" +
                                                       line);
                                    }finally{
                                        if (hunter != null &&
                                            data != null)
                                        {
                                            data.DailyPerfectJobBonusExperience = experience;
                                        }
                                    }
                                }
                            }
                        }

                        mSim.CareerManager.UpdateCareerUI();
                    }
                }
            }catch (Exception exception) {
                //  Get stack trace for the exception. with source file information
                var st = new StackTrace(exception, true);
                //  Get the top stack frame
                var frame = st.GetFrame(0);
                //  Get the line number from the stack frame
                var line = frame.GetFileLineNumber();
                Alive.WriteLog(exception.Message + "\n\n" +
                               exception.StackTrace + "\n\n" +
                               exception.Source + "\n\n" +
                               line);
            }finally{
            }
        }
Beispiel #2
0
        public void Dispose()
        {
            try
            {
                mSim.AssignedRole = mRole;

                mSim.IsNeverSelectable = mNeverSelectable;

                if (mSim.CelebrityManager != null)
                {
                    mSim.CelebrityManager.ScheduleOpportunityCallIfNecessary();
                }

                if (mOpportunities != null)
                {
                    mOpportunities.Dispose();
                }

                if ((mSchool != null) && (mSim.CareerManager != null))
                {
                    mSim.CareerManager.mSchool = mSchool;
                }

                if ((mCareer != null) && (mSim.CareerManager != null) && (mSim.Occupation == null))
                {
                    mSim.CareerManager.mJob = mCareer;

                    if (mSim.Occupation != null)
                    {
                        using (BaseWorldReversion reversion = new BaseWorldReversion())
                        {
                            if ((mFlags & Flag.LoadFixup) == Flag.LoadFixup)
                            {
                                mSim.Occupation.OnLoadFixup(false);
                            }

                            if (((mFlags & Flag.Selectable) == Flag.Selectable) && (SimTypes.IsSelectable(mSim)))
                            {
                                using (StoryProgressionServiceEx.SuppressCreateHousehold suppress = new StoryProgressionServiceEx.SuppressCreateHousehold())
                                {
                                    bool careerLoc = true;
                                    if (mSim.Occupation is Career)
                                    {
                                        careerLoc = (mSim.Occupation.CareerLoc != null);
                                    }

                                    if (careerLoc)
                                    {
                                        Corrections.FixCareer(mSim.Occupation, false, null);

                                        mSim.Occupation.OnOwnerBecameSelectable();
                                    }
                                }
                            }
                            else if ((mFlags & Flag.Unselectable) == Flag.Unselectable)
                            {
                                using (StoryProgressionServiceEx.SuppressCreateHousehold suppress = new StoryProgressionServiceEx.SuppressCreateHousehold())
                                {
                                    // fix for script error in GhostHunter:ApplyCareerSpecificModifiersToXp where
                                    // ownersim is not null checked and breaks when this is ran during age up.
                                    ActiveCareerLevelStaticData data = null;
                                    int         experience           = 0;
                                    GhostHunter hunter = null;
                                    try
                                    {
                                        hunter = mSim.Occupation as GhostHunter;
                                        if (hunter != null)
                                        {
                                            data = hunter.GetCurrentLevelStaticDataForActiveCareer();
                                            if (data != null)
                                            {
                                                experience = data.DailyPerfectJobBonusExperience;
                                                data.DailyPerfectJobBonusExperience = 0;
                                            }
                                        }

                                        mSim.Occupation.OnOwnerBecameUnselectable();
                                    }
                                    catch (Exception e)
                                    {
                                        Common.Exception(mSim, e);
                                    }
                                    finally
                                    {
                                        if (hunter != null && data != null)
                                        {
                                            data.DailyPerfectJobBonusExperience = experience;
                                        }
                                    }
                                }
                            }
                        }

                        mSim.CareerManager.UpdateCareerUI();
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(mSim, e);
            }
        }