Member-wise deletion of the three legacy resolver members named in docs/research/2026-08-05-c5a-contract.md: PhysicsEngine.Resolve, PhysicsEngine.HasCellSurface, and PhysicsEngine.ResolvePlacement. An exhaustive receiver census over src/ found zero production callers of any of the three — every production placement writer already reaches the canonical PhysicsEngine.SetPosition transaction exclusively through RuntimeSetPositionState (three call sites total). The deletion is purely member-wise: IsSpawnCellReady and AdjustPosition, which shared the same source region as the deleted members, are preserved byte-identical — every remaining production caller of either (including PhysicsCameraCollisionProbe, AdjustPosition's sole surviving production caller) is unaffected. Companion changes: - PlayerMovementController's 3-argument SetPosition test overload is renamed to SeedPlacementForTest (internal) and CommitPreparedPosition is deleted; 83 call sites across 19 test files were mechanically renamed to match. - Seven pinned test dispositions from the contract are executed: 3.1 (PhysicsEngineTests.cs: 11 legacy-resolver tests deleted, 6 ResolveWithTransition tests kept), 3.2/3.3/3.4 (re-point to canonical SetPosition, with TransitionScratchDifferentialTests.cs additionally gaining positive IsCommitted assertions after each bitwise comparison so the differential proves a placement actually committed, not just that two possibly-uncommitted results match), 3.5 (Runtime rename), and 3.6 (PlayerMovementPlacementTransactionTests.cs rewritten — its xmldoc now states plainly that the render-root publish moved to RuntimeSetPositionState.cs, but the sticky-release relocation claim was false and is retracted; this disposition's coverage loss is the sticky release path, not silently absorbed elsewhere). - Stale `PhysicsEngine.Resolve`/`Resolve` doc citations in CellTransit.cs, PlayerMovementController.cs, and HeadlessSessionWorldProjection.cs are corrected to name the surviving canonical entry points by symbol (SetPosition, AdjustSetPosition/AdjustPosition, ResolveWithTransition) rather than fragile line numbers. Retires AP-1 and AD-1 in docs/architecture/retail-divergence-register.md: both rows described production zero-delta placement routing remaining on the legacy resolver pending the Slice 4B2/4B route cutover; that resolver no longer exists, so the condition each row tracked is now structurally false rather than merely narrowed. AP-145 (routed through the prior commit) and this commit's AP-1/AD-1 together bring the section counts to 101 AP / 47 AD active rows. Builds on the AP-145 fix (previous commit) — this commit's staged tree was independently rebuilt and its four suites independently rerun on top of that commit before this commit was created, in addition to the combined rebuild/rerun below. Full-solution build: 0 errors (21 pre-existing warnings, all unrelated). Suite results (combined tree): Core 4270/4271 passed (1 skip; the single DatSoundCacheTests concurrent-decode-dedup failure is a known load-sensitive race, confirmed passing standalone and unrelated to this change), Runtime 1176/1176, Headless 86/86, App 4132/4135 (3 skips). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
559 lines
19 KiB
C#
559 lines
19 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Input;
|
|
using AcDream.App.Net;
|
|
using AcDream.App.Physics;
|
|
using AcDream.App.Streaming;
|
|
using AcDream.App.World;
|
|
using AcDream.Core.Net;
|
|
using AcDream.Core.Net.Messages;
|
|
using AcDream.Core.Physics;
|
|
using AcDream.Core.Terrain;
|
|
using AcDream.Core.World;
|
|
using AcDream.Core.World.Cells;
|
|
using DatReaderWriter.DBObjs;
|
|
|
|
namespace AcDream.App.Tests.Streaming;
|
|
|
|
public sealed class StreamingFrameControllerTests
|
|
{
|
|
[Fact]
|
|
public void LivePreLogin_AdvancesOriginConvergenceButSuppressesStreaming()
|
|
{
|
|
var fixture = new Fixture(liveMode: true);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal(1, fixture.Convergence.Advances);
|
|
Assert.Empty(fixture.Streaming.Calls);
|
|
Assert.Equal(0, fixture.Dungeon.Captures);
|
|
Assert.Empty(fixture.Rescues.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void LiveInWorldWithoutAuthoritativeOrigin_RemainsGated()
|
|
{
|
|
var fixture = new Fixture(liveMode: true);
|
|
fixture.Session.IsInWorld = true;
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal(1, fixture.Convergence.Advances);
|
|
Assert.Empty(fixture.Streaming.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void ChaseLifetimeAfterEntry_AllowsConvergenceWithNoCurrentSession()
|
|
{
|
|
var fixture = new Fixture(liveMode: true);
|
|
fixture.Mode.ChaseModeEverEntered = true;
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(10, 20, false)], fixture.Streaming.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void ConvergenceCompletesBeforeObserverSelection()
|
|
{
|
|
var fixture = new Fixture();
|
|
fixture.Convergence.OnAdvance = () => fixture.Origin.Recenter(30, 40);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(30, 40, false)], fixture.Streaming.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void PendingConvergence_StillTicksBackendBeforeRescueSoBackendOwnsItsGate()
|
|
{
|
|
var calls = new List<string>();
|
|
var fixture = new Fixture();
|
|
fixture.Convergence.AdvanceResult = false;
|
|
fixture.Streaming.OnTick = (_, _, _) => calls.Add("backend");
|
|
fixture.Rescues.OnRebucket = (_, _) => calls.Add("rescues");
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal(["backend", "rescues"], calls);
|
|
Assert.Equal([(10, 20, false)], fixture.Streaming.Calls);
|
|
Assert.Equal([(10, 20)], fixture.Rescues.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void LivePrePlayerMode_UsesAuthoritativePlayerLandblock()
|
|
{
|
|
var fixture = new Fixture(liveMode: true, initializeOrigin: true);
|
|
fixture.Session.IsInWorld = true;
|
|
fixture.PlayerLandblock.LastKnownLandblockId = 0xA1B20001u;
|
|
fixture.Offline.Position = new Vector3(9000f, 9000f, 0f);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(0xA1, 0xB2, false)], fixture.Streaming.Calls);
|
|
Assert.Equal(0, fixture.Offline.Reads);
|
|
}
|
|
|
|
[Fact]
|
|
public void LivePrePlayerModeWithoutPositionHint_StaysOnAcceptedOrigin()
|
|
{
|
|
var fixture = new Fixture(liveMode: true, initializeOrigin: true);
|
|
fixture.Session.IsInWorld = true;
|
|
fixture.Offline.Position = new Vector3(9000f, 9000f, 0f);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(10, 20, false)], fixture.Streaming.Calls);
|
|
Assert.Equal(0, fixture.Offline.Reads);
|
|
}
|
|
|
|
[Fact]
|
|
public void PlayerModeWithoutController_InWorldStillUsesAuthoritativePlayerHint()
|
|
{
|
|
var fixture = new Fixture(liveMode: true, initializeOrigin: true);
|
|
fixture.Mode.IsPlayerMode = true;
|
|
fixture.Session.IsInWorld = true;
|
|
fixture.PlayerLandblock.LastKnownLandblockId = 0xC95B0001u;
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(0xC9, 0x5B, false)], fixture.Streaming.Calls);
|
|
Assert.Equal(0, fixture.Offline.Reads);
|
|
}
|
|
|
|
[Fact]
|
|
public void PlayerModeWithoutController_OfflineFallsBackToFlyObserver()
|
|
{
|
|
var fixture = new Fixture();
|
|
fixture.Mode.IsPlayerMode = true;
|
|
fixture.Offline.Position = new Vector3(192f, 384f, 0f);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(11, 22, false)], fixture.Streaming.Calls);
|
|
Assert.Equal(1, fixture.Offline.Reads);
|
|
}
|
|
|
|
[Fact]
|
|
public void PlayerMode_UsesPhysicsResolvedPositionIncludingNegativeFloor()
|
|
{
|
|
var fixture = new Fixture(initializeOrigin: true);
|
|
fixture.Mode.IsPlayerMode = true;
|
|
var player = new PlayerMovementController(new PhysicsEngine());
|
|
player.SeedPlacementForTest(
|
|
new Vector3(383f, -0.01f, 0f),
|
|
0x0A140001u,
|
|
new Vector3(1f, 1f, 0f));
|
|
fixture.Player.Controller = player;
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(11, 19, false)], fixture.Streaming.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void PortalSpace_PinsDestinationOriginAndSuppressesFrozenSourceDungeon()
|
|
{
|
|
var fixture = new Fixture(initializeOrigin: true);
|
|
fixture.Mode.IsPlayerMode = true;
|
|
var player = new PlayerMovementController(new PhysicsEngine())
|
|
{
|
|
State = PlayerState.PortalSpace,
|
|
};
|
|
player.SeedPlacementForTest(
|
|
new Vector3(1000f, -1000f, 0f),
|
|
0x0A140001u,
|
|
new Vector3(1f, 1f, 0f));
|
|
fixture.Player.Controller = player;
|
|
fixture.Dungeon.Snapshot = new StreamingDungeonCellSnapshot(
|
|
0xAABB0001u,
|
|
IsSealedDungeon: true);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(10, 20, false)], fixture.Streaming.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void SealedDungeon_PinsObserverToCurrentCellsOwnLandblock()
|
|
{
|
|
var fixture = new Fixture(initializeOrigin: true);
|
|
fixture.Mode.IsPlayerMode = true;
|
|
var player = new PlayerMovementController(new PhysicsEngine());
|
|
player.SeedPlacementForTest(
|
|
new Vector3(1000f, -1000f, 0f),
|
|
0x0A140001u,
|
|
new Vector3(1f, 1f, 0f));
|
|
fixture.Player.Controller = player;
|
|
fixture.Dungeon.Snapshot = new StreamingDungeonCellSnapshot(
|
|
0xAABB0001u,
|
|
IsSealedDungeon: true);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(0xAA, 0xBB, true)], fixture.Streaming.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void OfflineMode_UsesFlyCameraRelativeToPlaceholderOrigin()
|
|
{
|
|
var fixture = new Fixture();
|
|
fixture.Offline.Position = new Vector3(384f, -0.01f, 0f);
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal([(12, 19, false)], fixture.Streaming.Calls);
|
|
Assert.Equal(1, fixture.Offline.Reads);
|
|
}
|
|
|
|
[Fact]
|
|
public void StreamingBackendTickPrecedesRescueRebucketAtSameObserver()
|
|
{
|
|
var calls = new List<string>();
|
|
var fixture = new Fixture();
|
|
fixture.Streaming.OnTick = (_, _, _) => calls.Add("streaming");
|
|
fixture.Rescues.OnRebucket = (_, _) => calls.Add("rescues");
|
|
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal(["streaming", "rescues"], calls);
|
|
Assert.Equal([(10, 20)], fixture.Rescues.Calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void PhysicsDungeonCellSource_MapsMissingOutdoorAndSealedCells()
|
|
{
|
|
var physics = new PhysicsEngine
|
|
{
|
|
DataCache = new PhysicsDataCache(),
|
|
};
|
|
var source = new PhysicsStreamingDungeonCellSource(physics);
|
|
|
|
Assert.Equal(default, source.Capture());
|
|
|
|
var heights = new byte[81];
|
|
var heightTable = new float[256];
|
|
physics.DataCache.CellGraph.RegisterTerrain(
|
|
0xAABB0000u,
|
|
new TerrainSurface(heights, heightTable),
|
|
Vector3.Zero);
|
|
physics.UpdatePlayerCurrCell(0xAABB0001u);
|
|
|
|
Assert.Equal(
|
|
new StreamingDungeonCellSnapshot(0xAABB0001u, IsSealedDungeon: false),
|
|
source.Capture());
|
|
|
|
var outsideVisibleCell = new AcDream.Core.World.Cells.EnvCell(
|
|
0xCCDD0100u,
|
|
Matrix4x4.Identity,
|
|
Matrix4x4.Identity,
|
|
Vector3.Zero,
|
|
Vector3.One,
|
|
Array.Empty<CellPortal>(),
|
|
Array.Empty<uint>(),
|
|
seenOutside: true,
|
|
containmentBsp: null);
|
|
physics.DataCache.CellGraph.Add(outsideVisibleCell);
|
|
physics.UpdatePlayerCurrCell(outsideVisibleCell.Id);
|
|
|
|
Assert.Equal(
|
|
new StreamingDungeonCellSnapshot(
|
|
outsideVisibleCell.Id,
|
|
IsSealedDungeon: false),
|
|
source.Capture());
|
|
|
|
var sealedCell = new AcDream.Core.World.Cells.EnvCell(
|
|
0xCCDD0101u,
|
|
Matrix4x4.Identity,
|
|
Matrix4x4.Identity,
|
|
Vector3.Zero,
|
|
Vector3.One,
|
|
Array.Empty<CellPortal>(),
|
|
Array.Empty<uint>(),
|
|
seenOutside: false,
|
|
containmentBsp: null);
|
|
physics.DataCache.CellGraph.Add(sealedCell);
|
|
physics.UpdatePlayerCurrCell(sealedCell.Id);
|
|
|
|
Assert.Equal(
|
|
new StreamingDungeonCellSnapshot(sealedCell.Id, IsSealedDungeon: true),
|
|
source.Capture());
|
|
}
|
|
|
|
[Fact]
|
|
public void LiveProjectionRescueRebucketter_RebucketsIntoExactObserverLandblock()
|
|
{
|
|
const uint guid = 0x50000031u;
|
|
const uint sourceLandblock = 0x0101FFFFu;
|
|
const uint sourceCell = 0x01010001u;
|
|
var state = new GpuWorldState();
|
|
state.AddLandblock(EmptyLandblock(sourceLandblock));
|
|
var runtime = Runtime(state);
|
|
runtime.RegisterLiveEntity(Spawn(guid, sourceCell));
|
|
WorldEntity entity = runtime.MaterializeLiveEntity(
|
|
guid,
|
|
sourceCell,
|
|
id => Entity(id, guid))!;
|
|
state.MarkPersistent(guid);
|
|
state.RemoveLandblock(sourceLandblock);
|
|
Assert.Equal(1, state.PendingRescueCount);
|
|
|
|
new LiveProjectionRescueRebucketter(state, runtime).RebucketAll(0xAA, 0xBB);
|
|
|
|
Assert.True(runtime.TryGetRecord(guid, out LiveEntityRecord record));
|
|
Assert.Same(entity, record.WorldEntity);
|
|
Assert.Equal(0xAABBFFFFu, record.CanonicalLandblockId);
|
|
Assert.Equal(0, state.PendingRescueCount);
|
|
Assert.Equal(1, state.PendingLiveEntityCount);
|
|
}
|
|
|
|
[Fact]
|
|
public void LiveProjectionRescueRebucketter_IgnoresEmptyAndDeletedRescues()
|
|
{
|
|
const uint guid = 0x50000032u;
|
|
const uint sourceLandblock = 0x0101FFFFu;
|
|
const uint sourceCell = 0x01010001u;
|
|
var state = new GpuWorldState();
|
|
var runtime = Runtime(state);
|
|
var adapter = new LiveProjectionRescueRebucketter(state, runtime);
|
|
|
|
adapter.RebucketAll(0xAA, 0xBB);
|
|
Assert.Equal(0, state.PendingLiveEntityCount);
|
|
|
|
state.AddLandblock(EmptyLandblock(sourceLandblock));
|
|
runtime.RegisterLiveEntity(Spawn(guid, sourceCell));
|
|
runtime.MaterializeLiveEntity(guid, sourceCell, id => Entity(id, guid));
|
|
state.MarkPersistent(guid);
|
|
state.RemoveLandblock(sourceLandblock);
|
|
Assert.Equal(1, state.PendingRescueCount);
|
|
runtime.UnregisterLiveEntity(
|
|
new DeleteObject.Parsed(guid, InstanceSequence: 1),
|
|
isLocalPlayer: false);
|
|
|
|
adapter.RebucketAll(0xAA, 0xBB);
|
|
|
|
Assert.Equal(0, state.PendingRescueCount);
|
|
Assert.Equal(0, state.PendingLiveEntityCount);
|
|
Assert.Empty(state.Entities);
|
|
}
|
|
|
|
[Fact]
|
|
public void CompletedStreamingPublicationMakesInboundProjectionResident()
|
|
{
|
|
const uint landblock = 0x0A14FFFFu;
|
|
const uint cell = 0x0A140001u;
|
|
const uint guid = 0x70000041u;
|
|
var state = new GpuWorldState();
|
|
var outbox = new Queue<LandblockStreamResult>();
|
|
outbox.Enqueue(new LandblockStreamResult.Loaded(
|
|
landblock,
|
|
LandblockStreamTier.Near,
|
|
EmptyLandblock(landblock),
|
|
new LandblockMeshData(Array.Empty<TerrainVertex>(), Array.Empty<uint>())));
|
|
var streaming = new StreamingController(
|
|
enqueueLoad: static (_, _) => { },
|
|
enqueueUnload: static _ => { },
|
|
drainCompletions: max => Drain(outbox, max),
|
|
applyTerrain: static (_, _) => { },
|
|
state,
|
|
nearRadius: 0,
|
|
farRadius: 0);
|
|
var fixture = new Fixture(streamingBackend: streaming);
|
|
|
|
for (int frame = 0; frame < 32 && !state.IsLoaded(landblock); frame++)
|
|
fixture.Controller.Tick();
|
|
Assert.True(state.IsLoaded(landblock));
|
|
|
|
var runtime = Runtime(state);
|
|
runtime.RegisterLiveEntity(Spawn(guid, cell));
|
|
WorldEntity entity = runtime.MaterializeLiveEntity(
|
|
guid,
|
|
cell,
|
|
id => Entity(id, guid))!;
|
|
|
|
Assert.Same(entity, Assert.Single(state.Entities));
|
|
Assert.Equal(0, state.PendingLiveEntityCount);
|
|
}
|
|
|
|
[Fact]
|
|
public void SessionResetClosesChaseLifetimeOriginAndPlayerHintBeforeNextTick()
|
|
{
|
|
var fixture = new Fixture(liveMode: true, initializeOrigin: true);
|
|
fixture.Mode.IsPlayerMode = true;
|
|
fixture.Mode.ChaseModeEverEntered = true;
|
|
fixture.Session.IsInWorld = true;
|
|
fixture.PlayerLandblock.LastKnownLandblockId = 0xAABB0001u;
|
|
|
|
fixture.Mode.ResetSession();
|
|
fixture.Origin.Reset();
|
|
fixture.Session.IsInWorld = false;
|
|
fixture.PlayerLandblock.LastKnownLandblockId = null;
|
|
fixture.Controller.Tick();
|
|
|
|
Assert.Equal(1, fixture.Convergence.Advances);
|
|
Assert.Empty(fixture.Streaming.Calls);
|
|
Assert.Empty(fixture.Rescues.Calls);
|
|
Assert.False(fixture.Mode.IsPlayerMode);
|
|
Assert.False(fixture.Mode.ChaseModeEverEntered);
|
|
Assert.False(fixture.Origin.IsKnown);
|
|
}
|
|
|
|
private sealed class Fixture
|
|
{
|
|
internal Fixture(
|
|
bool liveMode = false,
|
|
bool initializeOrigin = false,
|
|
IStreamingFrameBackend? streamingBackend = null)
|
|
{
|
|
Origin.SetPlaceholder(10, 20);
|
|
if (initializeOrigin)
|
|
Assert.True(Origin.TryInitialize(10, 20));
|
|
Controller = new StreamingFrameController(
|
|
liveMode,
|
|
Mode,
|
|
Player,
|
|
Session,
|
|
Origin,
|
|
PlayerLandblock,
|
|
Offline,
|
|
Dungeon,
|
|
Convergence,
|
|
streamingBackend ?? Streaming,
|
|
Rescues);
|
|
}
|
|
|
|
internal LocalPlayerModeState Mode { get; } = new();
|
|
internal RuntimeLocalPlayerMovementState Player { get; } = new();
|
|
internal SessionSource Session { get; } = new();
|
|
internal LiveWorldOriginState Origin { get; } = new();
|
|
internal PlayerLandblockSource PlayerLandblock { get; } = new();
|
|
internal OfflineObserverSource Offline { get; } = new();
|
|
internal DungeonCellSource Dungeon { get; } = new();
|
|
internal OriginConvergence Convergence { get; } = new();
|
|
internal StreamingBackend Streaming { get; } = new();
|
|
internal RescueRebucketter Rescues { get; } = new();
|
|
internal StreamingFrameController Controller { get; }
|
|
}
|
|
|
|
private sealed class SessionSource : ILiveInWorldSource
|
|
{
|
|
public bool IsInWorld { get; set; }
|
|
}
|
|
|
|
private sealed class PlayerLandblockSource : ILocalPlayerLandblockSource
|
|
{
|
|
public uint? LastKnownLandblockId { get; set; }
|
|
}
|
|
|
|
private sealed class OfflineObserverSource : IOfflineStreamingObserverSource
|
|
{
|
|
private Vector3 _position;
|
|
internal int Reads { get; private set; }
|
|
public Vector3 Position
|
|
{
|
|
get
|
|
{
|
|
Reads++;
|
|
return _position;
|
|
}
|
|
set => _position = value;
|
|
}
|
|
}
|
|
|
|
private sealed class DungeonCellSource : IStreamingDungeonCellSource
|
|
{
|
|
internal int Captures { get; private set; }
|
|
internal StreamingDungeonCellSnapshot Snapshot { get; set; }
|
|
public StreamingDungeonCellSnapshot Capture()
|
|
{
|
|
Captures++;
|
|
return Snapshot;
|
|
}
|
|
}
|
|
|
|
private sealed class OriginConvergence : IStreamingOriginConvergence
|
|
{
|
|
internal int Advances { get; private set; }
|
|
internal Action? OnAdvance { get; set; }
|
|
internal bool AdvanceResult { get; set; } = true;
|
|
public bool Advance()
|
|
{
|
|
Advances++;
|
|
OnAdvance?.Invoke();
|
|
return AdvanceResult;
|
|
}
|
|
}
|
|
|
|
private sealed class StreamingBackend : IStreamingFrameBackend
|
|
{
|
|
internal List<(int X, int Y, bool Dungeon)> Calls { get; } = [];
|
|
internal Action<int, int, bool>? OnTick { get; set; }
|
|
public void Tick(int observerCx, int observerCy, bool insideDungeon = false)
|
|
{
|
|
Calls.Add((observerCx, observerCy, insideDungeon));
|
|
OnTick?.Invoke(observerCx, observerCy, insideDungeon);
|
|
}
|
|
}
|
|
|
|
private sealed class RescueRebucketter : ILiveProjectionRescueRebucketter
|
|
{
|
|
internal List<(int X, int Y)> Calls { get; } = [];
|
|
internal Action<int, int>? OnRebucket { get; set; }
|
|
public void RebucketAll(int observerCx, int observerCy)
|
|
{
|
|
Calls.Add((observerCx, observerCy));
|
|
OnRebucket?.Invoke(observerCx, observerCy);
|
|
}
|
|
}
|
|
|
|
private static LiveEntityRuntime Runtime(GpuWorldState state) =>
|
|
LiveEntityRuntimeFixture.Create(
|
|
state,
|
|
new DelegateLiveEntityResourceLifecycle(_ => { }, _ => { }));
|
|
|
|
private static LoadedLandblock EmptyLandblock(uint landblock) =>
|
|
new(landblock, new LandBlock(), Array.Empty<WorldEntity>());
|
|
|
|
private static WorldEntity Entity(uint id, uint guid) => new()
|
|
{
|
|
Id = id,
|
|
ServerGuid = guid,
|
|
SourceGfxObjOrSetupId = 0x02000001u,
|
|
Position = Vector3.Zero,
|
|
Rotation = Quaternion.Identity,
|
|
MeshRefs = Array.Empty<MeshRef>(),
|
|
};
|
|
|
|
private static WorldSession.EntitySpawn Spawn(uint guid, uint cell)
|
|
{
|
|
var position = new CreateObject.ServerPosition(
|
|
cell, 10f, 10f, 5f, 1f, 0f, 0f, 0f);
|
|
return new WorldSession.EntitySpawn(
|
|
guid,
|
|
position,
|
|
0x02000001u,
|
|
Array.Empty<CreateObject.AnimPartChange>(),
|
|
Array.Empty<CreateObject.TextureChange>(),
|
|
Array.Empty<CreateObject.SubPaletteSwap>(),
|
|
BasePaletteId: null,
|
|
ObjScale: null,
|
|
Name: "streaming frame fixture",
|
|
ItemType: null,
|
|
MotionState: null,
|
|
MotionTableId: null,
|
|
PhysicsState: (uint)PhysicsStateFlags.ReportCollisions,
|
|
InstanceSequence: 1,
|
|
MovementSequence: 1,
|
|
ServerControlSequence: 1,
|
|
PositionSequence: 1).WithConsistentPhysics();
|
|
}
|
|
|
|
private static IReadOnlyList<LandblockStreamResult> Drain(
|
|
Queue<LandblockStreamResult> queue,
|
|
int max)
|
|
{
|
|
var drained = new List<LandblockStreamResult>(max);
|
|
while (drained.Count < max && queue.TryDequeue(out LandblockStreamResult? result))
|
|
drained.Add(result);
|
|
return drained;
|
|
}
|
|
}
|