예제 #1
0
        private void Run()
        {
            BeforeRun?.Invoke(this, new EventArgs());
            int lastTick    = Environment.TickCount;
            int firstTick   = lastTick;
            int currentTick = 0;

            working = true;

            while (working)
            {
                currentTick = Environment.TickCount;
                cntrLogic.Tick();
                TickEventArgs args = new TickEventArgs(new Time(TimeSpan.FromMilliseconds(Environment.TickCount - firstTick), TimeSpan.FromMilliseconds(currentTick - lastTick)), cntrLogic);
                LogicTick?.Invoke(this, args);
                DrawTick?.Invoke(this, args);

                if (args.Stop)
                {
                    break;
                }

                lastTick = Environment.TickCount;

                if (this.LimitFrames)
                {
                    long passed = lastTick - currentTick + 1;
                    if (passed <= timePerTick)
                    {
                        Thread.Sleep((int)(timePerTick - passed));
                    }
                }
            }
            AfterRun?.Invoke(this, new EventArgs());
        }
예제 #2
0
 public static void InvokeDrawTick(object sender, EventArgs eventArgs)
 {
     try
     {
         DrawTick.Invoke(null, EventArgs.Empty);
     }
     catch (Exception ex)
     {
         Log.AsyncR("An exception occured in a Mod's DrawTick: " + ex);
     }
 }
예제 #3
0
 public static void InvokeDrawTick()
 {
     try
     {
         DrawTick.Invoke();
     }
     catch (Exception ex)
     {
         Program.LogError("An exception occured in XNA DrawTick: " + ex.ToString());
     }
 }
예제 #4
0
        public static void InvokeDrawTick(object sender, EventArgs e)
        {
#pragma warning disable 618
            DrawTick.Invoke(null, EventArgs.Empty);
#pragma warning restore 618
        }