Example #1
0
 protected override void Removed(SystemRegistry registry)
 {
     if (Parent != null)
     {
         bool result = Parent._children.Remove(this);
         Debug.Assert(result);
     }
 }
Example #2
0
        internal void InternalRemoved(SystemRegistry registry)
        {
            if (_enabledInHierarchy)
            {
                OnDisabled();
            }

            Removed(registry);
        }
Example #3
0
 public Game()
 {
     _timeSystem = new TimeControlSystem();
     SystemRegistry.Register(_timeSystem);
     SystemRegistry.Register(new GameObjectQuerySystem(_gameObjects));
     GameObject.InternalConstructed      += OnGameObjectConstructed;
     GameObject.InternalDestroyRequested += OnGameObjectDestroyRequested;
     GameObject.InternalDestroyCommitted += OnGameObjectDestroyCommitted;
 }
Example #4
0
        public void NewSceneLoaded()
        {
            var systemEnumerator = SystemRegistry.GetSystemsEnumerator();

            while (systemEnumerator.MoveNext())
            {
                var kvp = systemEnumerator.Current;
                kvp.Value.OnNewSceneLoaded();
            }

            ResetDeltaTime();
        }
Example #5
0
        private void RunMainLoopCore()
        {
            _running = true;

            _sw = Stopwatch.StartNew();
            while (_running)
            {
                double desiredFrameTime  = 1000.0 / DesiredFramerate;
                long   currentFrameTicks = _sw.ElapsedTicks;
                double deltaMilliseconds = (currentFrameTicks - _previousFrameTicks) * (1000.0 / Stopwatch.Frequency);

                while (LimitFrameRate && deltaMilliseconds < desiredFrameTime)
                {
                    Thread.Sleep(0);
                    currentFrameTicks = _sw.ElapsedTicks;
                    deltaMilliseconds = (currentFrameTicks - _previousFrameTicks) * (1000.0 / Stopwatch.Frequency);
                }

                _previousFrameTicks = currentFrameTicks;

                FlushDeletedObjects();

                var systemEnumerator = SystemRegistry.GetSystemsEnumerator();
                while (systemEnumerator.MoveNext())
                {
                    var        kvp          = systemEnumerator.Current;
                    GameSystem system       = kvp.Value;
                    float      deltaSeconds = (float)deltaMilliseconds / 1000.0f;
                    system.Update(deltaSeconds * _timeSystem.TimeScale);
                }

                RunEndOfFrameActions();
            }

            var cleanupEnumerator = SystemRegistry.GetSystemsEnumerator();

            while (cleanupEnumerator.MoveNext())
            {
                var        kvp    = cleanupEnumerator.Current;
                GameSystem system = kvp.Value;
                if (system is IDisposable)
                {
                    ((IDisposable)system).Dispose();
                }
            }
        }
Example #6
0
 protected override void Attached(SystemRegistry registry)
 {
 }
Example #7
0
 internal void SetRegistry(SystemRegistry systemRegistry)
 {
     _registry = systemRegistry;
 }
Example #8
0
 protected abstract void Removed(SystemRegistry registry);
Example #9
0
 protected abstract void Attached(SystemRegistry registry);
Example #10
0
 internal void InternalAttached(SystemRegistry registry)
 {
     Attached(registry);
     HierarchyEnabledStateChanged();
 }
Example #11
0
 internal void AttachToGameObject(GameObject go, SystemRegistry registry)
 {
     _attachedGO = go;
     _transform  = _attachedGO.Transform;
     InternalAttached(registry);
 }