refactor(app): compose live presentation startup

This commit is contained in:
Erik 2026-07-22 17:55:15 +02:00
parent aa6ffa5176
commit 88f32dc4e2
23 changed files with 1767 additions and 626 deletions

View file

@ -39,6 +39,18 @@ internal sealed class DeferredLiveEntityMotionRuntimeBindings
_target = target;
}
public IDisposable BindOwned(ILiveEntityMotionRuntimeBindings target)
{
Bind(target);
return new Binding(this, target);
}
private void Unbind(ILiveEntityMotionRuntimeBindings expected)
{
if (ReferenceEquals(_target, expected))
_target = null;
}
private ILiveEntityMotionRuntimeBindings Target =>
_target ?? throw new InvalidOperationException(
"Live entity motion runtime bindings were used before binding.");
@ -61,4 +73,21 @@ internal sealed class DeferredLiveEntityMotionRuntimeBindings
public IPhysicsObjHost? ResolvePhysicsHost(uint serverGuid) =>
Target.ResolvePhysicsHost(serverGuid);
private sealed class Binding : IDisposable
{
private DeferredLiveEntityMotionRuntimeBindings? _owner;
private readonly ILiveEntityMotionRuntimeBindings _expected;
public Binding(
DeferredLiveEntityMotionRuntimeBindings owner,
ILiveEntityMotionRuntimeBindings expected)
{
_owner = owner;
_expected = expected;
}
public void Dispose() =>
Interlocked.Exchange(ref _owner, null)?.Unbind(_expected);
}
}