示例#1
0
        /// <summary>
        ///     Fired when the simulation is closing and needs to clear out any data structures that it created so the program can
        ///     exit cleanly.
        /// </summary>
        public virtual void Destroy()
        {
            // Set flag that we are closing now so we can ignore ticks during shutdown.
            IsClosing = true;

            // Allows game simulation above us to cleanup any data structures it cares about.
            OnPreDestroy();

            // Remove simulation presentation variables.
            _lastTickTime      = DateTime.MinValue;
            _currentTickTime   = DateTime.MinValue;
            TotalSecondsTicked = 0;
            _spinningPixel     = null;
            TickPhase          = string.Empty;

            // Remove simulation core modules.
            Random        = null;
            WindowManager = null;
            SceneGraph    = null;
            InputManager  = null;
        }
示例#2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:TrailGame.SimulationApp" /> class.
        /// </summary>
        protected SimulationApp()
        {
            // We are not closing...
            IsClosing = false;

            // Date and time the simulation was started, which we use as benchmark for all future time passed.
            _lastTickTime    = DateTime.UtcNow;
            _currentTickTime = DateTime.UtcNow;

            // Visual tick representations for other sub-systems.
            TotalSecondsTicked = 0;

            // Setup spinning pixel to show game is not thread locked.
            _spinningPixel = new SpinningPixel();
            TickPhase      = _spinningPixel.Step();

            // Create modules needed for managing simulation.
            Random        = new Randomizer();
            WindowManager = new WindowManager(this);
            SceneGraph    = new SceneGraph(this);

            // Input manager needs event hook for knowing when buffer is sent.
            InputManager = new InputManager(this);
        }