Пример #1
0
 public bool Resume()
 {
     if (running && paused)
     {
         paused = false;
         FrameRate.Start();
         OnResumeEvent(this, new Events.ResumeEventArgs {
         });
         return(true);
     }
     else if (running && !paused)
     {
         OnErrorEvent(this, new Events.ErrorEventArgs {
             errorLevel = Events.ErrorEventArgs.ErrorLevel.Warning,
             message    = "Tried to resume engine while engine was not paused"
         });
         return(false);
     }
     else if (!running)
     {
         OnErrorEvent(this, new Events.ErrorEventArgs {
             errorLevel = Events.ErrorEventArgs.ErrorLevel.Warning,
             message    = "Tried to resume 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");
     }
 }
Пример #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();
        }
Пример #3
0
 public bool Start()
 {
     if (!running)
     {
         running = true;
         paused  = false;
         FrameRate.Start();
         OnStartEvent(this, new Events.StartEventArgs {
         });
         return(true);
     }
     else
     {
         OnErrorEvent(this, new Events.ErrorEventArgs {
             errorLevel = Events.ErrorEventArgs.ErrorLevel.Warning,
             message    = "Tried to start engine while engine was already running"
         });
         return(false);
     }
 }