refactor(runtime): close simulation ownership
Move remote-motion construction, CreateObject vector initialization, final simulation-component retirement, and the combined J5 ownership ledger into Runtime. Delete App compatibility views and moved-state reconstruction while preserving the existing graphical projection and retail update order.
This commit is contained in:
parent
c30a3efeb0
commit
cdee7a4b49
57 changed files with 1013 additions and 410 deletions
|
|
@ -96,7 +96,7 @@ public sealed class LiveCombatAttackOperationsTests
|
|||
var combat = new CombatState();
|
||||
var targets = new FakeTargets();
|
||||
var settings = new FakeSettings();
|
||||
var player = new LocalPlayerControllerSlot();
|
||||
var player = new RuntimeLocalPlayerMovementState();
|
||||
var live = new FakeLiveSource { IsInWorld = inWorld };
|
||||
var feedback = new FakeFeedback();
|
||||
var outbound = new LocalPlayerOutboundController(
|
||||
|
|
|
|||
|
|
@ -1,18 +1,4 @@
|
|||
global using AcDream.Runtime.Gameplay;
|
||||
global using AcDream.Runtime.Physics;
|
||||
global using ILiveEntityRemoteMotionRuntime =
|
||||
AcDream.Runtime.Physics.IRuntimeRemoteMotion;
|
||||
global using ILiveEntityPhysicsHostConsumer =
|
||||
AcDream.Runtime.Physics.IRuntimePhysicsHostConsumer;
|
||||
global using ILiveEntityCanonicalRuntimeConsumer =
|
||||
AcDream.Runtime.Physics.IRuntimeCanonicalPhysicsConsumer;
|
||||
global using ILiveEntityCanonicalCellConsumer =
|
||||
AcDream.Runtime.Physics.IRuntimeCanonicalCellConsumer;
|
||||
global using ILiveEntityRemotePlacementRuntime =
|
||||
AcDream.Runtime.Physics.IRuntimeRemotePlacement;
|
||||
global using LocalPlayerControllerSlot =
|
||||
AcDream.Runtime.Gameplay.RuntimeLocalPlayerMovementState;
|
||||
global using ILocalPlayerControllerSource =
|
||||
AcDream.Runtime.Gameplay.IRuntimeLocalPlayerControllerSource;
|
||||
global using ILocalPlayerMotionSource =
|
||||
AcDream.Runtime.Gameplay.IRuntimeLocalPlayerMotionSource;
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public sealed class MouseLookControllerTests
|
|||
{
|
||||
PlayerMovementController player = CreatePlayer();
|
||||
var mode = new LocalPlayerModeState();
|
||||
var slot = new LocalPlayerControllerSlot { Controller = player };
|
||||
var slot = new RuntimeLocalPlayerMovementState { Controller = player };
|
||||
var camera = new CameraController(new OrbitCamera(), new FlyCamera());
|
||||
var chase = new ChaseCameraInputState();
|
||||
var mouse = new FakeMouse();
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ using AcDream.Core.Physics;
|
|||
|
||||
namespace AcDream.App.Tests.Input;
|
||||
|
||||
public sealed class LocalPlayerControllerSlotTests
|
||||
public sealed class RuntimeLocalPlayerMovementStateTests
|
||||
{
|
||||
[Fact]
|
||||
public void MotionPreparation_RoutesCompletionWithoutPublishingController()
|
||||
{
|
||||
var slot = new LocalPlayerControllerSlot();
|
||||
var slot = new RuntimeLocalPlayerMovementState();
|
||||
ILocalPlayerMotionSource source = slot;
|
||||
var controller = new PlayerMovementController(new PhysicsEngine());
|
||||
controller.Motion.AddToQueue(0, MotionCommand.Ready, 0);
|
||||
|
|
@ -29,7 +29,7 @@ public sealed class LocalPlayerControllerSlotTests
|
|||
[Fact]
|
||||
public void MotionPreparation_HandsOffToCommittedControllerOnDispose()
|
||||
{
|
||||
var slot = new LocalPlayerControllerSlot();
|
||||
var slot = new RuntimeLocalPlayerMovementState();
|
||||
ILocalPlayerMotionSource source = slot;
|
||||
var controller = new PlayerMovementController(new PhysicsEngine());
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ public sealed class LocalPlayerControllerSlotTests
|
|||
[Fact]
|
||||
public void MotionPreparation_DrainsPriorAnimationBeforePublishingCandidate()
|
||||
{
|
||||
var slot = new LocalPlayerControllerSlot();
|
||||
var slot = new RuntimeLocalPlayerMovementState();
|
||||
ILocalPlayerMotionSource source = slot;
|
||||
var prior = new PlayerMovementController(new PhysicsEngine());
|
||||
var candidate = new PlayerMovementController(new PhysicsEngine());
|
||||
|
|
@ -71,7 +71,7 @@ public sealed class LocalPlayerControllerSlotTests
|
|||
[Fact]
|
||||
public void MotionPreparation_RejectsConcurrentCandidate()
|
||||
{
|
||||
var slot = new LocalPlayerControllerSlot();
|
||||
var slot = new RuntimeLocalPlayerMovementState();
|
||||
var first = new PlayerMovementController(new PhysicsEngine());
|
||||
var second = new PlayerMovementController(new PhysicsEngine());
|
||||
|
||||
|
|
@ -105,11 +105,10 @@ public sealed class ProjectileControllerTests
|
|||
LiveEntityRecord record = fixture.Spawn(instance: 1);
|
||||
WorldEntity entity = record.WorldEntity!;
|
||||
Assert.Null(record.AnimationRuntime);
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion();
|
||||
RemotePhysicsBodyInitializer.Initialize(remote.Body, record);
|
||||
var remote =
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid);
|
||||
remote.Body.Position = entity.Position;
|
||||
remote.Body.Orientation = entity.Rotation;
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, remote);
|
||||
Assert.True(fixture.Controller.TryBind(record, ProjectileSetup(), 1.0, 1, 1));
|
||||
Assert.Same(remote.Body, record.ProjectileRuntime!.Body);
|
||||
|
||||
|
|
@ -686,7 +685,9 @@ public sealed class ProjectileControllerTests
|
|||
LiveEntityRecord record = fixture.Spawn(instance: 1);
|
||||
Assert.True(fixture.Controller.TryBind(record, ProjectileSetup(), 1.0));
|
||||
PhysicsBody body = record.PhysicsBody!;
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, new AcDream.Runtime.Physics.RemoteMotion(body));
|
||||
Assert.Same(
|
||||
body,
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid).Body);
|
||||
record.FinalPhysicsState = PhysicsStateFlags.ReportCollisions;
|
||||
Assert.True(fixture.Controller.ApplyAuthoritativeState(
|
||||
record, record.FinalPhysicsState, 2.0, 1, 1));
|
||||
|
|
@ -710,7 +711,9 @@ public sealed class ProjectileControllerTests
|
|||
Assert.True(fixture.Controller.TryBind(record, ProjectileSetup(), 1.0));
|
||||
PhysicsBody body = record.PhysicsBody!;
|
||||
Vector3 position = body.Position;
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, new AcDream.Runtime.Physics.RemoteMotion(body));
|
||||
Assert.Same(
|
||||
body,
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid).Body);
|
||||
|
||||
record.FinalPhysicsState = PhysicsStateFlags.ReportCollisions;
|
||||
Assert.True(fixture.Controller.ApplyAuthoritativeState(
|
||||
|
|
@ -949,9 +952,8 @@ public sealed class ProjectileControllerTests
|
|||
var fixture = new Fixture();
|
||||
LiveEntityRecord record = fixture.Spawn(instance: 1);
|
||||
record.FinalPhysicsState = PhysicsStateFlags.ReportCollisions;
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion();
|
||||
RemotePhysicsBodyInitializer.Initialize(remote.Body, record);
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, remote);
|
||||
var remote =
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid);
|
||||
|
||||
PhysicsStateFlags ordinaryState =
|
||||
PhysicsStateFlags.Gravity | PhysicsStateFlags.IgnoreCollisions;
|
||||
|
|
@ -1001,9 +1003,8 @@ public sealed class ProjectileControllerTests
|
|||
var fixture = new Fixture();
|
||||
LiveEntityRecord record = fixture.Spawn(instance: 1);
|
||||
record.FinalPhysicsState = PhysicsStateFlags.ReportCollisions;
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion();
|
||||
RemotePhysicsBodyInitializer.Initialize(remote.Body, record);
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, remote);
|
||||
var remote =
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid);
|
||||
|
||||
record.FinalPhysicsState = MissileState;
|
||||
Assert.True(fixture.Controller.ApplyAuthoritativeState(
|
||||
|
|
@ -1073,15 +1074,14 @@ public sealed class ProjectileControllerTests
|
|||
seedCellId: startCell,
|
||||
isStatic: false);
|
||||
record.FinalPhysicsState = PhysicsStateFlags.ReportCollisions;
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion();
|
||||
RemotePhysicsBodyInitializer.Initialize(remote.Body, record);
|
||||
var remote =
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid);
|
||||
Assert.Equal(new Vector3(40f, 0f, 0f), remote.Body.Velocity);
|
||||
Assert.Equal(new Vector3(0f, 0f, 2f), remote.Body.Omega);
|
||||
remote.Body.set_velocity(new Vector3(8f, 0f, 0f));
|
||||
remote.Body.Omega = new Vector3(0f, 0f, 3f);
|
||||
remote.Body.Position = entity.Position;
|
||||
remote.Body.State = record.FinalPhysicsState;
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, remote);
|
||||
PhysicsBody body = remote.Body;
|
||||
|
||||
record.FinalPhysicsState = MissileState;
|
||||
|
|
@ -1139,11 +1139,10 @@ public sealed class ProjectileControllerTests
|
|||
velocity: new Vector3(float.NaN, 0f, 0f));
|
||||
WorldEntity entity = record.WorldEntity!;
|
||||
record.FinalPhysicsState = PhysicsStateFlags.ReportCollisions;
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion();
|
||||
RemotePhysicsBodyInitializer.Initialize(remote.Body, record);
|
||||
var remote =
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid);
|
||||
remote.Body.Position = entity.Position;
|
||||
remote.Body.Orientation = entity.Rotation;
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, remote);
|
||||
|
||||
Assert.True(float.IsNaN(record.Snapshot.Physics!.Value.Velocity!.Value.X));
|
||||
Assert.Equal(Vector3.Zero, remote.Body.Velocity);
|
||||
|
|
@ -1165,12 +1164,11 @@ public sealed class ProjectileControllerTests
|
|||
LiveEntityRecord record = fixture.Spawn(instance: 1);
|
||||
WorldEntity entity = record.WorldEntity!;
|
||||
record.FinalPhysicsState = PhysicsStateFlags.ReportCollisions;
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion();
|
||||
RemotePhysicsBodyInitializer.Initialize(remote.Body, record);
|
||||
var remote =
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid);
|
||||
remote.Body.Position = entity.Position;
|
||||
remote.Body.Orientation = entity.Rotation;
|
||||
remote.Body.Velocity = new Vector3(float.PositiveInfinity, 0f, 0f);
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, remote);
|
||||
|
||||
record.FinalPhysicsState = MissileState;
|
||||
Assert.True(fixture.Controller.ApplyAuthoritativeState(
|
||||
|
|
@ -1189,8 +1187,9 @@ public sealed class ProjectileControllerTests
|
|||
LiveEntityRecord record = fixture.Spawn(instance: 1);
|
||||
Assert.True(fixture.Controller.TryBind(record, ProjectileSetup(), 1.0));
|
||||
PhysicsBody body = record.PhysicsBody!;
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion(body);
|
||||
fixture.Live.SetRemoteMotionRuntime(Guid, remote);
|
||||
var remote =
|
||||
fixture.Live.GetOrCreateRemoteMotionRuntime(Guid);
|
||||
Assert.Same(body, remote.Body);
|
||||
|
||||
fixture.Live.RebucketLiveEntity(Guid, CellB);
|
||||
Assert.Equal(CellB, remote.CellId);
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ public sealed class RemoteTeleportControllerTests
|
|||
public void Unregister(WorldEntity entity) { }
|
||||
}
|
||||
|
||||
private sealed class BodyOnlyRemote(PhysicsBody body) : ILiveEntityRemoteMotionRuntime
|
||||
private sealed class BodyOnlyRemote(PhysicsBody body) : IRuntimeRemoteMotion
|
||||
{
|
||||
public PhysicsBody Body { get; } = body;
|
||||
}
|
||||
|
||||
private sealed class MutablePlacementRemote(PhysicsBody body) : ILiveEntityRemotePlacementRuntime
|
||||
private sealed class MutablePlacementRemote(PhysicsBody body) : IRuntimeRemotePlacement
|
||||
{
|
||||
private uint _cellId;
|
||||
private Func<uint>? _readCell;
|
||||
|
|
@ -56,7 +56,7 @@ public sealed class RemoteTeleportControllerTests
|
|||
|
||||
private sealed class AlternatingBodyRemote(
|
||||
PhysicsBody first,
|
||||
PhysicsBody later) : ILiveEntityRemotePlacementRuntime
|
||||
PhysicsBody later) : IRuntimeRemotePlacement
|
||||
{
|
||||
private int _reads;
|
||||
public PhysicsBody Body => _reads++ == 0 ? first : later;
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public sealed class WorldRenderFrameBuilderTests
|
|||
cells,
|
||||
mode,
|
||||
chase,
|
||||
new LocalPlayerControllerSlot(),
|
||||
new RuntimeLocalPlayerMovementState(),
|
||||
origin);
|
||||
var camera = new FlyCamera { Position = new Vector3(5f, 6f, 7f) };
|
||||
WorldCameraFrame cameraFrame = CameraFrame(camera);
|
||||
|
|
@ -227,7 +227,7 @@ public sealed class WorldRenderFrameBuilderTests
|
|||
new CellVisibility(),
|
||||
new LocalPlayerModeState(),
|
||||
new ChaseCameraInputState(),
|
||||
new LocalPlayerControllerSlot(),
|
||||
new RuntimeLocalPlayerMovementState(),
|
||||
new LiveWorldOriginState());
|
||||
WorldCameraFrame camera = CameraFrame(new FlyCamera());
|
||||
|
||||
|
|
|
|||
|
|
@ -827,7 +827,6 @@ public sealed class CurrentGameRuntimeAdapterTests
|
|||
Host,
|
||||
Commands,
|
||||
Identity,
|
||||
Entities,
|
||||
EntityObjects,
|
||||
InventoryState,
|
||||
Character,
|
||||
|
|
|
|||
|
|
@ -69,6 +69,13 @@ public sealed class RuntimePhysicsOwnershipTests
|
|||
runtimeRoot,
|
||||
"Physics",
|
||||
"RuntimePhysicsState.cs"));
|
||||
string app = string.Join(
|
||||
"\n",
|
||||
Directory.EnumerateFiles(
|
||||
appRoot,
|
||||
"*.cs",
|
||||
SearchOption.AllDirectories)
|
||||
.Select(File.ReadAllText));
|
||||
|
||||
Assert.DoesNotContain(
|
||||
"ResolveWithTransition(",
|
||||
|
|
@ -131,6 +138,67 @@ public sealed class RuntimePhysicsOwnershipTests
|
|||
"public bool TryGetPhysicsHost(",
|
||||
runtimePhysics,
|
||||
StringComparison.Ordinal);
|
||||
Assert.Contains(
|
||||
"GetOrCreateRemoteMotion(",
|
||||
runtimePhysics,
|
||||
StringComparison.Ordinal);
|
||||
Assert.Contains(
|
||||
"_physics.TryCommitAuthoritativeVector(",
|
||||
liveRuntime,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"TryActivateOrdinaryObject(",
|
||||
liveRuntime,
|
||||
StringComparison.Ordinal);
|
||||
Assert.Contains(
|
||||
"_entityObjects.CompleteProjectionRetirement(",
|
||||
liveRuntime,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"record.RemoteMotionRuntime =",
|
||||
liveRuntime,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"record.PhysicsBody =",
|
||||
liveRuntime,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"new RemoteMotion(",
|
||||
app,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"LiveEntityRemoteMotionRuntimeView",
|
||||
app,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"ILiveEntityRemoteMotionRuntime",
|
||||
app,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"ILiveEntityRemotePlacementRuntime",
|
||||
app,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"LocalPlayerControllerSlot",
|
||||
app,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"ILocalPlayerControllerSource",
|
||||
app,
|
||||
StringComparison.Ordinal);
|
||||
Assert.False(File.Exists(Path.Combine(
|
||||
appRoot,
|
||||
"Physics",
|
||||
"RemotePhysicsBodyInitializer.cs")));
|
||||
Assert.False(typeof(AcDream.App.World.LiveEntityRecord)
|
||||
.GetProperty(nameof(AcDream.App.World.LiveEntityRecord.PhysicsBody))!
|
||||
.CanWrite);
|
||||
Assert.False(typeof(AcDream.App.World.LiveEntityRecord)
|
||||
.GetProperty(nameof(AcDream.App.World.LiveEntityRecord.RemoteMotionRuntime))!
|
||||
.CanWrite);
|
||||
Assert.False(typeof(AcDream.App.World.LiveEntityRecord)
|
||||
.GetProperty(nameof(AcDream.App.World.LiveEntityRecord.PhysicsHost))!
|
||||
.CanWrite);
|
||||
}
|
||||
|
||||
private static string FindRepositoryRoot()
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ public sealed class LocalPlayerTeleportControllerTests
|
|||
MeshRefs = Array.Empty<MeshRef>(),
|
||||
})!;
|
||||
var identity = new LocalPlayerIdentityState { ServerGuid = guid };
|
||||
var controllerSlot = new LocalPlayerControllerSlot
|
||||
var controllerSlot = new RuntimeLocalPlayerMovementState
|
||||
{
|
||||
Controller = new PlayerMovementController(new PhysicsEngine()),
|
||||
};
|
||||
|
|
@ -494,7 +494,7 @@ public sealed class LocalPlayerTeleportControllerTests
|
|||
MeshRefs = Array.Empty<MeshRef>(),
|
||||
})!;
|
||||
var identity = new LocalPlayerIdentityState { ServerGuid = guid };
|
||||
var controllerSlot = new LocalPlayerControllerSlot
|
||||
var controllerSlot = new RuntimeLocalPlayerMovementState
|
||||
{
|
||||
Controller = new PlayerMovementController(new PhysicsEngine()),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ public sealed class StreamingFrameControllerTests
|
|||
}
|
||||
|
||||
internal LocalPlayerModeState Mode { get; } = new();
|
||||
internal LocalPlayerControllerSlot Player { get; } = new();
|
||||
internal RuntimeLocalPlayerMovementState Player { get; } = new();
|
||||
internal SessionSource Session { get; } = new();
|
||||
internal LiveWorldOriginState Origin { get; } = new();
|
||||
internal PlayerLandblockSource PlayerLandblock { get; } = new();
|
||||
|
|
|
|||
|
|
@ -144,12 +144,7 @@ public sealed class GameWindowLiveEntityCompositionTests
|
|||
typeof(LiveEntityAnimationRuntimeView<LiveEntityAnimationState>)
|
||||
.GetFields(BindingFlags.Instance | BindingFlags.NonPublic),
|
||||
field => field.Name == "_runtime");
|
||||
FieldInfo remoteRuntime = Assert.Single(
|
||||
typeof(LiveEntityRemoteMotionRuntimeView<RemoteMotion>)
|
||||
.GetFields(BindingFlags.Instance | BindingFlags.NonPublic),
|
||||
field => field.Name == "_runtime");
|
||||
Assert.Equal(typeof(ILiveEntityRuntimeSource), animationRuntime.FieldType);
|
||||
Assert.Equal(typeof(ILiveEntityRuntimeSource), remoteRuntime.FieldType);
|
||||
|
||||
FieldInfo[] projectileFields = typeof(ProjectileController).GetFields(
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
|
@ -192,7 +187,7 @@ public sealed class GameWindowLiveEntityCompositionTests
|
|||
source,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"new LiveEntityRemoteMotionRuntimeView<RemoteMotion>(() =>",
|
||||
"LiveEntityRemoteMotionRuntimeView",
|
||||
source,
|
||||
StringComparison.Ordinal);
|
||||
Assert.Contains("new DatProjectileSetupResolver", livePresentation);
|
||||
|
|
|
|||
|
|
@ -371,7 +371,11 @@ public sealed class LiveEntityHydrationControllerTests
|
|||
LiveEntityRecord record = fixture.Record;
|
||||
WorldEntity entity = record.WorldEntity!;
|
||||
var body = new PhysicsBody();
|
||||
record.PhysicsBody = body;
|
||||
Assert.Same(
|
||||
body,
|
||||
fixture.Runtime.GetOrCreatePhysicsBody(
|
||||
record.ServerGuid,
|
||||
_ => body));
|
||||
fixture.Relationships.OnUnparentAction = _ =>
|
||||
fixture.Runtime.WithdrawLiveEntityProjection(record)
|
||||
? ChildUnparentDisposition.Completed
|
||||
|
|
|
|||
|
|
@ -874,7 +874,7 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
_animations.TryGetValue(id, out Animation? animation) ? animation : null;
|
||||
}
|
||||
|
||||
private sealed class TestRemoteMotion : ILiveEntityRemotePlacementRuntime
|
||||
private sealed class TestRemoteMotion : IRuntimeRemotePlacement
|
||||
{
|
||||
private uint _cellId;
|
||||
private Func<uint>? _readCell;
|
||||
|
|
|
|||
|
|
@ -710,8 +710,8 @@ public sealed class LiveEntityPhysicsHostOwnershipTests
|
|||
interruptCurrentMovement);
|
||||
|
||||
private sealed class HostConsumerMotion :
|
||||
ILiveEntityRemoteMotionRuntime,
|
||||
ILiveEntityPhysicsHostConsumer
|
||||
IRuntimeRemoteMotion,
|
||||
IRuntimePhysicsHostConsumer
|
||||
{
|
||||
private Func<IPhysicsObjHost?>? _read;
|
||||
public PhysicsBody Body { get; } = new();
|
||||
|
|
@ -725,8 +725,8 @@ public sealed class LiveEntityPhysicsHostOwnershipTests
|
|||
}
|
||||
|
||||
private sealed class ThrowingCellConsumerMotion :
|
||||
ILiveEntityRemoteMotionRuntime,
|
||||
ILiveEntityCanonicalRuntimeConsumer
|
||||
IRuntimeRemoteMotion,
|
||||
IRuntimeCanonicalPhysicsConsumer
|
||||
{
|
||||
private bool _failOnce = true;
|
||||
public PhysicsBody Body { get; } = new();
|
||||
|
|
@ -748,14 +748,14 @@ public sealed class LiveEntityPhysicsHostOwnershipTests
|
|||
|
||||
private sealed class AlternatingBodyMotion(
|
||||
PhysicsBody first,
|
||||
PhysicsBody second) : ILiveEntityRemoteMotionRuntime
|
||||
PhysicsBody second) : IRuntimeRemoteMotion
|
||||
{
|
||||
private int _reads;
|
||||
public PhysicsBody Body => _reads++ == 0 ? first : second;
|
||||
}
|
||||
|
||||
private sealed class SequenceBodyMotion(params PhysicsBody[] bodies) :
|
||||
ILiveEntityRemoteMotionRuntime
|
||||
IRuntimeRemoteMotion
|
||||
{
|
||||
public int ReadCount { get; private set; }
|
||||
|
||||
|
|
@ -771,8 +771,8 @@ public sealed class LiveEntityPhysicsHostOwnershipTests
|
|||
}
|
||||
|
||||
private sealed class CallbackCanonicalMotion(Action callback) :
|
||||
ILiveEntityRemoteMotionRuntime,
|
||||
ILiveEntityCanonicalRuntimeConsumer
|
||||
IRuntimeRemoteMotion,
|
||||
IRuntimeCanonicalPhysicsConsumer
|
||||
{
|
||||
public PhysicsBody Body { get; } = new();
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public sealed class LiveEntityRuntimeTests
|
|||
|
||||
private sealed class EffectProfile : ILiveEntityEffectProfile { }
|
||||
|
||||
private sealed class RemoteMotionRuntime : ILiveEntityRemoteMotionRuntime
|
||||
private sealed class RemoteMotionRuntime : IRuntimeRemoteMotion
|
||||
{
|
||||
public PhysicsBody Body { get; } = new();
|
||||
}
|
||||
|
|
@ -1156,43 +1156,6 @@ public sealed class LiveEntityRuntimeTests
|
|||
Assert.False(remote.Body.TransientState.HasFlag(TransientStateFlags.Active));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MovementActivation_ReactivatesExactIncarnation_ButStaticIsNoOp()
|
||||
{
|
||||
const uint ordinaryGuid = 0x70000050u;
|
||||
const uint staticGuid = 0x70000051u;
|
||||
var spatial = new GpuWorldState();
|
||||
spatial.AddLandblock(EmptyLandblock(0x0101FFFFu));
|
||||
var runtime = LiveEntityRuntimeFixture.Create(spatial, new RecordingResources());
|
||||
|
||||
LiveEntityRecord ordinary = RegisterProjection(
|
||||
runtime,
|
||||
Spawn(ordinaryGuid, 1, 1, 0x01010001u));
|
||||
var ordinaryRemote = new RemoteMotionRuntime();
|
||||
runtime.SetRemoteMotionRuntime(ordinaryGuid, ordinaryRemote);
|
||||
ordinary.ObjectClock.Deactivate();
|
||||
ordinaryRemote.Body.TransientState &= ~TransientStateFlags.Active;
|
||||
|
||||
Assert.True(runtime.TryActivateOrdinaryObject(ordinaryGuid, ordinaryRemote));
|
||||
Assert.True(ordinary.ObjectClock.IsActive);
|
||||
Assert.True(ordinaryRemote.Body.TransientState.HasFlag(TransientStateFlags.Active));
|
||||
|
||||
LiveEntityRecord staticRecord = RegisterProjection(
|
||||
runtime,
|
||||
Spawn(
|
||||
staticGuid,
|
||||
1,
|
||||
1,
|
||||
0x01010001u,
|
||||
PhysicsStateFlags.Static));
|
||||
var staticRemote = new RemoteMotionRuntime();
|
||||
runtime.SetRemoteMotionRuntime(staticGuid, staticRemote);
|
||||
|
||||
Assert.False(runtime.TryActivateOrdinaryObject(staticGuid, staticRemote));
|
||||
Assert.False(staticRecord.ObjectClock.IsActive);
|
||||
Assert.False(staticRemote.Body.TransientState.HasFlag(TransientStateFlags.Active));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AuthoritativeVector_WakesOrdinaryClockButPreservesStaticActivity()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -244,6 +244,10 @@ public sealed class RuntimeEntityOwnershipTests
|
|||
Assert.Contains(
|
||||
viewFields,
|
||||
field => field.FieldType == typeof(IRuntimeInventoryView));
|
||||
Assert.DoesNotContain(
|
||||
viewFields,
|
||||
field => field.FieldType == typeof(LiveEntityRuntime)
|
||||
|| field.FieldType == typeof(ClientObjectTable));
|
||||
Assert.DoesNotContain(
|
||||
typeof(CurrentGameRuntimeViewAdapter).GetNestedTypes(
|
||||
BindingFlags.NonPublic),
|
||||
|
|
@ -271,6 +275,21 @@ public sealed class RuntimeEntityOwnershipTests
|
|||
Assert.DoesNotContain("_entityObjects.PublishEntity", liveSource);
|
||||
Assert.DoesNotContain("_directory.TryApply", liveSource);
|
||||
Assert.DoesNotContain("_directory.RemoveActive", liveSource);
|
||||
|
||||
string viewSource = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"src",
|
||||
"AcDream.App",
|
||||
"Runtime",
|
||||
"CurrentGameRuntimeViewAdapter.cs"));
|
||||
Assert.Contains(
|
||||
"_entityView.MaterializedCount",
|
||||
viewSource,
|
||||
StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(
|
||||
"_entities.MaterializedCount",
|
||||
viewSource,
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static bool IsPresentationType(Type type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue