acdream/src/AcDream.App/Rendering/WorldSceneRuntimeSources.cs
Erik d09e246d3a refactor(world): own live environment state
Move the DAT sky, selected day group, world clock, weather, AdminEnvirons bridge, and debug cycles into a one-shot WorldEnvironmentController while preserving GameWindow's public aliases and accepted startup/session/render order. Correct the named retail citations and register the remaining environment audio and fog/radar gaps.

Co-authored-by: Codex <codex@openai.com>
2026-07-22 10:54:33 +02:00

98 lines
2.9 KiB
C#

using System.Numerics;
using AcDream.App.Input;
using AcDream.App.Streaming;
using AcDream.Core.Physics;
using AcDream.Core.World;
namespace AcDream.App.Rendering;
internal interface IWorldSceneSkyStateSource
{
DayGroupData? ActiveDayGroup { get; }
float DayFraction { get; }
}
internal interface IWorldSceneEntitySource
{
IEnumerable<(uint LandblockId, Vector3 AabbMin, Vector3 AabbMax,
IReadOnlyList<WorldEntity> Entities,
IReadOnlyDictionary<uint, WorldEntity>? AnimatedById)> LandblockEntries
{ get; }
IEnumerable<(uint LandblockId, Vector3 AabbMin, Vector3 AabbMax)> LandblockBounds { get; }
}
internal sealed class RuntimeWorldSceneEntitySource : IWorldSceneEntitySource
{
private readonly GpuWorldState _world;
public RuntimeWorldSceneEntitySource(GpuWorldState world)
{
_world = world ?? throw new ArgumentNullException(nameof(world));
}
public IEnumerable<(uint LandblockId, Vector3 AabbMin, Vector3 AabbMax,
IReadOnlyList<WorldEntity> Entities,
IReadOnlyDictionary<uint, WorldEntity>? AnimatedById)> LandblockEntries =>
_world.LandblockEntries;
public IEnumerable<(uint LandblockId, Vector3 AabbMin, Vector3 AabbMax)> LandblockBounds =>
_world.LandblockBounds;
}
internal interface IWorldScenePViewDiagnosticSource
{
Vector3 RawPlayerPositionOr(Vector3 fallback);
float PlayerYaw { get; }
float? SampleTerrainZ(float worldX, float worldY);
CameraCellResolution CameraCellResolution { get; }
}
internal sealed class RuntimeWorldScenePViewDiagnosticSource :
IWorldScenePViewDiagnosticSource
{
private readonly ILocalPlayerControllerSource _player;
private readonly PhysicsEngine _physics;
private readonly CellVisibility _visibility;
public RuntimeWorldScenePViewDiagnosticSource(
ILocalPlayerControllerSource player,
PhysicsEngine physics,
CellVisibility visibility)
{
_player = player ?? throw new ArgumentNullException(nameof(player));
_physics = physics ?? throw new ArgumentNullException(nameof(physics));
_visibility = visibility ?? throw new ArgumentNullException(nameof(visibility));
}
public Vector3 RawPlayerPositionOr(Vector3 fallback) =>
_player.Controller?.Position ?? fallback;
public float PlayerYaw => _player.Controller?.Yaw ?? 0f;
public float? SampleTerrainZ(float worldX, float worldY) =>
_physics.SampleTerrainZ(worldX, worldY);
public CameraCellResolution CameraCellResolution =>
_visibility.LastCameraCellResolution;
}
internal interface IWorldSceneDebugStateSource
{
bool CollisionWireframesVisible { get; }
}
internal sealed class WorldSceneDebugState : IWorldSceneDebugStateSource
{
public bool CollisionWireframesVisible { get; private set; }
public bool ToggleCollisionWireframes()
{
CollisionWireframesVisible = !CollisionWireframesVisible;
return CollisionWireframesVisible;
}
}