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:
Erik 2026-07-25 19:08:42 +02:00
parent afebbe3eca
commit 854d9e9cd1
21 changed files with 2594 additions and 44 deletions

View file

@ -1,6 +1,7 @@
namespace AcDream.App.Update;
using AcDream.App.Streaming;
using AcDream.Runtime;
/// <summary>
/// The host-supplied input for one update callback.
@ -26,29 +27,31 @@ internal readonly record struct UpdateFrameTiming(
/// hooks, and the later script drain. Absolute liveness time and raw-mouse
/// idle time intentionally do not enter this clock.
/// </remarks>
internal sealed class UpdateFrameClock : IPhysicsScriptTimeSource
internal sealed class UpdateFrameClock
: IPhysicsScriptTimeSource,
IGameRuntimeClock
{
public double CurrentScriptTime { get; private set; }
private readonly GameRuntimeClock _runtime = new();
public ulong FrameNumber => _runtime.FrameNumber;
public double SimulationTimeSeconds => _runtime.SimulationTimeSeconds;
public double CurrentScriptTime => _runtime.SimulationTimeSeconds;
public UpdateFrameTiming Advance(
UpdateFrameInput input,
bool advanceScriptClock = true)
{
double deltaSeconds = NormalizeDeltaSeconds(input.HostDeltaSeconds);
if (advanceScriptClock)
CurrentScriptTime += deltaSeconds;
RuntimeFrameTime frame = _runtime.Advance(
input.HostDeltaSeconds,
advanceScriptClock);
return new UpdateFrameTiming(
deltaSeconds,
(float)deltaSeconds,
CurrentScriptTime);
frame.DeltaSeconds,
(float)frame.DeltaSeconds,
frame.SimulationTimeSeconds);
}
public static double NormalizeDeltaSeconds(double deltaSeconds) =>
double.IsFinite(deltaSeconds)
&& deltaSeconds > 0.0
&& deltaSeconds <= float.MaxValue
? deltaSeconds
: 0.0;
GameRuntimeClock.NormalizeDeltaSeconds(deltaSeconds);
}
internal interface IPhysicsScriptTimeSource