refactor(runtime): extract the live object frame

This commit is contained in:
Erik 2026-07-22 00:42:26 +02:00
parent 99a3e819c4
commit 4e4aac2c5a
27 changed files with 1217 additions and 371 deletions

View file

@ -0,0 +1,34 @@
using AcDream.App.World;
using AcDream.Core.World;
namespace AcDream.App.Rendering;
/// <summary>
/// Resolves static-workset residency against the canonical live incarnation.
/// DAT-only statics have no server identity and remain resident for their
/// enclosing landblock resource lifetime.
/// </summary>
internal sealed class LiveStaticAnimationResidency
{
private readonly ILiveEntityRuntimeSource _runtime;
public LiveStaticAnimationResidency(ILiveEntityRuntimeSource runtime) =>
_runtime = runtime ?? throw new ArgumentNullException(nameof(runtime));
public bool IsResident(WorldEntity entity) =>
entity.ServerGuid == 0
|| (_runtime.Current?.TryGetRecord(entity.ServerGuid, out LiveEntityRecord resident) == true
&& resident.ProjectionKind is LiveEntityProjectionKind.World
&& ReferenceEquals(resident.WorldEntity, entity)
&& resident.IsSpatiallyProjected
&& resident.IsSpatiallyVisible
&& resident.FullCellId != 0);
public ulong ProjectionVersion(WorldEntity entity) =>
entity.ServerGuid == 0
? 0UL
: _runtime.Current?.TryGetRecord(entity.ServerGuid, out LiveEntityRecord resident) == true
&& ReferenceEquals(resident.WorldEntity, entity)
? resident.ProjectionMutationVersion
: ulong.MaxValue;
}