private void OnRootConsoleRender(object sender, GameLoopEventArgs e) { if (!_leaving) { SystemContainer.AnimationSystem.Tick(); SystemContainer.AnimatedMovementSystem.Tick(); SystemContainer.ParticleSystem.Tick(); Stack <IActivity> renderStack = new Stack <IActivity>(); foreach (IActivity activity in SystemContainer.ActivitySystem.ActivitiesForRendering) { renderStack.Push(activity); if (activity.RendersEntireSpace) { break; } } var activityIndex = 0; foreach (IActivity activity in renderStack) { if ((activity as GameplayActivity)?.Running ?? true) { SystemContainer.RendererSystem.Renderer.Render(SystemContainer, activity, activityIndex++); } } IOSystem.Draw(); } }
void UpdateAnimations(object sender, GameLoopEventArgs e) { foreach (var anim in _animations.ToList()) { anim.CurrentDuration += (float)e.GameTime.ElapsedGameTime.TotalMilliseconds; if (anim.CurrentDuration > anim.Duration) { anim.CurrentDuration = anim.Duration; } anim.NotifyValue(); if (anim.CurrentDuration == anim.Duration || anim.Cancellation.IsCancellationRequested) { anim.Completion.TrySetResult(true); _animations.Remove(anim); } } if (_animations.Count == 0) { DrawContext.BeforeLoop -= UpdateAnimations; } }
private void OnRootConsoleUpdate(object sender, GameLoopEventArgs e) { if (!_leaving && !Loading) { var keyPress = IOSystem.GetKeyPress(); SystemContainer.ControlSystem.HandleInput(keyPress, IOSystem.GetMouseData()); if (!SystemContainer.AnimatedMovementSystem.IsBlockingAnimationPlaying()) { var throttle = 1000; while ( !SystemContainer.TimeSystem.WaitingForInput && SystemContainer.ActivitySystem.Count > 0 && SystemContainer.ActivitySystem.GetActivityAcceptingInput().Type == ActivityType.Gameplay && SystemContainer.PlayerSystem.Player != null && !_leaving && throttle-- > 0) { SystemContainer.TimeSystem.Tick(); } } } }
void FadeScreen(object sender, GameLoopEventArgs args) { SpriteBatch.Begin(); SpriteBatch.Draw(BlackTexture, drawRectangle: GraphicsDevice.Viewport.Bounds, color: new Color(Color.White, _screenOpacity)); SpriteBatch.End(); }