예제 #1
0
        static void RunServer()
        {
            try
            {
                TimeStat  timeAll         = new TimeStat();
                LockTimer perfUpdateTimer = new LockTimer(60 * 1000);
                perfUpdateTimer.Trigger();

                while (true)
                {
                    timeAll.Start();

                    GameTime.Update();
                    OnTick?.Invoke();

                    GameTime.Update();
                    GUCTimer.Update(GameTime.Ticks); // move to new thread?

                    //Run the dispatcher
                    GUCDispatcher.Execute();


                    GameTime.Update();
                    GameServer.Update(); //process received packets

                    GameTime.Update();
                    WorldObjects.World.ForEach(w => w.OnTick(GameTime.Ticks));

                    long elapsed = timeAll.Stop();
                    if (perfUpdateTimer.IsReady)
                    {
                        Logger.Log("Performance: {0:0}ms avg, {1:0}ms max. RAM: {2:0.0}MB", timeAll.Average, timeAll.Maximum, Process.GetCurrentProcess().PrivateMemorySize64 / 1000000d);
                        timeAll.Reset();
                    }

                    long diff = (updateRate - elapsed) / TimeSpan.TicksPerMillisecond;
                    if (diff > 0)
                    {
                        Thread.Sleep((int)diff);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e.Source + "<br>" + e.Message + "<br>" + e.StackTrace);
            }
        }
예제 #2
0
 /// <inheritdoc />
 public void RunOrEnqueue(Action action) => GUCDispatcher.RunOrEnqueue(action);
예제 #3
0
 /// <inheritdoc />
 public void EnqueueAction(Action action) => GUCDispatcher.EnqueueAction(action);
예제 #4
0
 /// <inheritdoc />
 public bool CheckAccess() => GUCDispatcher.CheckAccess();