예제 #1
0
        public override void Shutdown()
        {
            base.Shutdown();

            mFirst = true;

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

            foreach (Manager manager in mManagers)
            {
                try
                {
                    manager.Shutdown();
                }
                catch (Exception e)
                {
                    Common.DebugException(manager.UnlocalizedName, e);
                }
            }

            mRunning = false;

            mManagers      = null;
            mManagerLookup = null;

            mScenarioManager  = null;
            mSimManager       = null;
            mHouseholdManager = null;
            mLotManager       = null;

            sOptions = null;
        }
예제 #2
0
        public override void Startup(PersistentOptionBase vOptions)
        {
            try
            {
                mManagers = new List <Manager>();

                Castes = new ManagerCaste(this);

                Lots = new ManagerLot(this);

                Households = new ManagerHousehold(this);

                Sims = new ManagerSim(this);

                Money = new ManagerMoney(this);

                Deaths = new ManagerDeath(this);

                Skills = new ManagerSkill(this);

                Careers = new ManagerCareer(this);

                Pregnancies = new ManagerPregnancy(this);

                Romances = new ManagerRomance(this);

                Flirts = new ManagerFlirt(this);

                Friends = new ManagerFriendship(this);

                Situations = new ManagerSituation(this);

                Personalities = new ManagerPersonality(this);

                Scenarios = new ManagerScenario(this);

                Scoring = new ManagerScoring(this);

                Stories = new ManagerStory(this);

                mManagerLookup = new Dictionary <Type, Manager>();
                mManagerLookup.Add(GetType(), this);

                mManagerByName = new Dictionary <string, Manager>();
                mManagerByName.Add(GetTitlePrefix(PrefixType.Pure), this);

                foreach (Manager manager in mManagers)
                {
                    mManagerLookup.Add(manager.GetType(), manager);
                    mManagerByName.Add(manager.GetTitlePrefix(PrefixType.Pure), manager);
                }

                InstallOptions(sInitialInstall);

                foreach (Manager manager in mManagers)
                {
                    manager.InstallOptions(sInitialInstall);
                }

                if (Common.IsAwayFromHomeworld())
                {
                    // Stop persistence for the moment
                    OptionStore optionStore = sOptions;
                    sOptions = null;

                    List <IAdjustForVacationOption> options = new List <IAdjustForVacationOption>();
                    GetOptions(options, false, null);

                    foreach (IAdjustForVacationOption option in options)
                    {
                        option.AdjustForVacationTown();
                    }

                    sOptions = optionStore;
                }

                Options.Restore();

                Common.kDebugging = GetValue <DebuggingOption, bool>();

                base.Startup(Options);

                RemoveStats();

                foreach (Manager manager in mManagers)
                {
                    try
                    {
                        manager.Startup(Options);
                    }
                    catch (Exception exception)
                    {
                        BooterLogger.AddError(exception.ToString());
                    }
                }

                if (DebuggingEnabled)
                {
                    TestOptionNameUniqueness();
                }

                sInitialInstall = false;

                mFirst = true;
                mTask  = new Common.AlarmTask(1f, TimeUnit.Seconds, OnTimer, 10f, TimeUnit.Minutes);
            }
            catch (Exception exception)
            {
                Common.Exception("Startup", exception);
            }
        }