Use managed runtime catalog in Unity client

This commit is contained in:
Meta Vens 2026-06-28 04:13:39 +01:00
commit 1d60c150ac
3 changed files with 129 additions and 172 deletions

View file

@ -1,5 +1,6 @@
using Aetheria.State.Documents;
using GameCult.Aetheria.State.Verse;
using GameCult.Mesh;
namespace Aetheria.State.Unity;
@ -14,19 +15,86 @@ public sealed class AetheriaRuntimeCatalogClient : IAsyncDisposable, IDisposable
public static async Task<AetheriaRuntimeCatalogClient> OpenAsync(string statePath)
{
var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-unity-runtime-catalog").ConfigureAwait(false);
var node = await AetheriaStateNode
.OpenAsync(statePath, "aetheria-unity-runtime-catalog", enableDurableShardLogs: false)
.ConfigureAwait(false);
return new AetheriaRuntimeCatalogClient(node);
}
public AetheriaRuntimeCatalogSnapshot ReadCatalog()
{
var catalog = _node.ReadCatalogSnapshot();
return AetheriaRuntimeCatalogSnapshotMapper.FromCatalog(catalog);
return _node.RuntimeCatalog().Latest();
}
public async Task<EveSurfaceState?> ReadCatalogSurfaceAsync()
{
return await _node.GetCatalogSurfaceAsync().ConfigureAwait(false);
var surface = AetheriaRuntimeCatalogStore
.ReadEveSurfaces(_node.StatePath)
.FirstOrDefault(candidate => candidate.Surface.Id == AetheriaCatalogSurfaceProjector.SurfaceId);
return surface == null ? null : ToState(surface);
}
private static EveSurfaceState ToState(global::GameCult.Eve.Surface.EveSurfaceDocument document)
{
return new EveSurfaceState
{
Type = document.Type,
Schema = document.Schema,
ProviderId = document.ProviderId,
ProviderKind = document.ProviderKind,
Title = document.Title,
Version = document.Version,
UpdatedAtUtc = document.UpdatedAtUtc,
Surface = new EveSurface
{
Id = document.Surface.Id,
Root = ToState(document.Surface.Root),
Styles = document.Surface.Styles
.Select(style => new EveStyleToken { Name = style.Name, Value = style.Value })
.ToArray()
},
Commands = document.Commands
.Select(command =>
{
var record = CultMesh.OperationBindingRecord(command.Operation);
return new EveCommandTemplate
{
Command = record.OperationId,
Label = record.Label,
Transport = record.RouteDescription,
SchemaId = record.SchemaId,
RouteKind = record.RouteKind,
RouteDescription = record.RouteDescription
};
})
.ToArray()
};
}
private static EveSurfaceComponent ToState(global::GameCult.Eve.Surface.EveSurfaceComponent component)
{
return new EveSurfaceComponent
{
Id = component.Id,
Kind = component.Kind,
Props = new Dictionary<string, string>(component.Props, StringComparer.Ordinal),
Children = component.Children.Select(ToState).ToArray(),
StateBindings = component.StateBindings
.Select(binding =>
{
var record = CultMesh.StateBindingRecord(binding);
return new EveSurfaceStateBinding
{
TargetProp = record.TargetProp,
PointerId = record.PointerId,
SourceId = record.SourceId,
SchemaId = record.SchemaId,
RouteKind = record.RouteKind,
RouteDescription = record.RouteDescription
};
})
.ToArray()
};
}
public ValueTask DisposeAsync()

View file

