The ImGui developer-tools stack (AcDream.UI.ImGui), UI Studio (src/AcDream.App/Studio), and the DevToolsFramePresenter/ SettingsDevToolsCompositionPhase ImGui composition machinery are removed. Vulkan never composed a DevTools frontend (DevToolsEnabled already forced false whenever the backend was Vulkan); this commit makes that permanent by deleting the only implementation rather than leaving a dead branch behind. What moved: Studio/SampleData.cs is a live production dependency (InteractionRetainedUiComposition's character-sheet fallback, plus three UI.Layout test files) - git mv'd to src/AcDream.App/UI/Layout/SampleData.cs, namespace AcDream.App.UI.Layout, and trimmed to the SampleCharacter API that is actually still called (BuildObjectTable/AddItem/AddEquipped/the item-guid and icon constants had zero callers left once the Studio fixture provider that used them was deleted). What survives as backend-neutral seams, per the tests that still exercise them: IDevToolsFrameLifecycle (moved into RenderFramePreparationController.cs, now always bound to null), IFramebufferDevToolsTarget/FramebufferDevToolsBinding in FramebufferResizeController.cs (its concrete DevToolsFramebufferTarget adapter is deleted), and IDevToolsGameplayCommands in GameplayInputCommandController.cs (DevToolsGameplayCommands becomes a documented no-op instead of forwarding to the deleted presenter). A follow-up re-homes Settings/Debug onto the retained UI through IPanelRenderer; until then keybind remapping falls back to editing keybinds.json. DevToolsEnabled is now `private const bool DevToolsEnabled = false`. RuntimeOptions.DevTools is unchanged and still reaches VulkanGraphicsContext for the optional debug-utils extensions; Program.cs now logs one line when ACDREAM_DEVTOOLS=1 explaining that the ImGui UI is gone and the flag is Vulkan-only now. Removed: AcDream.UI.ImGui (project + ImGui.NET/Silk.NET.OpenGL.Extensions.ImGui package refs), src/AcDream.App/Studio (minus SampleData.cs), DevToolsFramePresenter.cs and everything only it constructed (ISettingsDevToolsCompositionFactory, RetailSettingsDevToolsCompositionFactory, DevToolsCompositionOwner, IGameWindowSettingsDevToolsPublication, SettingsDevToolsOptionalDependencies, the "developer tools" shutdown-ledger stage and its DevTools-typed fields on IngressShutdownRoots/ RenderShutdownRoots), the ui-studio Program.cs verb, and the cimgui native manifest entries in GraphicalHostPlatformServices. GameWindow.cs's DevTools composition branch, its _vitalsVm/_debugVm/_devToolsComposition/ _devToolsFramePresenter/_devToolsCommandBus fields, and every settingsDevTools .DevTools?.* access across FrameRootComposition.cs/SessionPlayerComposition.cs are gone with it. Build green; complete Release solution suite 8,830 / 5 skips (App Tests 4,097/3 skips run standalone - one #250-family zero-allocation test flakes under the full parallel `dotnet test AcDream.slnx` run, a pre-existing, documented class unrelated to this change). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
230 lines
8.6 KiB
C#
230 lines
8.6 KiB
C#
using AcDream.Core.Net;
|
|
using AcDream.Core.Net.Messages;
|
|
using AcDream.Core.Physics;
|
|
using AcDream.Runtime.Entities;
|
|
|
|
namespace AcDream.Runtime.Tests.Entities;
|
|
|
|
public sealed class RuntimeEntityDirectoryTests
|
|
{
|
|
[Fact]
|
|
public void AddActive_OwnsOneCurrentIncarnationPerGuid()
|
|
{
|
|
var directory = new RuntimeEntityDirectory();
|
|
RuntimeEntityRecord first = directory.AddActive(Spawn(0x70000001u, 1));
|
|
|
|
Assert.True(directory.TryGetActive(first.ServerGuid, out RuntimeEntityRecord found));
|
|
Assert.Same(first, found);
|
|
Assert.True(directory.IsCurrent(first));
|
|
Assert.Throws<InvalidOperationException>(
|
|
() => directory.AddActive(Spawn(first.ServerGuid, 2)));
|
|
}
|
|
|
|
[Fact]
|
|
public void RemoveAndRetainTombstone_AllowsReplacementWithoutLosingExactOldIncarnation()
|
|
{
|
|
var directory = new RuntimeEntityDirectory();
|
|
RuntimeEntityRecord old = directory.AddActive(Spawn(0x70000002u, 7));
|
|
|
|
Assert.True(directory.RemoveActive(old.ServerGuid, out RuntimeEntityRecord? removed));
|
|
Assert.Same(old, removed);
|
|
directory.RetainTeardown(old);
|
|
RuntimeEntityRecord replacement = directory.AddActive(Spawn(old.ServerGuid, 8));
|
|
|
|
Assert.True(directory.TryGetActive(old.ServerGuid, out RuntimeEntityRecord current));
|
|
Assert.Same(replacement, current);
|
|
Assert.True(directory.TryGetTeardown(old.ServerGuid, 7, out RuntimeEntityRecord tombstone));
|
|
Assert.Same(old, tombstone);
|
|
Assert.False(directory.IsCurrent(old));
|
|
Assert.True(directory.IsCurrent(replacement));
|
|
}
|
|
|
|
[Fact]
|
|
public void LocalIdentity_IsOwnedByDirectoryAndReverseLookupRejectsReleasedIncarnation()
|
|
{
|
|
var directory = new RuntimeEntityDirectory();
|
|
RuntimeEntityRecord old = directory.AddActive(Spawn(0x70000003u, 1));
|
|
uint oldLocalId = directory.ClaimLocalId(old);
|
|
Assert.True(directory.TryGetByLocalId(oldLocalId, out RuntimeEntityRecord foundOld));
|
|
Assert.Same(old, foundOld);
|
|
|
|
Assert.True(directory.RemoveActive(old.ServerGuid, out _));
|
|
directory.RetainTeardown(old);
|
|
RuntimeEntityRecord replacement = directory.AddActive(Spawn(old.ServerGuid, 2));
|
|
uint replacementLocalId = directory.ClaimLocalId(replacement);
|
|
|
|
Assert.NotEqual(oldLocalId, replacementLocalId);
|
|
Assert.True(directory.ReleaseLocalId(old));
|
|
Assert.False(directory.TryGetByLocalId(oldLocalId, out _));
|
|
Assert.True(directory.TryGetByLocalId(
|
|
replacementLocalId,
|
|
out RuntimeEntityRecord foundReplacement));
|
|
Assert.Same(replacement, foundReplacement);
|
|
}
|
|
|
|
[Fact]
|
|
public void LocalIdentity_WrapsWithinReservedNamespaceWithoutCollision()
|
|
{
|
|
var directory = new RuntimeEntityDirectory(RuntimeEntityDirectory.LastLocalEntityId);
|
|
RuntimeEntityRecord first = directory.AddActive(Spawn(0x70000004u, 1));
|
|
RuntimeEntityRecord second = directory.AddActive(Spawn(0x70000005u, 1));
|
|
|
|
Assert.Equal(
|
|
RuntimeEntityDirectory.LastLocalEntityId,
|
|
directory.ClaimLocalId(first));
|
|
Assert.Equal(
|
|
RuntimeEntityDirectory.FirstLocalEntityId,
|
|
directory.ClaimLocalId(second));
|
|
}
|
|
|
|
[Fact]
|
|
public void SessionClear_AdvancesEpochAndPreservesRetryableTombstone()
|
|
{
|
|
var directory = new RuntimeEntityDirectory();
|
|
RuntimeEntityRecord record = directory.AddActive(Spawn(0x70000006u, 3));
|
|
ulong operation = directory.AdvanceLifetimeMutation(record.ServerGuid);
|
|
Assert.Equal(operation, directory.CurrentLifetimeMutation(record.ServerGuid));
|
|
|
|
Assert.True(directory.RemoveActive(record.ServerGuid, out _));
|
|
directory.RetainTeardown(record);
|
|
directory.BeginSessionClear();
|
|
|
|
Assert.Equal(1UL, directory.SessionLifetimeVersion);
|
|
Assert.Equal(0UL, directory.CurrentLifetimeMutation(record.ServerGuid));
|
|
Assert.False(directory.CompleteSessionClearIfConverged());
|
|
Assert.True(directory.TryGetTeardown(record.ServerGuid, 3, out _));
|
|
|
|
directory.ReleaseTeardown(record);
|
|
Assert.True(directory.CompleteSessionClearIfConverged());
|
|
}
|
|
|
|
[Fact]
|
|
public void AcceptedCreateSnapshotAndAuthorityLiveOnCanonicalRecord()
|
|
{
|
|
var directory = new RuntimeEntityDirectory();
|
|
WorldSession.EntitySpawn spawn = Spawn(0x70000007u, 4);
|
|
InboundCreateResult accepted = directory.AcceptCreate(spawn);
|
|
RuntimeEntityRecord record = directory.AddActive(accepted.Snapshot);
|
|
|
|
ulong priorCreateVersion = record.CreateIntegrationVersion;
|
|
directory.AdvanceCreateAuthority(record);
|
|
directory.RefreshSnapshot(
|
|
record,
|
|
accepted.Snapshot with { Name = "refreshed" },
|
|
refreshPosition: true);
|
|
|
|
Assert.Equal("refreshed", record.Snapshot.Name);
|
|
Assert.Equal(priorCreateVersion + 1UL, record.CreateIntegrationVersion);
|
|
Assert.Equal(spawn.Position!.Value.LandblockId, record.FullCellId);
|
|
}
|
|
|
|
[Fact]
|
|
public void DeleteGateAndIdentityRemovalRemainSeparateRetryableEdges()
|
|
{
|
|
var directory = new RuntimeEntityDirectory();
|
|
WorldSession.EntitySpawn spawn = Spawn(0x70000008u, 9);
|
|
directory.AcceptCreate(spawn);
|
|
RuntimeEntityRecord record = directory.AddActive(spawn);
|
|
|
|
Assert.True(directory.TryDelete(
|
|
new DeleteObject.Parsed(spawn.Guid, spawn.InstanceSequence),
|
|
isLocalPlayer: false));
|
|
Assert.True(directory.IsCurrent(record));
|
|
Assert.True(directory.RemoveActive(record));
|
|
directory.RetainTeardown(record);
|
|
Assert.True(directory.TryGetTeardown(
|
|
spawn.Guid,
|
|
spawn.InstanceSequence,
|
|
out RuntimeEntityRecord retained));
|
|
Assert.Same(record, retained);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanonicalRecord_PublicSurfaceContainsNoAppOrBackendTypes()
|
|
{
|
|
Type canonical = typeof(RuntimeEntityRecord);
|
|
Type[] exposed = canonical
|
|
.GetProperties()
|
|
.Select(property => property.PropertyType)
|
|
.Concat(canonical.GetMethods().Select(method => method.ReturnType))
|
|
.ToArray();
|
|
|
|
Assert.DoesNotContain(exposed, type =>
|
|
type.Namespace?.StartsWith("AcDream.App", StringComparison.Ordinal) == true
|
|
|| type.Namespace?.StartsWith("Silk.NET", StringComparison.Ordinal) == true);
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_RejectsIdsOutsideLiveNamespace()
|
|
{
|
|
Assert.Throws<ArgumentOutOfRangeException>(
|
|
() => new RuntimeEntityDirectory(
|
|
RuntimeEntityDirectory.FirstLocalEntityId - 1u));
|
|
Assert.Throws<ArgumentOutOfRangeException>(
|
|
() => new RuntimeEntityDirectory(
|
|
RuntimeEntityDirectory.LastLocalEntityId + 1u));
|
|
}
|
|
|
|
private static WorldSession.EntitySpawn Spawn(uint guid, ushort instance)
|
|
{
|
|
var position = new CreateObject.ServerPosition(
|
|
0x0101FFFFu,
|
|
10f,
|
|
20f,
|
|
5f,
|
|
1f,
|
|
0f,
|
|
0f,
|
|
0f);
|
|
var timestamps = new PhysicsTimestamps(
|
|
Position: 1,
|
|
Movement: 1,
|
|
State: 1,
|
|
Vector: 1,
|
|
Teleport: 0,
|
|
ServerControlledMove: 1,
|
|
ForcePosition: 0,
|
|
ObjDesc: 1,
|
|
Instance: instance);
|
|
var physics = new PhysicsSpawnData(
|
|
RawState: 0x408u,
|
|
Position: position,
|
|
Movement: null,
|
|
AnimationFrame: null,
|
|
SetupTableId: 0x02000001u,
|
|
MotionTableId: 0x09000001u,
|
|
SoundTableId: null,
|
|
PhysicsScriptTableId: null,
|
|
Parent: null,
|
|
Children: null,
|
|
Scale: null,
|
|
Friction: null,
|
|
Elasticity: null,
|
|
Translucency: null,
|
|
Velocity: null,
|
|
Acceleration: null,
|
|
AngularVelocity: null,
|
|
DefaultScriptType: null,
|
|
DefaultScriptIntensity: null,
|
|
Timestamps: timestamps);
|
|
return new WorldSession.EntitySpawn(
|
|
guid,
|
|
position,
|
|
0x02000001u,
|
|
Array.Empty<CreateObject.AnimPartChange>(),
|
|
Array.Empty<CreateObject.TextureChange>(),
|
|
Array.Empty<CreateObject.SubPaletteSwap>(),
|
|
null,
|
|
null,
|
|
"fixture",
|
|
null,
|
|
null,
|
|
0x09000001u,
|
|
PhysicsState: 0x408u,
|
|
InstanceSequence: instance,
|
|
MovementSequence: 1,
|
|
ServerControlSequence: 1,
|
|
PositionSequence: 1,
|
|
Physics: physics);
|
|
}
|
|
}
|