Esempio n. 1
0
        public static bool SaveGame()
        {
            if (Traveler.Settings.mPromptToSave)
            {
                Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.SimIFace.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.User);

                OptionsModel optionsModel = Sims3.Gameplay.UI.Responder.Instance.OptionsModel as OptionsModel;

                bool playerMadeTravelRequest = TravelUtil.PlayerMadeTravelRequest;
                TravelUtil.PlayerMadeTravelRequest = false;
                try
                {
                    if ((optionsModel != null) && (!optionsModel.SaveGame(false, true, true)))
                    {
                        return(false);
                    }

                    while (optionsModel.mSaveInProgress)
                    {
                        SpeedTrap.Sleep();
                    }
                }
                finally
                {
                    TravelUtil.PlayerMadeTravelRequest = playerMadeTravelRequest;
                }
            }

            return(true);
        }
Esempio n. 2
0
        protected static void OnInitialize()
        {
            if (SkewerEx.Instance != null)
            {
                return;
            }

            try
            {
                while ((Skewer.Instance == null) || (Skewer.Instance.mDoubleClickTimer == null))
                {
                    SpeedTrap.Sleep();
                }

                while (!GameStates.IsLiveState)
                {
                    SpeedTrap.Sleep();
                }

                SkewerEx.Load();

                while (Skewer.Instance != null)
                {
                    if (Skewer.Instance.mHouseholdItems.Length == 0)
                    {
                        break;
                    }

                    if (Skewer.Instance.mHouseholdItems[0].mContainer == null)
                    {
                        break;
                    }

                    if (Skewer.Instance.mHouseholdItems[0].mContainer.Visible)
                    {
                        SkewerEx.HideSkewer(ref Skewer.Instance.mHouseholdItems);
                    }

                    SpeedTrap.Sleep();
                }
            }
            catch (Exception exception)
            {
                Common.Exception("Simulate", exception);
            }
        }
Esempio n. 3
0
            public override void Simulate()
            {
                try
                {
                    NRaas.SpeedTrap.Begin();

                    mTimer = StopWatch.Create(StopWatch.TickStyles.Minutes);
                    mTimer.Start();

                    while (true)
                    {
                        while ((mTimer != null) && (mTimer.GetElapsedTime() < mSaveInterval))
                        {
                            if (mExit)
                            {
                                break;
                            }
                            SpeedTrap.Sleep();
                        }

                        if (mTimer == null)
                        {
                            break;
                        }

                        Corrections.CorrectSaveGameLocks();

                        do
                        {
                            if (mExit)
                            {
                                break;
                            }
                            SpeedTrap.Sleep();
                        }while (!IsValidState());

                        if (mExit)
                        {
                            break;
                        }

                        Saver.Save();

                        mTimer.Restart();
                    }

                    Destroy();
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    Common.Exception("Simulate", exception);
                }
                finally
                {
                    NRaas.SpeedTrap.End();
                }
            }
Esempio n. 4
0
        protected static void Save()
        {
            if (sSaveWasRequested)
            {
                return;
            }

            try
            {
                /*
                 * if (!AcceptCancelDialog.Show(Common.LocalizeEAString("Ui/Caption/PromptedSave:PromptEditTown")))
                 * {
                 *  sSaveWasRequested = false;
                 *  sSaveWasPerformed = false;
                 *  return;
                 * }
                 */
                PuckController controller = null;

                Puck puck = Puck.Instance;
                if (puck != null)
                {
                    controller = puck.mPuckController;
                }

                if (GameStates.GetInWorldSubState() is LiveModeState)
                {
                    if (Settings.mSwitchToMapView)
                    {
                        if (!CameraController.IsMapViewModeEnabled())
                        {
                            Sims3.Gameplay.Core.Camera.ToggleMapView();
                            SpeedTrap.Sleep();
                        }
                    }

                    if (Saver.Settings.mPauseOnSave)
                    {
                        GameflowEx.Pause();
                    }
                }

                /*else
                 * {
                 *  if (controller != null)
                 *  {
                 *      controller.ChangeToMode(PuckController.Mode.Live);
                 *  }
                 *
                 *  GameflowEx.Pause();
                 *
                 *  while ((GameStates.GetInWorldSubState() is BuyModeState) || (GameStates.GetInWorldSubState() is BuildModeState))
                 *  {
                 *      SpeedTrap.Sleep();
                 *  }
                 * }*/

                Common.FunctionTask.Perform(OnSave);
            }
            catch (Exception exception)
            {
                Common.Exception("Save", exception);
            }
        }
