refactor(runtime): extract the live object frame
This commit is contained in:
parent
99a3e819c4
commit
4e4aac2c5a
27 changed files with 1217 additions and 371 deletions
|
|
@ -1430,6 +1430,24 @@ public sealed class ProjectileControllerTests
|
|||
|
||||
private sealed class Fixture
|
||||
{
|
||||
private sealed class SetupResolver : IProjectileSetupResolver
|
||||
{
|
||||
private readonly Func<Setup?> _resolve;
|
||||
|
||||
internal SetupResolver(Func<Setup?> resolve) => _resolve = resolve;
|
||||
|
||||
public Setup? Resolve(uint setupId) => _resolve();
|
||||
}
|
||||
|
||||
private sealed class RootPosePublisher : IEntityRootPosePublisher
|
||||
{
|
||||
private readonly Action<WorldEntity> _publish;
|
||||
|
||||
internal RootPosePublisher(Action<WorldEntity> publish) => _publish = publish;
|
||||
|
||||
public void UpdateRoot(WorldEntity entity) => _publish(entity);
|
||||
}
|
||||
|
||||
internal Fixture(
|
||||
bool loadInitialLandblock = true,
|
||||
PhysicsEngine? physicsEngine = null,
|
||||
|
|
@ -1439,12 +1457,15 @@ public sealed class ProjectileControllerTests
|
|||
Spatial.AddLandblock(EmptyLandblock(0x0101FFFFu));
|
||||
Live = new LiveEntityRuntime(Spatial, Resources);
|
||||
Engine = physicsEngine ?? new PhysicsEngine();
|
||||
Origin.Recenter(1, 1);
|
||||
Controller = new ProjectileController(
|
||||
Live,
|
||||
Engine,
|
||||
_ => ResolvedSetup,
|
||||
publishRootPose ?? (entity => Poses.UpdateRoot(entity)),
|
||||
() => LiveCenter);
|
||||
new SetupResolver(() => ResolvedSetup),
|
||||
new RootPosePublisher(
|
||||
publishRootPose ?? new Action<WorldEntity>(
|
||||
entity => { _ = Poses.UpdateRoot(entity); })),
|
||||
Origin);
|
||||
}
|
||||
|
||||
internal GpuWorldState Spatial { get; } = new();
|
||||
|
|
@ -1452,8 +1473,8 @@ public sealed class ProjectileControllerTests
|
|||
internal LiveEntityRuntime Live { get; }
|
||||
internal PhysicsEngine Engine { get; }
|
||||
internal EntityEffectPoseRegistry Poses { get; } = new();
|
||||
internal LiveWorldOriginState Origin { get; } = new();
|
||||
internal Setup ResolvedSetup { get; set; } = ProjectileSetup();
|
||||
internal (int X, int Y) LiveCenter { get; set; } = (1, 1);
|
||||
internal ProjectileController Controller { get; }
|
||||
|
||||
internal LiveEntityRecord Spawn(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue