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:
parent
eeb0f6b45c
commit
947c61d2d7
19 changed files with 988 additions and 356 deletions
|
|
@ -0,0 +1,69 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.Combat;
|
||||
using AcDream.App.Interaction;
|
||||
using AcDream.Core.Combat;
|
||||
using AcDream.Core.Selection;
|
||||
|
||||
namespace AcDream.App.Tests.Combat;
|
||||
|
||||
public sealed class CombatCameraTargetSourceTests
|
||||
{
|
||||
[Fact]
|
||||
public void GetTrackedTargetPoint_RequiresOptionTargetedModeAndSelection()
|
||||
{
|
||||
const uint target = 0x70000001u;
|
||||
Vector3 point = new(10f, 20f, 30f);
|
||||
var settings = new GameplaySettingsState();
|
||||
var combat = new CombatState();
|
||||
var selection = new SelectionState();
|
||||
var world = new TargetQuery(point);
|
||||
var source = new CombatCameraTargetSource(
|
||||
settings,
|
||||
combat,
|
||||
selection,
|
||||
world);
|
||||
|
||||
Assert.Null(source.GetTrackedTargetPoint());
|
||||
|
||||
settings.Value = settings.Value with { ViewCombatTarget = true };
|
||||
combat.SetCombatMode(CombatMode.Melee);
|
||||
selection.Select(target, SelectionChangeSource.World);
|
||||
|
||||
Assert.Equal(point, source.GetTrackedTargetPoint());
|
||||
Assert.Equal(target, world.LastGuid);
|
||||
|
||||
combat.SetCombatMode(CombatMode.Magic);
|
||||
Assert.Null(source.GetTrackedTargetPoint());
|
||||
}
|
||||
|
||||
private sealed class TargetQuery(Vector3 point) : IWorldSelectionQuery
|
||||
{
|
||||
public uint LastGuid { get; private set; }
|
||||
public Vector3? GetCombatCameraTargetPoint(uint serverGuid)
|
||||
{
|
||||
LastGuid = serverGuid;
|
||||
return point;
|
||||
}
|
||||
|
||||
public uint? PickAtCursor(bool includeSelf) => null;
|
||||
public uint? PickAt(float mouseX, float mouseY, bool includeSelf) => null;
|
||||
public void BeginLightingPulse(uint serverGuid) { }
|
||||
public bool TryCaptureIdentity(uint serverGuid, out uint localEntityId)
|
||||
{
|
||||
localEntityId = 0;
|
||||
return false;
|
||||
}
|
||||
public bool IsCurrent(uint serverGuid, uint localEntityId) => false;
|
||||
public string Describe(uint serverGuid) => string.Empty;
|
||||
public bool IsCreature(uint serverGuid) => false;
|
||||
public bool IsHostileMonster(uint serverGuid) => false;
|
||||
public ClosestCombatTarget? FindClosestHostileMonster() => null;
|
||||
public bool IsUseable(uint serverGuid) => false;
|
||||
public bool IsPickupable(uint serverGuid) => false;
|
||||
public bool TryGetApproach(uint serverGuid, out InteractionApproach approach)
|
||||
{
|
||||
approach = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +120,7 @@ public sealed class LiveCombatAttackOperationsTests
|
|||
{
|
||||
public bool AutoTarget { get; set; }
|
||||
public bool AutoRepeatAttack { get; set; }
|
||||
public bool ViewCombatTarget { get; set; }
|
||||
}
|
||||
|
||||
private sealed class FakeLiveSource : ILiveInWorldSource, ILiveWorldSessionSource
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
var calls = new List<string>();
|
||||
var preNetwork = new List<(PlayerState State, MovementResult Movement)>();
|
||||
var postNetwork = new List<PlayerState>();
|
||||
var local = new RetailLocalPlayerFrameController(
|
||||
var local = CreateFrame(
|
||||
canPresentPlayer: () => true,
|
||||
getController: () => controller,
|
||||
movementInput: Input(() => new MovementInput(Forward: true)),
|
||||
|
|
@ -79,7 +79,7 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
int projections = 0;
|
||||
int preNetwork = 0;
|
||||
int postNetwork = 0;
|
||||
var local = new RetailLocalPlayerFrameController(
|
||||
var local = CreateFrame(
|
||||
canPresentPlayer: () => controller is not null,
|
||||
getController: () => controller,
|
||||
movementInput: Input(() => new MovementInput(Forward: true)),
|
||||
|
|
@ -109,7 +109,7 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
{
|
||||
PlayerMovementController controller = CreateController();
|
||||
Vector3 projectedRoot = default;
|
||||
var local = new RetailLocalPlayerFrameController(
|
||||
var local = CreateFrame(
|
||||
canPresentPlayer: () => true,
|
||||
getController: () => controller,
|
||||
movementInput: Input(() => new MovementInput()),
|
||||
|
|
@ -140,7 +140,7 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
PlayerMovementController controller = CreateController();
|
||||
Vector3 initial = controller.Position;
|
||||
Vector3 positionSeenByTargetManager = new(float.NaN);
|
||||
var local = new RetailLocalPlayerFrameController(
|
||||
var local = CreateFrame(
|
||||
canPresentPlayer: () => true,
|
||||
getController: () => controller,
|
||||
movementInput: Input(() => new MovementInput(Forward: true)),
|
||||
|
|
@ -166,7 +166,7 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
int projections = 0;
|
||||
int preNetwork = 0;
|
||||
int postNetwork = 0;
|
||||
var local = new RetailLocalPlayerFrameController(
|
||||
var local = CreateFrame(
|
||||
canPresentPlayer: () => true,
|
||||
getController: () => controller,
|
||||
movementInput: Input(() =>
|
||||
|
|
@ -201,7 +201,7 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
public void HiddenPoseIsDirtyOnlyWhenACompleteObjectQuantumRuns()
|
||||
{
|
||||
PlayerMovementController controller = CreateController();
|
||||
var local = new RetailLocalPlayerFrameController(
|
||||
var local = CreateFrame(
|
||||
canPresentPlayer: () => true,
|
||||
getController: () => controller,
|
||||
movementInput: Input(() => new MovementInput()),
|
||||
|
|
@ -228,7 +228,7 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
int projections = 0;
|
||||
int preNetwork = 0;
|
||||
int postNetwork = 0;
|
||||
var local = new RetailLocalPlayerFrameController(
|
||||
var local = CreateFrame(
|
||||
canPresentPlayer: () => true,
|
||||
getController: () => controller,
|
||||
movementInput: Input(() =>
|
||||
|
|
@ -297,6 +297,65 @@ public sealed class RetailLocalPlayerFrameControllerTests
|
|||
private static IMovementInputSource Input(Func<MovementInput> capture) =>
|
||||
new TestMovementInputSource(capture);
|
||||
|
||||
private static RetailLocalPlayerFrameController CreateFrame(
|
||||
Func<bool> canPresentPlayer,
|
||||
Func<PlayerMovementController?> getController,
|
||||
IMovementInputSource movementInput,
|
||||
Func<uint> resolveLocalEntityId,
|
||||
Action handleTargeting,
|
||||
Func<bool> isHidden,
|
||||
Action<PlayerMovementController, MovementResult, bool> project,
|
||||
Action<PlayerMovementController, MovementResult, bool> sendPreNetwork,
|
||||
Action<PlayerMovementController, bool> sendPostNetwork,
|
||||
Func<RetailObjectClockDisposition>? objectClockDisposition = null) =>
|
||||
new(
|
||||
new TestLocalPlayerFrameRuntime(
|
||||
canPresentPlayer,
|
||||
getController,
|
||||
resolveLocalEntityId,
|
||||
handleTargeting,
|
||||
isHidden,
|
||||
project,
|
||||
sendPreNetwork,
|
||||
sendPostNetwork,
|
||||
objectClockDisposition),
|
||||
movementInput);
|
||||
|
||||
private sealed class TestLocalPlayerFrameRuntime(
|
||||
Func<bool> canPresentPlayer,
|
||||
Func<PlayerMovementController?> getController,
|
||||
Func<uint> resolveLocalEntityId,
|
||||
Action handleTargeting,
|
||||
Func<bool> isHidden,
|
||||
Action<PlayerMovementController, MovementResult, bool> project,
|
||||
Action<PlayerMovementController, MovementResult, bool> sendPreNetwork,
|
||||
Action<PlayerMovementController, bool> sendPostNetwork,
|
||||
Func<RetailObjectClockDisposition>? objectClockDisposition)
|
||||
: ILocalPlayerFrameRuntime
|
||||
{
|
||||
public bool CanPresentPlayer => canPresentPlayer();
|
||||
public PlayerMovementController? Controller => getController();
|
||||
public uint ResolveLocalEntityId() => resolveLocalEntityId();
|
||||
public void HandleTargeting() => handleTargeting();
|
||||
public bool IsHidden => isHidden();
|
||||
public RetailObjectClockDisposition ObjectClockDisposition =>
|
||||
objectClockDisposition?.Invoke() ?? RetailObjectClockDisposition.Advance;
|
||||
|
||||
public void Project(
|
||||
PlayerMovementController controller,
|
||||
MovementResult movement,
|
||||
bool hidden) => project(controller, movement, hidden);
|
||||
|
||||
public void SendPreNetwork(
|
||||
PlayerMovementController controller,
|
||||
MovementResult movement,
|
||||
bool hidden) => sendPreNetwork(controller, movement, hidden);
|
||||
|
||||
public void SendPostNetwork(
|
||||
PlayerMovementController controller,
|
||||
bool hidden) => sendPostNetwork(controller, hidden);
|
||||
}
|
||||
|
||||
private sealed class TestMovementInputSource(Func<MovementInput> capture)
|
||||
: IMovementInputSource
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public sealed class SelectionInteractionControllerTests
|
|||
public ClosestCombatTarget? FindClosestHostileMonster() => Closest;
|
||||
public bool IsUseable(uint serverGuid) => Useable;
|
||||
public bool IsPickupable(uint serverGuid) => Pickupable;
|
||||
public Vector3? GetCombatCameraTargetPoint(uint serverGuid) => null;
|
||||
|
||||
public bool TryGetApproach(uint serverGuid, out InteractionApproach approach)
|
||||
{
|
||||
|
|
|
|||
231
tests/AcDream.App.Tests/Rendering/CameraFrameControllerTests.cs
Normal file
231
tests/AcDream.App.Tests/Rendering/CameraFrameControllerTests.cs
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.Combat;
|
||||
using AcDream.App.Input;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.App.Update;
|
||||
using AcDream.Core.Physics;
|
||||
|
||||
namespace AcDream.App.Tests.Rendering;
|
||||
|
||||
public sealed class CameraFrameControllerTests
|
||||
{
|
||||
[Fact]
|
||||
public void FlyMode_UsesOneSemanticHeldInputSnapshot()
|
||||
{
|
||||
CameraController camera = CreateCamera();
|
||||
camera.ToggleFly();
|
||||
Vector3 start = camera.Fly.Position;
|
||||
var input = new InputSource
|
||||
{
|
||||
Fly = new FlyCameraInput(
|
||||
Forward: true,
|
||||
Left: false,
|
||||
Backward: false,
|
||||
Right: false,
|
||||
Up: true,
|
||||
Down: false,
|
||||
Boost: false),
|
||||
};
|
||||
CameraFrameController frame = CreateFrame(camera, input: input);
|
||||
|
||||
frame.Tick(new UpdateFrameTiming(0.5, 0.5f, 0.5));
|
||||
|
||||
Assert.Equal(1, input.FlyCaptures);
|
||||
Assert.InRange(camera.Fly.Position.Y - start.Y, 5.999f, 6.001f);
|
||||
Assert.InRange(camera.Fly.Position.Z - start.Z, 5.999f, 6.001f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DevToolsKeyboardCapture_PausesFlyCamera()
|
||||
{
|
||||
CameraController camera = CreateCamera();
|
||||
camera.ToggleFly();
|
||||
Vector3 start = camera.Fly.Position;
|
||||
var input = new InputSource
|
||||
{
|
||||
Fly = new FlyCameraInput(true, false, false, false, false, false, false),
|
||||
};
|
||||
CameraFrameController frame = CreateFrame(
|
||||
camera,
|
||||
capture: new CaptureSource { DevToolsKeyboard = true },
|
||||
input: input);
|
||||
|
||||
frame.Tick(new UpdateFrameTiming(1.0, 1f, 1.0));
|
||||
|
||||
Assert.Equal(start, camera.Fly.Position);
|
||||
Assert.Equal(0, input.FlyCaptures);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InboundCreatedPlayer_ProjectsThenReconcilesBeforeCameraPublication()
|
||||
{
|
||||
PlayerMovementController controller = CreatePlayer();
|
||||
var calls = new List<string>();
|
||||
var runtime = new PlayerRuntime(controller, calls);
|
||||
var localFrame = new RetailLocalPlayerFrameController(
|
||||
runtime,
|
||||
new StillMovementInput());
|
||||
CameraController camera = CreateCamera();
|
||||
var legacy = new ChaseCamera();
|
||||
var retail = new RetailChaseCamera();
|
||||
camera.EnterChaseMode(legacy, retail);
|
||||
var chase = new ChaseSource(legacy, retail);
|
||||
var reconciler = new Reconciler(calls);
|
||||
var frame = new CameraFrameController(
|
||||
camera,
|
||||
new CaptureSource(),
|
||||
new InputSource(),
|
||||
runtime,
|
||||
chase,
|
||||
localFrame,
|
||||
reconciler,
|
||||
new CombatTargetSource());
|
||||
|
||||
frame.Tick(new UpdateFrameTiming(1.0 / 60.0, 1f / 60f, 1.0));
|
||||
|
||||
Assert.Equal(["project", "reconcile"], calls);
|
||||
Assert.NotEqual(Vector3.Zero, legacy.Position);
|
||||
Assert.NotEqual(Vector3.Zero, retail.Position);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PreNetworkAdvancedPlayer_DoesNotRunTheInboundCreationReconcile()
|
||||
{
|
||||
PlayerMovementController controller = CreatePlayer();
|
||||
var calls = new List<string>();
|
||||
var runtime = new PlayerRuntime(controller, calls);
|
||||
var localFrame = new RetailLocalPlayerFrameController(
|
||||
runtime,
|
||||
new StillMovementInput());
|
||||
localFrame.AdvanceBeforeNetwork(PhysicsBody.MaxQuantum);
|
||||
calls.Clear();
|
||||
CameraController camera = CreateCamera();
|
||||
var legacy = new ChaseCamera();
|
||||
var retail = new RetailChaseCamera();
|
||||
camera.EnterChaseMode(legacy, retail);
|
||||
var frame = new CameraFrameController(
|
||||
camera,
|
||||
new CaptureSource(),
|
||||
new InputSource(),
|
||||
runtime,
|
||||
new ChaseSource(legacy, retail),
|
||||
localFrame,
|
||||
new Reconciler(calls),
|
||||
new CombatTargetSource());
|
||||
|
||||
frame.Tick(new UpdateFrameTiming(1.0 / 60.0, 1f / 60f, 1.0));
|
||||
|
||||
Assert.Empty(calls);
|
||||
}
|
||||
|
||||
private static CameraFrameController CreateFrame(
|
||||
CameraController camera,
|
||||
CaptureSource? capture = null,
|
||||
InputSource? input = null)
|
||||
{
|
||||
var runtime = new PlayerRuntime(null, []);
|
||||
var localFrame = new RetailLocalPlayerFrameController(
|
||||
runtime,
|
||||
new StillMovementInput());
|
||||
return new CameraFrameController(
|
||||
camera,
|
||||
capture ?? new CaptureSource(),
|
||||
input ?? new InputSource(),
|
||||
runtime,
|
||||
new ChaseSource(null, null),
|
||||
localFrame,
|
||||
new Reconciler([]),
|
||||
new CombatTargetSource());
|
||||
}
|
||||
|
||||
private static CameraController CreateCamera() =>
|
||||
new(new OrbitCamera(), new FlyCamera());
|
||||
|
||||
private static PlayerMovementController CreatePlayer()
|
||||
{
|
||||
var engine = new PhysicsEngine();
|
||||
var heights = new byte[81];
|
||||
Array.Fill(heights, (byte)50);
|
||||
var heightTable = new float[256];
|
||||
for (int i = 0; i < heightTable.Length; i++)
|
||||
heightTable[i] = i;
|
||||
engine.AddLandblock(
|
||||
0xA9B4FFFFu,
|
||||
new TerrainSurface(heights, heightTable),
|
||||
Array.Empty<CellSurface>(),
|
||||
Array.Empty<PortalPlane>(),
|
||||
0f,
|
||||
0f);
|
||||
var controller = new PlayerMovementController(engine);
|
||||
controller.SetPosition(new Vector3(96f, 96f, 50f), 0x0001u);
|
||||
return controller;
|
||||
}
|
||||
|
||||
private sealed class CaptureSource : IInputCaptureSource
|
||||
{
|
||||
public bool DevToolsKeyboard { get; set; }
|
||||
public bool WantCaptureMouse => false;
|
||||
public bool WantCaptureKeyboard => DevToolsKeyboard;
|
||||
public bool DevToolsWantCaptureKeyboard => DevToolsKeyboard;
|
||||
}
|
||||
|
||||
private sealed class InputSource : ICameraFrameInputSource
|
||||
{
|
||||
public bool IsAvailable { get; set; } = true;
|
||||
public FlyCameraInput Fly { get; set; }
|
||||
public ChaseCameraAdjustmentInput Chase { get; set; }
|
||||
public int FlyCaptures { get; private set; }
|
||||
public FlyCameraInput CaptureFly()
|
||||
{
|
||||
FlyCaptures++;
|
||||
return Fly;
|
||||
}
|
||||
public ChaseCameraAdjustmentInput CaptureChaseAdjustment() => Chase;
|
||||
}
|
||||
|
||||
private sealed class ChaseSource(
|
||||
ChaseCamera? legacy,
|
||||
RetailChaseCamera? retail) : IChaseCameraSource
|
||||
{
|
||||
public ChaseCamera? Legacy => legacy;
|
||||
public RetailChaseCamera? Retail => retail;
|
||||
}
|
||||
|
||||
private sealed class StillMovementInput : IMovementInputSource
|
||||
{
|
||||
public MovementInput Capture() => default;
|
||||
}
|
||||
|
||||
private sealed class PlayerRuntime(
|
||||
PlayerMovementController? controller,
|
||||
List<string> calls) : ILocalPlayerFrameRuntime
|
||||
{
|
||||
public bool CanPresentPlayer { get; set; } = controller is not null;
|
||||
public PlayerMovementController? Controller => controller;
|
||||
public uint ResolveLocalEntityId() => 7u;
|
||||
public void HandleTargeting() { }
|
||||
public bool IsHidden => false;
|
||||
public RetailObjectClockDisposition ObjectClockDisposition =>
|
||||
RetailObjectClockDisposition.Advance;
|
||||
public void Project(
|
||||
PlayerMovementController owner,
|
||||
MovementResult movement,
|
||||
bool hidden) => calls.Add("project");
|
||||
public void SendPreNetwork(
|
||||
PlayerMovementController owner,
|
||||
MovementResult movement,
|
||||
bool hidden) { }
|
||||
public void SendPostNetwork(PlayerMovementController owner, bool hidden) { }
|
||||
}
|
||||
|
||||
private sealed class Reconciler(List<string> calls)
|
||||
: ILiveSpatialReconcilePhase
|
||||
{
|
||||
public void Reconcile() => calls.Add("reconcile");
|
||||
}
|
||||
|
||||
private sealed class CombatTargetSource : ICombatCameraTargetSource
|
||||
{
|
||||
public Vector3? GetTrackedTargetPoint() => null;
|
||||
}
|
||||
}
|
||||
|
|
@ -619,6 +619,64 @@ public sealed class UpdateFrameOrchestratorTests
|
|||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CameraAndLocalPlayerFrameOwnersUseTypedSeamsWithoutWindowCallbacks()
|
||||
{
|
||||
Type[] owners =
|
||||
[
|
||||
typeof(AcDream.App.Rendering.CameraFrameController),
|
||||
typeof(AcDream.App.Input.RetailLocalPlayerFrameController),
|
||||
typeof(AcDream.App.Input.LocalPlayerProjectionController),
|
||||
typeof(AcDream.App.Input.LiveLocalPlayerFrameRuntime),
|
||||
typeof(AcDream.App.Input.LiveLocalPlayerProjectionRuntime),
|
||||
typeof(AcDream.App.Combat.CombatCameraTargetSource),
|
||||
];
|
||||
|
||||
foreach (Type owner in owners)
|
||||
{
|
||||
FieldInfo[] fields = owner.GetFields(
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
Assert.DoesNotContain(fields, field => field.FieldType == typeof(GameWindow));
|
||||
Assert.DoesNotContain(
|
||||
fields,
|
||||
field => typeof(Delegate).IsAssignableFrom(field.FieldType));
|
||||
}
|
||||
|
||||
string root = FindRepoRoot();
|
||||
string source = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"src",
|
||||
"AcDream.App",
|
||||
"Rendering",
|
||||
"GameWindow.cs"));
|
||||
Assert.Equal(1, CountOccurrences(source, "_cameraFrame.Tick(frameTiming);"));
|
||||
Assert.DoesNotContain("CanAdvanceLocalPlayer", source, StringComparison.Ordinal);
|
||||
Assert.DoesNotContain("GetCombatCameraTargetPoint()", source,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain("_cameraController.Fly.Update(", source,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain("_localPlayerFrame.TryGetPresentationAfterNetwork", source,
|
||||
StringComparison.Ordinal);
|
||||
AssertAppearsInOrder(
|
||||
source,
|
||||
"_localPlayerTeleport!.Tick(frameDelta);",
|
||||
"_playerModeAutoEntry?.TryEnter();",
|
||||
"_cameraFrame.Tick(frameTiming);");
|
||||
|
||||
string cameraSource = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"src",
|
||||
"AcDream.App",
|
||||
"Rendering",
|
||||
"CameraFrameController.cs"));
|
||||
AssertAppearsInOrder(
|
||||
cameraSource,
|
||||
"_localFrame.TryGetPresentationAfterNetwork",
|
||||
"_spatialReconciler.Reconcile();",
|
||||
"legacy.Update(",
|
||||
"retail?.Update(");
|
||||
}
|
||||
|
||||
private static UpdateFrameOrchestrator Create(
|
||||
List<string> calls,
|
||||
RecordingTeardown? teardown = null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue