refactor(runtime): extract local teleport and player mode

Move local teleport, player-mode, animation, shadow, and sealed-dungeon lifetimes out of GameWindow. Make player-mode entry transactional and isolate approach completions by controller lifetime and approach generation so stale callbacks cannot affect replacements.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-22 02:50:15 +02:00
parent c557038353
commit eeb0f6b45c
29 changed files with 3311 additions and 1073 deletions

View file

@ -124,6 +124,40 @@ public sealed class LiveEntityPhysicsHostOwnershipTests
Assert.Equal(12f, watcher.Position.Frame.Origin.X);
}
[Fact]
public void PreparedRebind_DoesNotPublishDelegatesUntilCommit()
{
const uint guid = 0x70000025u;
var runtime = Runtime();
LiveEntityRecord record = runtime.RegisterLiveEntity(Spawn(guid, 1)).Record!;
EntityPhysicsHost original = Host(
guid,
position: new Vector3(1f, 0f, 0f));
runtime.InstallPhysicsHost(record, original);
EntityPhysicsHost configuration = Host(
guid,
position: new Vector3(9f, 0f, 0f));
EntityPhysicsHost stable = EntityPhysicsHost.SelectStableHostWithoutRebind(
runtime,
record,
configuration);
// A late DAT/physics/camera preparation failure occurs here in the
// player-mode transaction. The live record must still expose its
// previous delegates and manager identity.
Assert.Same(original, stable);
Assert.Same(original, record.PhysicsHost);
Assert.Equal(1f, original.Position.Frame.Origin.X);
EntityPhysicsHost committed = EntityPhysicsHost.InstallOrRebind(
runtime,
record,
configuration);
Assert.Same(original, committed);
Assert.Equal(9f, committed.Position.Frame.Origin.X);
}
[Fact]
public void SameGuidReplacement_HostCallbacksRemainIncarnationLocal()
{