@ -1,168 +0,0 @@
using Aetheria.State.Documents;
using GameCult.Aetheria.State.Verse;
namespace Aetheria.State.Unity;
internal static class AetheriaRuntimeCatalogSnapshotMapper
{
public static AetheriaRuntimeCatalogSnapshot FromCatalog(AetheriaCatalogSnapshot catalog)
{
return new AetheriaRuntimeCatalogSnapshot(
catalog.Items.Select(FromState).ToArray(),
catalog.Corporations.Select(FromState).ToArray(),
catalog.NameFiles.Select(FromState).ToArray(),
AetheriaRuntimeStateMapper.ToRuntimeTradeValueSettings(catalog.TradeValuePolicy));
}
private static AetheriaRuntimeCatalogItem FromState(AetheriaItemDefinition item)
{
return new AetheriaRuntimeCatalogItem(
item.ItemKey,
item.Name,
item.Category,
item.Description,
item.ManufacturerKey,
item.Price,
item.Mass,
item.SpecificHeat,
item.Conductivity,
item.Volume,
item.ShapeWidth,
item.ShapeHeight,
item.OccupiedCells,
item.ShapeCells.Select(FromState).ToArray(),
item.InteriorShapeWidth,
item.InteriorShapeHeight,
item.InteriorOccupiedCells,
item.InteriorShapeCells.Select(FromState).ToArray(),
item.Hardpoints.Select(FromState).ToArray(),
item.BehaviorPayloads.Select(FromState).ToArray(),
item.HardpointType,
item.HullType,
item.BehaviorKinds,
item.MaxStack,
item.Stackable,
item.Duration,
item.Durability,
item.WeaponRange,
item.WeaponCaliber,
item.WeaponType,
item.WeaponFireTypes,
item.WeaponModifiers,
item.MinimumTemperature,
item.MaximumTemperature,
item.ThermalPerformanceCurveKeys.Select(FromState).ToArray(),
item.HullPrefab,
item.ThermalResilience,
item.HullGridOffset,
item.HullArmor,
item.HullDrag,
item.HullCanTow,
item.DockingMaxSizeX,
item.DockingMaxSizeY,
item.ActionBarIcon,
item.AudioStats.Select(FromState).ToArray(),
item.EffectivenessCurveKeys.Select(FromState).ToArray(),
item.SimpleCommodityCategory,
item.CompoundCommodityCategory);
}
private static AetheriaRuntimeAudioStat FromState(AetheriaItemAudioStat stat)
{
return new AetheriaRuntimeAudioStat(stat.Parameter, FromState(stat.Stat));
}
private static AetheriaRuntimePerformanceStat FromState(AetheriaItemPerformanceStat stat)
{
return new AetheriaRuntimePerformanceStat(
stat.Min,
stat.Max,
stat.HeatExponentMultiplier,
stat.DurabilityExponentMultiplier,
stat.QualityExponent,
null);
}
private static AetheriaRuntimeShapeCell FromState(AetheriaShapeCell cell)
{
return new AetheriaRuntimeShapeCell(cell.X, cell.Y);
}
private static AetheriaRuntimeCurveKey FromState(AetheriaCurveKey key)
{
return new AetheriaRuntimeCurveKey(key.Time, key.Value, key.InTangent, key.OutTangent);
}
private static AetheriaRuntimeBehaviorPayload FromState(AetheriaBehaviorPayload payload)
{
return new AetheriaRuntimeBehaviorPayload(
payload.UnionKey,
payload.Kind,
payload.Group,
payload.Fields.Select(FromState).ToArray());
}
private static AetheriaRuntimeBehaviorField FromState(AetheriaBehaviorField field)
{
return new AetheriaRuntimeBehaviorField(field.Key, FromState(field.Value));
}
private static AetheriaRuntimeBehaviorMapEntry FromState(AetheriaBehaviorMapEntry entry)
{
return new AetheriaRuntimeBehaviorMapEntry(entry.Key, FromState(entry.Value));
}
private static AetheriaRuntimeBehaviorValue FromState(AetheriaBehaviorValue value)
{
return new AetheriaRuntimeBehaviorValue(
value.Kind,
value.StringValue,
value.NumberValue,
value.BoolValue,
value.LegacyIdValue,
value.ItemKeyValue,
value.Children.Select(FromState).ToArray(),
value.MapEntries.Select(FromState).ToArray());
}
private static AetheriaRuntimeHardpoint FromState(AetheriaItemHardpoint hardpoint)
{
return new AetheriaRuntimeHardpoint(
hardpoint.Type,
hardpoint.PositionX,
hardpoint.PositionY,
hardpoint.ShapeWidth,
hardpoint.ShapeHeight,
hardpoint.OccupiedCells,
hardpoint.ShapeCells.Select(FromState).ToArray(),
hardpoint.Transform,
hardpoint.Rotation,
hardpoint.Armor);
}
private static AetheriaRuntimeCorporation FromState(AetheriaCorporation corporation)
{
return new AetheriaRuntimeCorporation(
corporation.CorporationKey,
corporation.Name,
corporation.ShortName,
corporation.Description,
corporation.GeonameFileKey,
corporation.BossHullItemKey,
corporation.InfluenceDistance,
corporation.AllegianceCount,
corporation.Allegiances.Select(allegiance => new AetheriaRuntimeCorporationAllegiance(
allegiance.CorporationKey,
allegiance.Weight)).ToArray());
}
private static AetheriaRuntimeNameFile FromState(AetheriaNameFile nameFile)
{
return new AetheriaRuntimeNameFile(
nameFile.NameFileKey,
nameFile.Name,
nameFile.NameCount,
nameFile.SampleNames,
nameFile.Names);
}
}

