Carry typed daemon entity indices into Unity

This commit is contained in:
Meta Vens 2026-06-28 11:26:11 +01:00
commit c751157670
5 changed files with 19 additions and 17 deletions

View file

@ -6,7 +6,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using GameCult.Aetheria.State.Verse;
using Regex = System.Text.RegularExpressions.Regex;
public static class AetheriaUnityDaemonEntitySnapshotProjector
{
@ -31,14 +30,6 @@ public static class AetheriaUnityDaemonEntitySnapshotProjector
.ToArray();
}
public static int EntityIndexFromRecordKey(string recordKey)
{
var match = Regex.Match(recordKey ?? "", @"\.entity\.(\d+)\.v1$");
return match.Success && int.TryParse(match.Groups[1].Value, out var index)
? index
: int.MaxValue;
}
public static string DaemonEntityRecordKey(string runId, int zoneIndex, int entityIndex)
{
return string.IsNullOrWhiteSpace(runId)
@ -53,6 +44,7 @@ public static class AetheriaUnityDaemonEntitySnapshotProjector
{
return new AetheriaRuntimeEntitySnapshot(
DaemonEntityRecordKey(runId, zoneIndex, entity.EntityIndex),
entity.EntityIndex,
entity.Name ?? "",
entity.Kind ?? "",
entity.PositionX,

View file

@ -123,8 +123,7 @@ public sealed class AetheriaUnityObservedEntityProjector
private static void ApplyPoseAndSimpleRuntimeState(Entity entity, AetheriaRuntimeEntitySnapshot entitySnapshot)
{
entity.DaemonEntityIndex =
AetheriaUnityDaemonEntitySnapshotProjector.EntityIndexFromRecordKey(entitySnapshot.RecordKey);
entity.DaemonEntityIndex = entitySnapshot.EntityIndex;
entity.Name = entitySnapshot.Name ?? "";
entity.CultPosition = new CultMath.float3((float)entitySnapshot.PositionX, (float)entitySnapshot.PositionY, (float)entitySnapshot.PositionZ);
entity.CultDirection = new CultMath.float2((float)entitySnapshot.DirectionX, (float)entitySnapshot.DirectionY);

View file

@ -91,7 +91,7 @@ public sealed class AetheriaUnityObservedFrameApplier
}
var entitySnapshots = AetheriaUnityDaemonEntitySnapshotProjector.CreateSnapshots(runId, render.ZoneIndex, render.EntitySnapshots)
.OrderBy(entity => AetheriaUnityDaemonEntitySnapshotProjector.EntityIndexFromRecordKey(entity.RecordKey))
.OrderBy(entity => entity.EntityIndex)
.ToArray();
if (entitySnapshots.Length == 0)