refactor(app): compose session and player startup
Move streaming, live-session, hydration, local-player, combat, and teleport construction behind the typed Phase-7 boundary. Add exact-owner runtime bindings and focused spawn-claim classification so partial startup rolls back without retaining old session targets while preserving the accepted construction and frame dependencies. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
3573da12e1
commit
7771c07fb6
31 changed files with 1759 additions and 532 deletions
|
|
@ -103,10 +103,38 @@ internal sealed class DeferredLiveEntityNetworkUpdateSink : ILiveEntityNetworkUp
|
|||
throw new InvalidOperationException("The live-entity network sink is already bound.");
|
||||
}
|
||||
|
||||
public IDisposable BindOwned(ILiveEntityNetworkUpdateSink inner)
|
||||
{
|
||||
Bind(inner);
|
||||
return new Binding(this, inner);
|
||||
}
|
||||
|
||||
private void Unbind(ILiveEntityNetworkUpdateSink expected)
|
||||
{
|
||||
_ = Interlocked.CompareExchange(ref _inner, null, expected);
|
||||
}
|
||||
|
||||
public void ApplySameGeneration(SameGenerationCreateObjectEvents events) =>
|
||||
(_inner ?? throw new InvalidOperationException(
|
||||
"The live-entity network sink must be bound before a session starts."))
|
||||
.ApplySameGeneration(events);
|
||||
|
||||
private sealed class Binding : IDisposable
|
||||
{
|
||||
private DeferredLiveEntityNetworkUpdateSink? _owner;
|
||||
private readonly ILiveEntityNetworkUpdateSink _expected;
|
||||
|
||||
public Binding(
|
||||
DeferredLiveEntityNetworkUpdateSink owner,
|
||||
ILiveEntityNetworkUpdateSink expected)
|
||||
{
|
||||
_owner = owner;
|
||||
_expected = expected;
|
||||
}
|
||||
|
||||
public void Dispose() =>
|
||||
Interlocked.Exchange(ref _owner, null)?.Unbind(_expected);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class DelegateLiveEntityNetworkUpdateSink(
|
||||
|
|
|
|||
|
|
@ -41,9 +41,37 @@ internal sealed class DeferredLiveEntityParentAcceptance
|
|||
throw new InvalidOperationException("Live parent acceptance is already bound.");
|
||||
}
|
||||
|
||||
public IDisposable BindOwned(Func<ParentEvent.Parsed, bool> accept)
|
||||
{
|
||||
Bind(accept);
|
||||
return new Binding(this, accept);
|
||||
}
|
||||
|
||||
private void Unbind(Func<ParentEvent.Parsed, bool> expected)
|
||||
{
|
||||
_ = Interlocked.CompareExchange(ref _accept, null, expected);
|
||||
}
|
||||
|
||||
public bool TryAccept(ParentEvent.Parsed update) =>
|
||||
(_accept ?? throw new InvalidOperationException(
|
||||
"Live parent acceptance must be bound before a session starts."))(update);
|
||||
|
||||
private sealed class Binding : IDisposable
|
||||
{
|
||||
private DeferredLiveEntityParentAcceptance? _owner;
|
||||
private readonly Func<ParentEvent.Parsed, bool> _expected;
|
||||
|
||||
public Binding(
|
||||
DeferredLiveEntityParentAcceptance owner,
|
||||
Func<ParentEvent.Parsed, bool> expected)
|
||||
{
|
||||
_owner = owner;
|
||||
_expected = expected;
|
||||
}
|
||||
|
||||
public void Dispose() =>
|
||||
Interlocked.Exchange(ref _owner, null)?.Unbind(_expected);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class LiveEntityReadyPublisher : ILiveEntityReadyPublisher
|
||||
|
|
|
|||
|
|
@ -152,6 +152,17 @@ internal sealed class DeferredLiveEntityRuntimeComponentLifecycle :
|
|||
throw new InvalidOperationException("The live-entity runtime component lifecycle is already bound.");
|
||||
}
|
||||
|
||||
public IDisposable BindOwned(ILiveEntityRuntimeComponentLifecycle lifecycle)
|
||||
{
|
||||
Bind(lifecycle);
|
||||
return new Binding(this, lifecycle);
|
||||
}
|
||||
|
||||
private void Unbind(ILiveEntityRuntimeComponentLifecycle expected)
|
||||
{
|
||||
_ = Interlocked.CompareExchange(ref _inner, null, expected);
|
||||
}
|
||||
|
||||
public void TearDown(LiveEntityRecord record)
|
||||
{
|
||||
ILiveEntityRuntimeComponentLifecycle lifecycle = Volatile.Read(ref _inner)
|
||||
|
|
@ -159,6 +170,23 @@ internal sealed class DeferredLiveEntityRuntimeComponentLifecycle :
|
|||
"The live-entity runtime component lifecycle has not been bound.");
|
||||
lifecycle.TearDown(record);
|
||||
}
|
||||
|
||||
private sealed class Binding : IDisposable
|
||||
{
|
||||
private DeferredLiveEntityRuntimeComponentLifecycle? _owner;
|
||||
private readonly ILiveEntityRuntimeComponentLifecycle _expected;
|
||||
|
||||
public Binding(
|
||||
DeferredLiveEntityRuntimeComponentLifecycle owner,
|
||||
ILiveEntityRuntimeComponentLifecycle expected)
|
||||
{
|
||||
_owner = owner;
|
||||
_expected = expected;
|
||||
}
|
||||
|
||||
public void Dispose() =>
|
||||
Interlocked.Exchange(ref _owner, null)?.Unbind(_expected);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Delegate adapter used by the App composition root.</summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue