refactor(runtime): own world environment state

This commit is contained in:
Erik 2026-07-26 16:45:04 +02:00
parent b972f539f7
commit 902076c0a4
27 changed files with 886 additions and 295 deletions

View file

@ -236,6 +236,8 @@ public sealed class InteractionUiRuntimeSourcesTests
public IRuntimeChatView Chat => null!;
public IRuntimeActionView Actions => null!;
public IRuntimeMovementView Movement => null!;
public AcDream.Runtime.World.IRuntimeWorldEnvironmentView Environment =>
null!;
public IRuntimePortalView Portal => null!;
public IRuntimeSessionCommands Session => null!;
public IRuntimeSelectionCommands Selection => null!;

View file

@ -209,6 +209,8 @@ public sealed class GameplayInputCommandControllerTests
public IRuntimeChatView Chat => throw new NotSupportedException();
public IRuntimeActionView Actions => throw new NotSupportedException();
public IRuntimeMovementView Movement => throw new NotSupportedException();
public AcDream.Runtime.World.IRuntimeWorldEnvironmentView Environment =>
throw new NotSupportedException();
public IRuntimePortalView Portal => throw new NotSupportedException();
public RuntimeStateCheckpoint CaptureCheckpoint() =>
throw new NotSupportedException();

View file

@ -169,7 +169,7 @@ public sealed class GameWindowSlice8BoundaryTests
"WorldRenderComposition.cs"));
Assert.Contains(
"private readonly AcDream.App.World.WorldEnvironmentController _worldEnvironment =",
"private readonly AcDream.App.World.WorldEnvironmentController _worldEnvironment;",
source,
StringComparison.Ordinal);
Assert.Contains(

View file

@ -23,6 +23,7 @@ using AcDream.Runtime;
using AcDream.Runtime.Entities;
using AcDream.Runtime.Gameplay;
using AcDream.Runtime.Session;
using AcDream.Runtime.World;
using AcDream.UI.Abstractions;
using AcDream.UI.Abstractions.Input;
@ -783,6 +784,7 @@ public sealed class CurrentGameRuntimeAdapterTests
_combatModeBinding =
CombatModeOperations.BindOwned(CombatMode);
MovementState = new RuntimeLocalPlayerMovementState();
Environment = new RuntimeWorldEnvironmentState();
MovementInput = new DispatcherMovementInputSource(MovementState);
GameplayInput = new GameplayInputFrameController(
dispatcher: null,
@ -833,6 +835,7 @@ public sealed class CurrentGameRuntimeAdapterTests
Communication,
Actions,
MovementState,
Environment,
WorldReveal,
Clock,
selectionController);
@ -853,6 +856,7 @@ public sealed class CurrentGameRuntimeAdapterTests
public RuntimeActionState Actions { get; }
public SelectionState Selection => Actions.Selection;
public RuntimeLocalPlayerMovementState MovementState { get; }
public RuntimeWorldEnvironmentState Environment { get; }
public DispatcherMovementInputSource MovementInput { get; }
public GameplayInputFrameController GameplayInput { get; }
public RecordingCombatModeOperations CombatMode { get; }

View file

@ -338,6 +338,26 @@ public sealed class RuntimeOptionsTests
Assert.Equal(0.95f, invalid.FogEndMultiplier);
}
[Fact]
public void DayGroupOverride_IsReadOnceIntoTypedOptions()
{
Assert.Null(
RuntimeOptions.Parse(
AnyDatDir,
EmptyEnv()).ForcedDayGroupIndex);
Assert.Null(
RuntimeOptions.Parse(
AnyDatDir,
Env(new() { ["ACDREAM_DAY_GROUP"] = "-1" }))
.ForcedDayGroupIndex);
Assert.Equal(
7,
RuntimeOptions.Parse(
AnyDatDir,
Env(new() { ["ACDREAM_DAY_GROUP"] = "7" }))
.ForcedDayGroupIndex);
}
[Fact]
public void DiagnosticFlags_RespectExactValueOne()
{
@ -346,6 +366,7 @@ public sealed class RuntimeOptionsTests
["ACDREAM_DEVTOOLS"] = "1",
["ACDREAM_UNCAPPED_RENDER"] = "1",
["ACDREAM_DUMP_MOVE_TRUTH"] = "1",
["ACDREAM_DUMP_SKY"] = "1",
["ACDREAM_NO_AUDIO"] = "1",
["ACDREAM_ENABLE_SKY_PES"] = "1",
["ACDREAM_DUMP_SCENERY_Z"] = "1",
@ -354,6 +375,7 @@ public sealed class RuntimeOptionsTests
Assert.True(allOn.DevTools);
Assert.True(allOn.UncappedRendering);
Assert.True(allOn.DumpMoveTruth);
Assert.True(allOn.DumpSky);
Assert.True(allOn.NoAudio);
Assert.True(allOn.EnableSkyPesDebug);
Assert.True(allOn.DumpSceneryZ);

View file

@ -1,6 +1,7 @@
using System.Numerics;
using AcDream.App.World;
using AcDream.Core.World;
using AcDream.Runtime.World;
namespace AcDream.App.Tests.World;
@ -57,25 +58,23 @@ public sealed class WorldEnvironmentControllerTests
}
[Fact]
public void Initialize_WithoutGameTimeRestoresDocumentedFallbackOrigin()
public void Initialize_WithoutGameTimeUsesInstanceFallbackOrigin()
{
double previous = DerethDateTime.OriginOffsetTicks;
try
{
DerethDateTime.SetOriginOffsetFromDat(3600.0);
var controller = CreateController([]);
var first = CreateController([]);
var second = CreateController([]);
controller.Initialize(SingleGroupSky("Sunny", begin: 0f), zeroTimeOfYear: null);
first.Initialize(
SingleGroupSky("Sunny", begin: 0f),
zeroTimeOfYear: 3600.0);
second.Initialize(
SingleGroupSky("Sunny", begin: 0f),
zeroTimeOfYear: null);
Assert.Equal(
DerethDateTime.DayFractionOriginOffsetTicks,
DerethDateTime.OriginOffsetTicks);
Assert.InRange(controller.DayFraction, 0.499f, 0.501f);
}
finally
{
DerethDateTime.SetOriginOffsetFromDat(previous);
}
Assert.Equal(3600.0, first.WorldTime.Calendar.OriginOffsetTicks);
Assert.Equal(
DerethDateTime.DayFractionOriginOffsetTicks,
second.WorldTime.Calendar.OriginOffsetTicks);
Assert.InRange(second.DayFraction, 0.499f, 0.501f);
}
[Theory]
@ -143,8 +142,8 @@ public sealed class WorldEnvironmentControllerTests
private static WorldEnvironmentController CreateController(List<string> log) =>
new(
new WorldTimeService(SkyStateProvider.Default()),
new WeatherSystem(),
new RuntimeWorldEnvironmentState(log: log.Add),
forcedDayGroupIndex: null,
log.Add);
private static LoadedSkyDesc SingleGroupSky(string name, float begin)
@ -180,8 +179,8 @@ public sealed class WorldEnvironmentControllerTests
line.Contains("→ DayGroup[", StringComparison.Ordinal);
}
[CollectionDefinition(Name, DisableParallelization = true)]
[CollectionDefinition(Name)]
public sealed class WorldEnvironmentControllerCollection
{
public const string Name = "World environment process-global calendar";
public const string Name = "World environment";
}