CI / build-test (push) Successful in 1m24s
Core now depends only on Friflo.Engine.ECS — no MonoGame, no platform. The windowed MonoGame host moves to the new MrGameEng.Host library: GameHost, GameHostOptions, visual scene transitions (OverlayTransition, Transitions.Fade/Wipe, TransitionRenderer) and the Input feature (namespace MrGameEng.Input is unchanged). Transition timing stays in Core (SceneManager exposes ActiveTransition/TransitionCoverage/ TransitionPhase; the host draws the overlay). EngineContext loses its GraphicsDevice property: hosts publish the device as a service and graphics code reads it via context.GetGraphicsDevice() in Graphics. Core gains HeadlessHost: a fixed-timestep loop without a window or GPU (Tick/RunTicks, Run with wall-clock pacing and lag resync) for dedicated servers, batch simulation and tests. Graphics and Audio now carry their own MonoGame.Framework.DesktopGL reference instead of inheriting it from Core. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
namespace MrGameEng.Core;
|
|
|
|
/// <summary>
|
|
/// Engine time service: per-frame delta, total elapsed time, time scaling and frame counter.
|
|
/// Advanced once per frame (or per fixed tick) by the host.
|
|
/// </summary>
|
|
public sealed class GameClock
|
|
{
|
|
/// <summary>Seconds elapsed since the previous frame, multiplied by <see cref="TimeScale"/>.</summary>
|
|
public float DeltaTime { get; private set; }
|
|
|
|
/// <summary>Seconds elapsed since the previous frame, unaffected by <see cref="TimeScale"/>.</summary>
|
|
public float UnscaledDeltaTime { get; private set; }
|
|
|
|
/// <summary>Total scaled time in seconds since the game started.</summary>
|
|
public double TotalTime { get; private set; }
|
|
|
|
/// <summary>Total unscaled time in seconds since the game started.</summary>
|
|
public double UnscaledTotalTime { get; private set; }
|
|
|
|
/// <summary>Multiplier applied to <see cref="DeltaTime"/>. 0 pauses gameplay, 1 is real time. Never negative.</summary>
|
|
public float TimeScale
|
|
{
|
|
get => _timeScale;
|
|
set => _timeScale = value < 0f ? 0f : value;
|
|
}
|
|
|
|
/// <summary>Number of completed frames since the game started.</summary>
|
|
public long FrameCount { get; private set; }
|
|
|
|
private float _timeScale = 1f;
|
|
|
|
/// <summary>Advances the clock by one frame. Called by the host; games should not call this.</summary>
|
|
public void Advance(float unscaledDeltaSeconds)
|
|
{
|
|
UnscaledDeltaTime = unscaledDeltaSeconds;
|
|
DeltaTime = unscaledDeltaSeconds * _timeScale;
|
|
UnscaledTotalTime += unscaledDeltaSeconds;
|
|
TotalTime += DeltaTime;
|
|
FrameCount++;
|
|
}
|
|
}
|