Beispiel #1
0
        public void Run()
        {
            var initiable = Registery.GetEnumerator();

            while (initiable.MoveNext())
            {
                var system = initiable.Current;
                if (system is EntitySystem s)
                {
                    s.Registery = EntityRegistery;
                    s.Input     = Input;
                }
            }

            _isRunning        = true;
            _previousGameTime = DateTime.Now;

            while (_isRunning)
            {
                var time     = DateTime.Now;
                var gameTime = time - _previousGameTime;
                _previousGameTime = time;

                EventManager.ProcessEvents();

                var systemsEnumerator = Registery.GetEnumerator();

                while (systemsEnumerator.MoveNext())
                {
                    var system = systemsEnumerator.Current;
                    system.Update(gameTime.TotalSeconds);
                }

                var cleanupEnumerator = Registery.GetEnumerator();

                while (cleanupEnumerator.MoveNext())
                {
                    var system = cleanupEnumerator.Current;
                    if (system is IDisposable s)
                    {
                        s.Dispose();
                    }
                }

                UIContext.Draw();
                Window.Update();
            }
        }