Esempio n. 5
0
            protected override bool OnPerform()
            {
                while ((SimClock.CurrentTicks - mPreviousTime) < (sOneMinute - 1))
                {
                    if (mExit)
                    {
                        break;
                    }
                    SpeedTrap.Sleep();
                }

                int overrideSpeed = 0;

                Sims3.Gameplay.Gameflow.ClockSpeedModel model = Sims3.UI.Responder.Instance.ClockSpeedModel as Sims3.Gameplay.Gameflow.ClockSpeedModel;
                if (model != null)
                {
                    if (Settings.mPausingOnCompletion)
                    {
                        if (Sim.ActiveActor != null)
                        {
                            if (Sim.ActiveActor.CurrentInteraction == null)
                            {
                                Settings.mPausingOnCompletion = false;
                                GameflowEx.Pause();
                            }
                        }
                    }

                    if (Settings.mSkipOnHumanSleep)
                    {
                        bool allSleeping = true;

                        if ((Sim.ActiveActor == null) || (!Sim.ActiveActor.IsHuman))
                        {
                            allSleeping = false;
                        }
                        else
                        {
                            foreach (Sim sim in Households.AllHumans(Household.ActiveHousehold))
                            {
                                if (!(sim.CurrentInteraction is ISleeping))
                                {
                                    allSleeping = false;
                                }
                            }
                        }

                        if (allSleeping)
                        {
                            if (model.CurrentGameSpeed != Sims3.SimIFace.Gameflow.GameSpeed.Triple)
                            {
                                Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.SimIFace.Gameflow.GameSpeed.Triple, Sims3.Gameplay.Gameflow.SetGameSpeedContext.Automation);
                            }

                            Settings.mSkippingSleep = true;
                        }
                        else if (Settings.mSkippingSleep)
                        {
                            switch (model.CurrentGameSpeed)
                            {
                            case Sims3.SimIFace.Gameflow.GameSpeed.Triple:
                            case Sims3.SimIFace.Gameflow.GameSpeed.Skip:
                                Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.SimIFace.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.Automation);
                                break;
                            }
                        }
                    }

                    Sims3.SimIFace.Gameflow.GameSpeed speed = model.CurrentGameSpeed;

                    switch (speed)
                    {
                    case Sims3.SimIFace.Gameflow.GameSpeed.Pause:
                        Settings.mPausingOnCompletion = false;
                        Settings.mSkippingSleep       = false;
                        break;

                    case Sims3.SimIFace.Gameflow.GameSpeed.Normal:
                        Settings.mSkippingSleep = false;
                        break;

                    case Sims3.SimIFace.Gameflow.GameSpeed.Double:
                        if (Settings.mSwitchSpeedOnFast > 0)
                        {
                            overrideSpeed = Settings.mSwitchSpeedOnFast;
                        }
                        Settings.mSkippingSleep       = false;
                        Settings.mPausingOnCompletion = false;
                        break;

                    case Sims3.SimIFace.Gameflow.GameSpeed.Triple:
                        if (Settings.mSwitchSpeedOnFast > 0)
                        {
                            overrideSpeed = Settings.mSwitchSpeedOnFast;
                        }

                        Settings.mPausingOnCompletion = false;
                        break;

                    case Sims3.SimIFace.Gameflow.GameSpeed.Skip:
                        if (Settings.mSwitchSpeedOnFast > 0)
                        {
                            overrideSpeed = Settings.mSwitchSpeedOnFast;
                        }

                        Settings.mPausingOnCompletion = false;
                        if (Settings.mPauseOnCompletion)
                        {
                            if (Sim.ActiveActor != null)
                            {
                                if (Sim.ActiveActor.CurrentInteraction != null)
                                {
                                    Settings.mPausingOnCompletion = true;
                                }
                            }
                        }
                        break;
                    }
                }

                using (TestSpan span = new TestSpan(Relativity.Logger.sLogger, "Simulate"))
                {
                    if (mExit)
                    {
                        return(false);
                    }

                    int speed = Settings.GetSpeed(SimClock.CurrentTime(), overrideSpeed);

                    PersistedSettings.sRelativeFactor = 0;
                    if (speed != 0)
                    {
                        PersistedSettings.sRelativeFactor = sOneMinute / (float)speed;
                    }

                    if (speed != mPriorValues.mPreviousSpeed)
                    {
                        PriorValues.sFactorChanged = true;
                    }

                    if (PriorValues.sFactorChanged)
                    {
                        PriorValues.sFactorChanged = false;

                        mPriorValues.RevertCommodityGains();

                        TuningAlterations.Revert();

                        TuningAlterations.Apply();
                    }

                    mPriorValues.ApplyCommodityGains();

                    mPriorValues.mPreviousSpeed = speed;

                    if (speed < 0)
                    {
                        speed = 0;
                    }

                    SimClock.TicksAdvanced += (speed - sOneMinute);

                    mPreviousTime = SimClock.CurrentTicks;
                }

                return(true);
            }