View file

@ -63,6 +63,7 @@ RequireTypedStatRecipeOperations(root);
RequireTypedDaemonCommandPayloads(root);
RequireUnityPublicRequestVocabulary(root);
RequireDaemonVersePublication(root);
RequireUnityRuntimeCatalogClientUsesManagedDocument(root);
RequireAetheriaRuntimeVerseClientContract(root);
RequireTypedEveCommandBodies(root);
RequireMainMenuVerseHostProjection(root);
@ -9215,6 +9216,62 @@ static void RequireDaemonVersePublication(string root)
}
}
static void RequireUnityRuntimeCatalogClientUsesManagedDocument(string root)
{
var clientPath = Path.Combine(root, "Aetheria.State.Unity", "AetheriaRuntimeCatalogClient.cs");
var mapperPath = Path.Combine(root, "Aetheria.State.Unity", "AetheriaRuntimeCatalogSnapshotMapper.cs");
var client = File.Exists(clientPath)
? File.ReadAllText(clientPath)
: throw new InvalidOperationException("Cannot verify Unity runtime catalog client; AetheriaRuntimeCatalogClient.cs is missing.");
var requiredSymbols = new[]
{
"\"aetheria-unity-runtime-catalog\",",
"enableDurableShardLogs: false",
"public AetheriaRuntimeCatalogSnapshot ReadCatalog()",
"return _node.RuntimeCatalog().Latest();",
"public async Task<EveSurfaceState?> ReadCatalogSurfaceAsync()",
"AetheriaRuntimeCatalogStore",
".ReadEveSurfaces(_node.StatePath)",
"candidate.Surface.Id == AetheriaCatalogSurfaceProjector.SurfaceId",
"private static EveSurfaceState ToState(global::GameCult.Eve.Surface.EveSurfaceDocument document)"
};
var missingSymbols = requiredSymbols
.Where(symbol => !client.Contains(symbol, StringComparison.Ordinal))
.ToArray();
if (missingSymbols.Length > 0)
{
throw new InvalidOperationException(
"Unity runtime catalog client must read the managed runtime catalog document: " +
string.Join(", ", missingSymbols));
}
var forbiddenSymbols = new[]
{
"_node.ReadCatalogSnapshot()",
"_node.GetCatalogSurfaceAsync()",
"AetheriaRuntimeCatalogSnapshotMapper.FromCatalog(",
"AetheriaCatalogSnapshot"
};
var forbiddenHits = forbiddenSymbols
.Where(symbol => client.Contains(symbol, StringComparison.Ordinal))
.ToArray();
if (forbiddenHits.Length > 0)
{
throw new InvalidOperationException(
"Unity runtime catalog client still maps authored catalog state instead of using the managed runtime document: " +
string.Join(", ", forbiddenHits));
}
if (File.Exists(mapperPath))
{
throw new InvalidOperationException(
"Unity runtime catalog snapshot mapper is dead projection chaff; AetheriaStateNode.RuntimeCatalog owns this document now.");
}
Console.WriteLine("Unity runtime catalog client: catalog reads use the managed typed runtime document");
}
static void RequireAetheriaRuntimeVerseClientContract(string root)
{
var clientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeVerseClient.cs");