feat(runtime): define borrowed views commands and ordered events
Establish the J1 presentation-independent contract with instance-scoped clocks and generations, immutable borrowed views, typed generation-gated commands, normalized ordered diagnostics, and teardown acknowledgements. Route graphical startup plus press-time selection, movement, and combat through focused App adapters over the exact existing owners without adding a queue or mirrored world. Validated by the Release solution build, 13 Runtime tests, 3,838 App tests with three existing skips, and the complete 8,424-test Release suite with five existing skips. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
afebbe3eca
commit
854d9e9cd1
21 changed files with 2594 additions and 44 deletions
45
src/AcDream.Runtime/GameRuntimeClock.cs
Normal file
45
src/AcDream.Runtime/GameRuntimeClock.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
namespace AcDream.Runtime;
|
||||
|
||||
public readonly record struct RuntimeFrameTime(
|
||||
ulong FrameNumber,
|
||||
double DeltaSeconds,
|
||||
double SimulationTimeSeconds);
|
||||
|
||||
public interface IGameRuntimeClock
|
||||
{
|
||||
ulong FrameNumber { get; }
|
||||
|
||||
double SimulationTimeSeconds { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instance-scoped simulation clock shared by graphical and future headless
|
||||
/// hosts. It owns no wall-clock/global state.
|
||||
/// </summary>
|
||||
public sealed class GameRuntimeClock : IGameRuntimeClock
|
||||
{
|
||||
public ulong FrameNumber { get; private set; }
|
||||
|
||||
public double SimulationTimeSeconds { get; private set; }
|
||||
|
||||
public RuntimeFrameTime Advance(
|
||||
double hostDeltaSeconds,
|
||||
bool advanceSimulationTime = true)
|
||||
{
|
||||
double deltaSeconds = NormalizeDeltaSeconds(hostDeltaSeconds);
|
||||
FrameNumber = checked(FrameNumber + 1UL);
|
||||
if (advanceSimulationTime)
|
||||
SimulationTimeSeconds += deltaSeconds;
|
||||
return new RuntimeFrameTime(
|
||||
FrameNumber,
|
||||
deltaSeconds,
|
||||
SimulationTimeSeconds);
|
||||
}
|
||||
|
||||
public static double NormalizeDeltaSeconds(double deltaSeconds) =>
|
||||
double.IsFinite(deltaSeconds)
|
||||
&& deltaSeconds > 0.0
|
||||
&& deltaSeconds <= float.MaxValue
|
||||
? deltaSeconds
|
||||
: 0.0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue