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

            Removed(registry);
        }
Exemplo n.º 3
0
Arquivo: Game.cs Projeto: zhuowp/ge
 public Game()
 {
     _timeSystem = new TimeControlSystem();
     SystemRegistry.Register(_timeSystem);
     SystemRegistry.Register(new GameObjectQuerySystem(_gameObjects));
     GameObject.InternalConstructed      += OnGameObjectConstructed;
     GameObject.InternalDestroyRequested += OnGameObjectDestroyRequested;
     GameObject.InternalDestroyCommitted += OnGameObjectDestroyCommitted;
 }
Exemplo n.º 4
0
Arquivo: Game.cs Projeto: zhuowp/ge
        public void NewSceneLoaded()
        {
            var systemEnumerator = SystemRegistry.GetSystemsEnumerator();

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

            ResetDeltaTime();
        }
Exemplo n.º 5
0
Arquivo: Game.cs Projeto: zhuowp/ge
        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();
                }
            }
        }
Exemplo n.º 6
0
 internal void SetRegistry(SystemRegistry systemRegistry)
 {
     _registry = systemRegistry;
 }
Exemplo n.º 7
0
 protected abstract void Removed(SystemRegistry registry);
Exemplo n.º 8
0
 protected abstract void Attached(SystemRegistry registry);
Exemplo n.º 9
0
 internal void InternalAttached(SystemRegistry registry)
 {
     Attached(registry);
     HierarchyEnabledStateChanged();
 }
Exemplo n.º 10
0
 internal void AttachToGameObject(GameObject go, SystemRegistry registry)
 {
     _attachedGO = go;
     _transform  = _attachedGO.Transform;
     InternalAttached(registry);
 }
Exemplo n.º 11
0
 protected override void Attached(SystemRegistry registry)
 {
 }