refactor(camera): extract the update frame

Move fly/chase publication, combat target tracking, and local player projection behind typed runtime owners. Preserve the inbound-created projection/reconcile barrier while removing GameWindow callbacks and duplicate shadow helpers.
This commit is contained in:
Erik 2026-07-22 03:08:58 +02:00
parent eeb0f6b45c
commit 947c61d2d7
19 changed files with 988 additions and 356 deletions

View file

@ -26,14 +26,14 @@ public sealed class LocalPlayerProjectionControllerTests
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
};
var projection = new LocalPlayerProjectionController(
var projection = new LocalPlayerProjectionController(new TestProjectionRuntime(
() => entity,
() => 1,
() => 1,
(_, _) => { },
(_, _) => { },
_ => true,
_ => { });
_ => { }));
projection.Project(
movement,
@ -64,14 +64,14 @@ public sealed class LocalPlayerProjectionControllerTests
MeshRefs = Array.Empty<MeshRef>(),
};
var order = new List<string>();
var projection = new LocalPlayerProjectionController(
var projection = new LocalPlayerProjectionController(new TestProjectionRuntime(
() => entity,
() => 2,
() => 2,
(_, _) => order.Add("shadow"),
(_, _) => order.Add("rebucket"),
_ => false,
_ => order.Add("suspend"));
_ => order.Add("suspend")));
projection.Project(
movement,
@ -100,7 +100,7 @@ public sealed class LocalPlayerProjectionControllerTests
};
bool visible = false;
var order = new List<string>();
var projection = new LocalPlayerProjectionController(
var projection = new LocalPlayerProjectionController(new TestProjectionRuntime(
() => entity,
() => 2,
() => 2,
@ -111,7 +111,7 @@ public sealed class LocalPlayerProjectionControllerTests
visible = true;
},
_ => visible,
_ => order.Add("suspend"));
_ => order.Add("suspend")));
projection.Project(
movement,
@ -120,4 +120,25 @@ public sealed class LocalPlayerProjectionControllerTests
Assert.Equal(["rebucket", "shadow"], order);
}
private sealed class TestProjectionRuntime(
Func<WorldEntity?> resolveEntity,
Func<int> liveCenterX,
Func<int> liveCenterY,
Action<WorldEntity, uint> syncShadow,
Action<uint, uint> rebucket,
Func<WorldEntity, bool> isCurrentVisibleProjection,
Action<WorldEntity> suspendShadow) : ILocalPlayerProjectionRuntime
{
public WorldEntity? ResolveEntity() => resolveEntity();
public int LiveCenterX => liveCenterX();
public int LiveCenterY => liveCenterY();
public void SyncShadow(WorldEntity entity, uint cellId) =>
syncShadow(entity, cellId);
public void Rebucket(uint serverGuid, uint landblockId) =>
rebucket(serverGuid, landblockId);
public bool IsCurrentVisibleProjection(WorldEntity entity) =>
isCurrentVisibleProjection(entity);
public void SuspendShadow(WorldEntity entity) => suspendShadow(entity);
}
}