Exemplo n.º 1
0
 public bool Pause()
 {
     if (running && !paused)
     {
         FrameRate.Stop();
         paused = true;
         OnPauseEvent(this, new Events.PauseEventArgs {
         });
         return(true);
     }
     else if (running && paused)
     {
         OnErrorEvent(this, new Events.ErrorEventArgs {
             errorLevel = Events.ErrorEventArgs.ErrorLevel.Warning,
             message    = "Tried to pause engine while engine was already paused"
         });
         return(false);
     }
     else if (!running)
     {
         OnErrorEvent(this, new Events.ErrorEventArgs {
             errorLevel = Events.ErrorEventArgs.ErrorLevel.Warning,
             message    = "Tried to pause engine while engine was not running"
         });
         return(false);
     }
     else
     {
         OnErrorEvent(this, new Events.ErrorEventArgs {
             errorLevel = Events.ErrorEventArgs.ErrorLevel.SystemFailure,
             message    = "Should never reach this code, only required by vs compiler"
         });
         throw new SystemException("Code branch only required by compiler, no logical way to hit this");
     }
 }
Exemplo n.º 2
0
        public void RunLoop()
        {
            if (frameRate == null)
            {
                frameRate = new FrameRate();
            }

            frameRate.Start();
            while (NextWindowFrame())
            {
                frameRate.StartFrame();
                if (PreProcess != null)
                {
                    PreProcess(this, new EventArgs());
                }

                if (ProcessFrame != null)
                {
                    ProcessFrame(this, new EventArgs());
                }

                if (PostProcess != null)
                {
                    PostProcess(this, new EventArgs());
                }
                frameRate.EndFrame();
            }
            frameRate.Stop();
        }
Exemplo n.º 3
0
 public bool Stop()
 {
     if (running)
     {
         FrameRate.Stop();
         running = false;
         paused  = false;
         OnStopEvent(this, new Events.StopEventArgs {
         });
         return(true);
     }
     else
     {
         OnErrorEvent(this, new Events.ErrorEventArgs {
             errorLevel = Events.ErrorEventArgs.ErrorLevel.Warning,
             message    = "Tried to stop engine while engine was not running"
         });
         return(false);
     }
 }