diff --git a/src/AcDream.Core/World/LoadedLandblock.cs b/src/AcDream.Core/World/LoadedLandblock.cs index 492b1f3e..a4f7b376 100644 --- a/src/AcDream.Core/World/LoadedLandblock.cs +++ b/src/AcDream.Core/World/LoadedLandblock.cs @@ -5,4 +5,5 @@ namespace AcDream.Core.World; public sealed record LoadedLandblock( uint LandblockId, LandBlock Heightmap, - IReadOnlyList Entities); + IReadOnlyList Entities, + PhysicsDatBundle? PhysicsDats = null); diff --git a/src/AcDream.Core/World/PhysicsDatBundle.cs b/src/AcDream.Core/World/PhysicsDatBundle.cs new file mode 100644 index 00000000..3c7b68ed --- /dev/null +++ b/src/AcDream.Core/World/PhysicsDatBundle.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using DatReaderWriter.DBObjs; +// Environment collides with System.Environment under implicit usings — alias it. +using DatEnvironment = DatReaderWriter.DBObjs.Environment; + +namespace AcDream.Core.World; + +/// +/// The parsed dat objects ApplyLoadedTerrainLocked needs, pre-read by the +/// streaming worker under _datLock so the apply makes ZERO DatCollection +/// calls and the update thread never blocks on the worker's lock (the FPS +/// 30↔200 swing was that lock-wait). Keyed by the same dat id the apply would +/// have passed to _dats.Get<T>. +/// +public sealed record PhysicsDatBundle( + LandBlockInfo? Info, + IReadOnlyDictionary EnvCells, + IReadOnlyDictionary Environments, + IReadOnlyDictionary Setups, + IReadOnlyDictionary GfxObjs) +{ + /// Empty bundle for far-tier landblocks (no cells / buildings / + /// entities) and for non-streaming construction. + public static readonly PhysicsDatBundle Empty = new( + null, + new Dictionary(), + new Dictionary(), + new Dictionary(), + new Dictionary()); +} diff --git a/tests/AcDream.Core.Tests/World/PhysicsDatBundleTests.cs b/tests/AcDream.Core.Tests/World/PhysicsDatBundleTests.cs new file mode 100644 index 00000000..3178e01a --- /dev/null +++ b/tests/AcDream.Core.Tests/World/PhysicsDatBundleTests.cs @@ -0,0 +1,18 @@ +using AcDream.Core.World; +using Xunit; + +namespace AcDream.Core.Tests.World; + +public class PhysicsDatBundleTests +{ + [Fact] + public void Empty_ReturnsNullInfoAndEmptyMaps() + { + var b = PhysicsDatBundle.Empty; + Assert.Null(b.Info); + Assert.Empty(b.EnvCells); + Assert.Empty(b.Environments); + Assert.Empty(b.Setups); + Assert.Empty(b.GfxObjs); + } +}