protected override void Removed(SystemRegistry registry) { if (Parent != null) { bool result = Parent._children.Remove(this); Debug.Assert(result); } }
internal void InternalRemoved(SystemRegistry registry) { if (_enabledInHierarchy) { OnDisabled(); } Removed(registry); }
public Game() { _timeSystem = new TimeControlSystem(); SystemRegistry.Register(_timeSystem); SystemRegistry.Register(new GameObjectQuerySystem(_gameObjects)); GameObject.InternalConstructed += OnGameObjectConstructed; GameObject.InternalDestroyRequested += OnGameObjectDestroyRequested; GameObject.InternalDestroyCommitted += OnGameObjectDestroyCommitted; }
public void NewSceneLoaded() { var systemEnumerator = SystemRegistry.GetSystemsEnumerator(); while (systemEnumerator.MoveNext()) { var kvp = systemEnumerator.Current; kvp.Value.OnNewSceneLoaded(); } ResetDeltaTime(); }
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(); } } }
protected override void Attached(SystemRegistry registry) { }
internal void SetRegistry(SystemRegistry systemRegistry) { _registry = systemRegistry; }
protected abstract void Removed(SystemRegistry registry);
protected abstract void Attached(SystemRegistry registry);
internal void InternalAttached(SystemRegistry registry) { Attached(registry); HierarchyEnabledStateChanged(); }
internal void AttachToGameObject(GameObject go, SystemRegistry registry) { _attachedGO = go; _transform = _attachedGO.Transform; InternalAttached(registry); }