Terrarium.Game.GameEngine.StopGame C# (CSharp) Method

StopGame() public method

Stops the game and determines if the final tick of data should be serialized.
public StopGame ( Boolean serializeState ) : void
serializeState Boolean Controls if the state is serialized.
return void
        public void StopGame(Boolean serializeState)
        {
            // This needs to be the first call in stop game because if it fails, the game needs to be able
            // to continue.  In addition, it may jump the engine ahead a few phases, and if the engine isn't
            // in the normal running state this could cause things to fail since the engine phases are expecting
            // things to be in a normal state.
            if (serializeState)
            {
                this.serializeState(_currentStateFileName);
            }

            if (_usingNetwork && _networkEngine != null)
            {
                _networkEngine.ShutdownNetwork();
                _networkEngine = null;
                _usingNetwork = false;
            }

            // Shut down populationData after serializing since serializing
            // may advance to the end of the tick
            if (_populationData != null)
            {
                _populationData.Close();
                _populationData = null;
            }

            AppMgr.DestroyScheduler();
            _pac.Close();
            _ledIndicators = null;
            _engine = null;
        }