refactor(runtime): own world reveal generation

This commit is contained in:
Erik 2026-07-26 17:09:54 +02:00
parent 4ab98b080e
commit a6860d5563
26 changed files with 1294 additions and 502 deletions

View file

@ -65,7 +65,7 @@ public sealed class CurrentGameRuntimeAdapterTests
};
harness.Objects.AddOrUpdate(item);
harness.Chat.OnSystemMessage("runtime parity", 0x1Au);
harness.WorldReveal.Begin(WorldRevealKind.Portal, 0x12340001u);
harness.WorldReveal.Begin(RuntimePortalKind.Portal, 0x12340001u);
WorldRevealReadinessSnapshot readiness =
harness.WorldReveal.PrepareAndEvaluate(0x12340001u);
Assert.True(readiness.IsReady);
@ -792,7 +792,9 @@ public sealed class CurrentGameRuntimeAdapterTests
mouseLook: null,
new NoopCombatInput());
Clock = new UpdateFrameClock();
WorldTransit = new RuntimeWorldTransitState();
WorldReveal = new WorldRevealCoordinator(
WorldTransit,
static (_, _) => true,
static _ => true,
static (_, _) => true,
@ -836,7 +838,7 @@ public sealed class CurrentGameRuntimeAdapterTests
Actions,
MovementState,
Environment,
WorldReveal,
WorldTransit,
Clock,
selectionController);
}
@ -861,6 +863,7 @@ public sealed class CurrentGameRuntimeAdapterTests
public GameplayInputFrameController GameplayInput { get; }
public RecordingCombatModeOperations CombatMode { get; }
public UpdateFrameClock Clock { get; }
public RuntimeWorldTransitState WorldTransit { get; }
public WorldRevealCoordinator WorldReveal { get; }
public RecordingCommandRouting Commands { get; }
public TestTransport Transport { get; }

View file

@ -0,0 +1,91 @@
using System.Text.RegularExpressions;
using AcDream.App.Runtime;
using AcDream.App.Streaming;
using AcDream.Runtime;
using AcDream.Runtime.World;
namespace AcDream.App.Tests.Runtime;
public sealed class RuntimeWorldTransitOwnershipTests
{
[Fact]
public void ProductionConstructsOneRuntimeTransitOwnerAndNoAppLifecycleOwner()
{
string root = FindRepositoryRoot();
string appRoot = Path.Combine(root, "src", "AcDream.App");
string app = string.Join(
"\n",
Directory.EnumerateFiles(appRoot, "*.cs", SearchOption.AllDirectories)
.Select(File.ReadAllText));
Assert.False(File.Exists(Path.Combine(
appRoot,
"Streaming",
"WorldRevealLifecycleTelemetry.cs")));
Assert.DoesNotContain(
"class WorldRevealLifecycleTelemetry",
app,
StringComparison.Ordinal);
Assert.DoesNotContain(
"record struct WorldRevealLifecycleSnapshot",
app,
StringComparison.Ordinal);
Assert.Single(Regex.Matches(
app,
@"new\s+RuntimeWorldTransitState\s*\(")
.Cast<Match>());
}
[Fact]
public void GraphicalAdaptersBorrowRuntimeStateWithoutReconstructingPortalView()
{
var availabilityFields = typeof(WorldGenerationAvailabilityState)
.GetFields(
System.Reflection.BindingFlags.Instance
| System.Reflection.BindingFlags.NonPublic);
Assert.Single(availabilityFields);
Assert.Equal(
typeof(RuntimeWorldTransitState),
availabilityFields[0].FieldType);
var viewFields = typeof(CurrentGameRuntimeViewAdapter)
.GetFields(
System.Reflection.BindingFlags.Instance
| System.Reflection.BindingFlags.NonPublic);
Assert.Contains(
viewFields,
field => field.FieldType == typeof(IRuntimePortalView));
Assert.DoesNotContain(
typeof(CurrentGameRuntimeViewAdapter).GetNestedTypes(
System.Reflection.BindingFlags.NonPublic),
type => type.Name.Contains(
"PortalView",
StringComparison.Ordinal));
var coordinatorFields = typeof(WorldRevealCoordinator)
.GetFields(
System.Reflection.BindingFlags.Instance
| System.Reflection.BindingFlags.NonPublic);
Assert.Contains(
coordinatorFields,
field => field.FieldType == typeof(RuntimeWorldTransitState));
Assert.DoesNotContain(
coordinatorFields,
field => field.Name is "_activeGeneration"
or "_worldSimulationReleased"
or "_lifecycle");
}
private static string FindRepositoryRoot()
{
var current = new DirectoryInfo(AppContext.BaseDirectory);
while (current is not null)
{
if (File.Exists(Path.Combine(current.FullName, "AcDream.slnx")))
return current.FullName;
current = current.Parent;
}
throw new DirectoryNotFoundException("AcDream.slnx was not found.");
}
}