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:
parent
c557038353
commit
eeb0f6b45c
29 changed files with 3311 additions and 1073 deletions
|
|
@ -5,6 +5,11 @@ namespace AcDream.App.Rendering;
|
|||
|
||||
public sealed class CameraController
|
||||
{
|
||||
internal readonly record struct CameraState(
|
||||
int ModeCode,
|
||||
ChaseCamera? Chase,
|
||||
RetailChaseCamera? RetailChase);
|
||||
|
||||
public OrbitCamera Orbit { get; }
|
||||
public FlyCamera Fly { get; }
|
||||
public ChaseCamera? Chase { get; private set; }
|
||||
|
|
@ -81,4 +86,22 @@ public sealed class CameraController
|
|||
Orbit.Aspect = aspect;
|
||||
Fly.Aspect = aspect;
|
||||
}
|
||||
|
||||
internal CameraState CaptureState() =>
|
||||
new((int)_mode, Chase, RetailChase);
|
||||
|
||||
/// <summary>
|
||||
/// Restores a previously captured camera lifetime before notifying
|
||||
/// subscribers. State remains restored even when a subscriber throws.
|
||||
/// </summary>
|
||||
internal void RestoreState(CameraState state)
|
||||
{
|
||||
if (state.ModeCode < (int)Mode.Orbit || state.ModeCode > (int)Mode.Chase)
|
||||
throw new ArgumentOutOfRangeException(nameof(state));
|
||||
|
||||
Chase = state.Chase;
|
||||
RetailChase = state.RetailChase;
|
||||
_mode = (Mode)state.ModeCode;
|
||||
ModeChanged?.Invoke(IsFlyMode || IsChaseMode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue