diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 4757dbf5c..cb4edf6fd 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Aetheria.State.Unity.Smoke/Program.cs b/Aetheria.State.Unity.Smoke/Program.cs index 00abdd28c..5fcbf57a0 100644 --- a/Aetheria.State.Unity.Smoke/Program.cs +++ b/Aetheria.State.Unity.Smoke/Program.cs @@ -157,6 +157,60 @@ try TutorialPassed = true, ActionBarInputs = new[] { "/1" } }); + AetheriaRuntimeStateCommitLog.QueueLoadoutTemplate( + commitSmokeStatePath, + new AetheriaRuntimeLoadoutTemplateCommit + { + Name = "Unity Smoke Loadout", + OwnerPlayerKey = "global:aetheria.player_settings.v1", + RootEntity = new AetheriaRuntimeEntityLoadoutCommit + { + Name = "Unity Smoke Ship", + Kind = "ship", + CorporationLegacyId = "smoke:faction", + Hull = new AetheriaRuntimeLoadoutItemCommit + { + ItemDefinitionLegacyId = "smoke:hull", + Quality = 0.7, + Durability = 0.6 + }, + Equipment = new[] + { + new AetheriaRuntimeLoadoutItemSlotCommit + { + X = 1, + Y = 2, + Item = new AetheriaRuntimeLoadoutItemCommit + { + ItemDefinitionLegacyId = "smoke:weapon", + Quality = 0.9, + Durability = 0.8 + } + } + }, + CargoContents = new[] + { + new AetheriaRuntimeCargoBayLoadoutCommit + { + Items = new[] + { + new AetheriaRuntimeLoadoutItemSlotCommit + { + X = 3, + Y = 4, + Item = new AetheriaRuntimeLoadoutItemCommit + { + ItemDefinitionLegacyId = "smoke:ore", + Quantity = 5 + } + } + } + } + }, + DockingBayAssignments = new[] { -1 }, + WeaponGroups = new[] { new[] { 0 } } + } + }); AetheriaRuntimeStateCommitLog.QueueRunCheckpoint( commitSmokeStatePath, new AetheriaRuntimeRunCheckpointCommit @@ -297,7 +351,7 @@ try } }); var pending = AetheriaRuntimeStateCommitLog.ReadPending(commitSmokeStatePath); - if (pending.Count != 2 || + if (pending.Count != 3 || pending[0].Kind != AetheriaRuntimeCommitKind.PlayerSettings || pending[0].Schema != AetheriaRuntimeStateCommitLog.CommitSchema || pending[0].Path != commit.Path) @@ -310,13 +364,21 @@ try { var report = await AetheriaRuntimeCommitLogApplier.ApplyPendingAsync(commitNode); var settings = await commitNode.GetPlayerSettingsAsync(); + var loadout = await commitNode.GetLoadoutTemplateAsync(new("global:aetheria.loadout_template.unity-smoke-loadout.v1")); var run = await commitNode.GetRunStateAsync(new("global:aetheria.run_state.smoke-run.v1")); var zone = await commitNode.GetZoneStateAsync(new("global:aetheria.run_state.smoke-run.zone.0.v1")); var entity = await commitNode.GetEntitySnapshotAsync(new("global:aetheria.run_state.smoke-run.zone.0.entity.0.v1")); typedNodeApplied = report.AppliedPlayerSettings == 1 && + report.AppliedLoadoutTemplates == 1 && report.AppliedRunCheckpoints == 1 && settings?.PlayerName == "Unity smoke" && settings.Input.ActionBarInputs.Length == 1 && + loadout?.Name == "Unity Smoke Loadout" && + loadout.RootEntity.Hull.ItemKey == "aetheria.item_definition:legacy:smoke:hull" && + loadout.RootEntity.Equipment.Length == 1 && + loadout.RootEntity.Equipment[0].Position.X == 1 && + loadout.RootEntity.CargoContents.Length == 1 && + loadout.RootEntity.CargoContents[0].Items[0].Item.Quantity == 5 && run?.ZoneKeys.Length == 1 && run.ActionBarBindings.Length == 2 && run.ActionBarBindings[0].ControlPath == "/1" && @@ -349,14 +411,19 @@ try } var packageSettings = AetheriaRuntimeCatalogStore.ReadPlayerSettings(commitSmokeStatePath); + var packageLoadouts = AetheriaRuntimeCatalogStore.ReadLoadoutTemplates(commitSmokeStatePath); if (!typedNodeApplied || packageSettings?.PlayerName != "Unity smoke" || packageSettings.TutorialPassed != true || - packageSettings.ActionBarInputs.Count != 1) + packageSettings.ActionBarInputs.Count != 1 || + packageLoadouts.Count != 1 || + packageLoadouts[0].RootEntity.Hull.ItemKey != "aetheria.item_definition:legacy:smoke:hull" || + packageLoadouts[0].RootEntity.Equipment[0].X != 1 || + packageLoadouts[0].RootEntity.CargoContents[0].Items[0].Item.Quantity != 5) { throw new InvalidOperationException( - "Runtime state commit log did not apply queued settings/run snapshots through the typed state node. " + - $"typedNodeApplied={typedNodeApplied}, packageSettings={(packageSettings == null ? "null" : $"{packageSettings.PlayerName}/{packageSettings.TutorialPassed}/{packageSettings.ActionBarInputs.Count}")}"); + "Runtime state commit log did not apply queued settings/loadout/run snapshots through the typed state node. " + + $"typedNodeApplied={typedNodeApplied}, packageSettings={(packageSettings == null ? "null" : $"{packageSettings.PlayerName}/{packageSettings.TutorialPassed}/{packageSettings.ActionBarInputs.Count}")}, packageLoadouts={packageLoadouts.Count}"); } var eveCommand = AetheriaRuntimeEveCommandLog.QueueCommand( @@ -397,5 +464,5 @@ Console.WriteLine($"Behavior payload sample: {behaviorHost.Name} {behaviorPayloa Console.WriteLine($"Behavior sample: {behaviorKind}"); Console.WriteLine($"Eve surface: {surface.Surface.Id}"); Console.WriteLine($"Package Eve surfaces: {packageSurfaces.Count}"); -Console.WriteLine("Runtime state commit log smoke: settings, action-bar bindings, faction relationships, and run zone/entity snapshots queued, applied, and cleared"); +Console.WriteLine("Runtime state commit log smoke: settings, loadouts, action-bar bindings, faction relationships, and run zone/entity snapshots queued, applied, and cleared"); Console.WriteLine("Runtime Eve command log smoke: surface command queued separately from state commits"); diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index bb566e9f1..06559932d 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -161,6 +161,127 @@ public class ActionGameManager : MonoBehaviour } } + private void LoadRuntimeLoadoutTemplates(string stateFilePath) + { + try + { + var loadouts = AetheriaRuntimeCatalogStore.ReadLoadoutTemplates(stateFilePath); + LoadoutBlueprints.Clear(); + foreach (var loadout in loadouts) + { + var blueprint = CreateRuntimeBlueprint(loadout.RootEntity); + if (blueprint == null) + continue; + + if (string.IsNullOrWhiteSpace(blueprint.Name)) + blueprint.Name = loadout.Name; + + LoadoutBlueprints.Add(blueprint); + } + + if (LoadoutBlueprints.Count > 0) + Debug.Log($"Loaded {LoadoutBlueprints.Count} Aetheria Verse loadout templates from typed state."); + } + catch (FileNotFoundException) + { + } + catch (Exception ex) + { + Debug.LogWarning($"Failed to load Aetheria Verse loadout templates from typed state: {ex}"); + } + } + + private RuntimeEntityBlueprint CreateRuntimeBlueprint(AetheriaRuntimeEntityLoadoutSnapshot entity) + { + var hull = CreateEquippableLoadoutItem(entity.Hull); + if (hull == null) + return null; + + RuntimeEntityBlueprint blueprint = string.Equals(entity.Kind, "orbital", StringComparison.OrdinalIgnoreCase) + ? new RuntimeOrbitalEntityBlueprint() + : new RuntimeShipBlueprint + { + Direction = new float2(0, 1) + }; + + blueprint.Name = entity.Name; + blueprint.Faction = ParseLegacyGuidFromReferenceKey(entity.FactionKey, "aetheria.corporation"); + blueprint.Hull = hull; + blueprint.Equipment = CreateEquippableSlots(entity.Equipment); + blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays); + blueprint.DockingBays = CreateEquippableSlots(entity.DockingBays); + blueprint.CargoContents = CreateCargoBayContents(entity.CargoContents); + blueprint.DockingBayContents = CreateCargoBayContents(entity.DockingBayContents); + blueprint.DockingBayAssignments = entity.DockingBayAssignments.ToArray(); + blueprint.WeaponGroups = entity.WeaponGroups.Select(group => group.ToArray()).ToArray(); + blueprint.Children = entity.Children + .Select(CreateRuntimeBlueprint) + .Where(child => child != null) + .ToArray(); + return blueprint; + } + + private (int2 position, EquippableItem item)[] CreateEquippableSlots( + IReadOnlyList slots) + { + return slots + .Select(slot => (position: new int2(slot.X, slot.Y), item: CreateEquippableLoadoutItem(slot.Item))) + .Where(slot => slot.item != null) + .ToArray(); + } + + private (int2 position, ItemInstance item)[][] CreateCargoBayContents( + IReadOnlyList bays) + { + return bays + .Select(bay => bay.Items + .Select(slot => (position: new int2(slot.X, slot.Y), item: CreateLoadoutItem(slot.Item))) + .Where(slot => slot.item != null) + .ToArray()) + .ToArray(); + } + + private EquippableItem CreateEquippableLoadoutItem(AetheriaRuntimeLoadoutItemSnapshot item) + { + var instance = CreateLoadoutItem(item) as EquippableItem; + if (instance != null && item.Durability > 0) + instance.Durability = (float)item.Durability; + return instance; + } + + private ItemInstance CreateLoadoutItem(AetheriaRuntimeLoadoutItemSnapshot item) + { + var legacyId = ParseLegacyIdFromReferenceKey(item.ItemKey, "aetheria.item_definition"); + var typedItem = RuntimeCatalog?.FindItemByLegacyId(legacyId); + if (typedItem == null) + return null; + + if (typedItem.Stackable) + return ItemManager.CreateSimpleCommodityInstance(typedItem, Math.Max(1, item.Quantity)); + + var instance = ItemManager.CreateCraftedInstance(typedItem, (float)item.Quality); + if (instance is EquippableItem equippable && item.Durability > 0) + equippable.Durability = (float)item.Durability; + return instance; + } + + private static Guid ParseLegacyGuidFromReferenceKey(string key, string documentName) + { + var legacyId = ParseLegacyIdFromReferenceKey(key, documentName); + return Guid.TryParse(legacyId, out var id) ? id : Guid.Empty; + } + + private static string ParseLegacyIdFromReferenceKey(string key, string documentName) + { + if (string.IsNullOrWhiteSpace(key)) + return ""; + + var prefix = $"{documentName}:legacy:"; + return key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) + ? key.Substring(prefix.Length) + : key; + } + public static Galaxy CurrentGalaxy; public static bool IsTutorial; public static AetheriaRuntimeCatalogSnapshot RuntimeCatalog { get; private set; } @@ -819,6 +940,7 @@ public class ActionGameManager : MonoBehaviour runtimeItemCatalog, Settings.GameplaySettings, Debug.Log); + LoadRuntimeLoadoutTemplates(stateBoot.StateFilePath); ZoneRenderer.ItemManager = ItemManager; // If hiding minimap asteroids, turn them off to start with diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index 549d81154..75879f5fb 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -566,4 +566,111 @@ namespace GameCult.Aetheria.State.Unity public int BindingIndex { get; } public string BindingPath { get; } } + + public sealed class AetheriaRuntimeLoadoutTemplateSnapshot + { + public AetheriaRuntimeLoadoutTemplateSnapshot( + string name, + string ownerPlayerKey, + AetheriaRuntimeEntityLoadoutSnapshot rootEntity, + string createdAtUtc, + string updatedAtUtc) + { + Name = name; + OwnerPlayerKey = ownerPlayerKey; + RootEntity = rootEntity; + CreatedAtUtc = createdAtUtc; + UpdatedAtUtc = updatedAtUtc; + } + + public string Name { get; } + public string OwnerPlayerKey { get; } + public AetheriaRuntimeEntityLoadoutSnapshot RootEntity { get; } + public string CreatedAtUtc { get; } + public string UpdatedAtUtc { get; } + } + + public sealed class AetheriaRuntimeEntityLoadoutSnapshot + { + public AetheriaRuntimeEntityLoadoutSnapshot( + string name, + string kind, + string factionKey, + AetheriaRuntimeLoadoutItemSnapshot hull, + IReadOnlyList equipment, + IReadOnlyList cargoBays, + IReadOnlyList dockingBays, + IReadOnlyList cargoContents, + IReadOnlyList dockingBayContents, + IReadOnlyList dockingBayAssignments, + IReadOnlyList> weaponGroups, + IReadOnlyList children) + { + Name = name; + Kind = kind; + FactionKey = factionKey; + Hull = hull; + Equipment = equipment; + CargoBays = cargoBays; + DockingBays = dockingBays; + CargoContents = cargoContents; + DockingBayContents = dockingBayContents; + DockingBayAssignments = dockingBayAssignments; + WeaponGroups = weaponGroups; + Children = children; + } + + public string Name { get; } + public string Kind { get; } + public string FactionKey { get; } + public AetheriaRuntimeLoadoutItemSnapshot Hull { get; } + public IReadOnlyList Equipment { get; } + public IReadOnlyList CargoBays { get; } + public IReadOnlyList DockingBays { get; } + public IReadOnlyList CargoContents { get; } + public IReadOnlyList DockingBayContents { get; } + public IReadOnlyList DockingBayAssignments { get; } + public IReadOnlyList> WeaponGroups { get; } + public IReadOnlyList Children { get; } + } + + public sealed class AetheriaRuntimeLoadoutItemSnapshot + { + public AetheriaRuntimeLoadoutItemSnapshot(string itemKey, double quality, double durability, int quantity) + { + ItemKey = itemKey; + Quality = quality; + Durability = durability; + Quantity = quantity; + } + + public string ItemKey { get; } + public double Quality { get; } + public double Durability { get; } + public int Quantity { get; } + } + + public sealed class AetheriaRuntimeLoadoutItemSlotSnapshot + { + public AetheriaRuntimeLoadoutItemSlotSnapshot(int x, int y, AetheriaRuntimeLoadoutItemSnapshot item) + { + X = x; + Y = y; + Item = item; + } + + public int X { get; } + public int Y { get; } + public AetheriaRuntimeLoadoutItemSnapshot Item { get; } + } + + public sealed class AetheriaRuntimeCargoBayLoadoutSnapshot + { + public AetheriaRuntimeCargoBayLoadoutSnapshot(IReadOnlyList items) + { + Items = items; + } + + public IReadOnlyList Items { get; } + } } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs index 98b7275f9..faf3227ec 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs @@ -17,6 +17,7 @@ namespace GameCult.Aetheria.State.Unity private const string NameFileSchema = "aetheria.name_file"; private const string EveSurfaceSchema = "gamecult.eve.surface"; private const string PlayerSettingsSchema = "aetheria.player_settings"; + private const string LoadoutTemplateSchema = "aetheria.loadout_template"; private const string PlayerSettingsKey = "global:aetheria.player_settings.v1"; public static AetheriaRuntimeCatalogSnapshot OpenReadOnly(string stateFilePath) @@ -86,6 +87,27 @@ namespace GameCult.Aetheria.State.Unity return settings; } + public static IReadOnlyList ReadLoadoutTemplates(string stateFilePath) + { + if (string.IsNullOrWhiteSpace(stateFilePath)) + throw new ArgumentException("State file path must be non-empty.", nameof(stateFilePath)); + + var catalog = ReadSchemaCatalog(stateFilePath); + var loadouts = new List(); + foreach (var record in ReadRecords(stateFilePath)) + { + if (!catalog.TryGetValue(record.SchemaId, out var schemaName) || + schemaName != LoadoutTemplateSchema) + continue; + + loadouts.Add(ReadLoadoutTemplatePayload(record.Payload)); + } + + return loadouts + .OrderBy(loadout => loadout.Name, StringComparer.Ordinal) + .ToArray(); + } + private static Dictionary ReadSchemaCatalog(string stateFilePath) { if (!File.Exists(stateFilePath)) @@ -347,6 +369,24 @@ namespace GameCult.Aetheria.State.Unity input.ActionBarInputs); } + private static AetheriaRuntimeLoadoutTemplateSnapshot ReadLoadoutTemplatePayload(byte[] payload) + { + var reader = new MessagePackReader(payload); + var fields = reader.ReadArrayHeader(); + var name = ReadFieldString(ref reader, fields, 0); + var ownerPlayerKey = ReadFieldString(ref reader, fields, 1); + var rootEntity = ReadFieldEntityLoadout(ref reader, fields, 2); + var createdAtUtc = ReadFieldString(ref reader, fields, 3); + var updatedAtUtc = ReadFieldString(ref reader, fields, 4); + SkipRemaining(ref reader, fields, 5); + return new AetheriaRuntimeLoadoutTemplateSnapshot( + name, + ownerPlayerKey, + rootEntity, + createdAtUtc, + updatedAtUtc); + } + private static string ReadFieldString(ref MessagePackReader reader, int fields, int index) { return index >= fields ? "" : ReadString(ref reader); @@ -457,6 +497,159 @@ namespace GameCult.Aetheria.State.Unity return bindings; } + private static AetheriaRuntimeEntityLoadoutSnapshot ReadFieldEntityLoadout(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return EmptyEntityLoadout(); + return ReadEntityLoadout(ref reader); + } + + private static IReadOnlyList ReadFieldEntityLoadouts(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return Array.Empty(); + var count = reader.ReadArrayHeader(); + var entities = new AetheriaRuntimeEntityLoadoutSnapshot[count]; + for (var entity = 0; entity < count; entity++) + entities[entity] = ReadEntityLoadout(ref reader); + return entities; + } + + private static AetheriaRuntimeEntityLoadoutSnapshot ReadEntityLoadout(ref MessagePackReader reader) + { + var fields = reader.ReadArrayHeader(); + var name = ReadFieldString(ref reader, fields, 0); + var kind = ReadFieldString(ref reader, fields, 1); + var factionKey = ReadFieldString(ref reader, fields, 2); + var hull = ReadFieldLoadoutItem(ref reader, fields, 3); + var equipment = ReadFieldLoadoutItemSlots(ref reader, fields, 4); + var cargoBays = ReadFieldLoadoutItemSlots(ref reader, fields, 5); + var dockingBays = ReadFieldLoadoutItemSlots(ref reader, fields, 6); + var cargoContents = ReadFieldCargoBayLoadouts(ref reader, fields, 7); + var dockingBayContents = ReadFieldCargoBayLoadouts(ref reader, fields, 8); + var dockingBayAssignments = ReadFieldInt32Array(ref reader, fields, 9); + var weaponGroups = ReadFieldInt32Arrays(ref reader, fields, 10); + var children = ReadFieldEntityLoadouts(ref reader, fields, 11); + SkipRemaining(ref reader, fields, 12); + return new AetheriaRuntimeEntityLoadoutSnapshot( + name, + kind, + factionKey, + hull, + equipment, + cargoBays, + dockingBays, + cargoContents, + dockingBayContents, + dockingBayAssignments, + weaponGroups, + children); + } + + private static AetheriaRuntimeEntityLoadoutSnapshot EmptyEntityLoadout() + { + return new AetheriaRuntimeEntityLoadoutSnapshot( + "", + "", + "", + EmptyLoadoutItem(), + Array.Empty(), + Array.Empty(), + Array.Empty(), + Array.Empty(), + Array.Empty(), + Array.Empty(), + Array.Empty>(), + Array.Empty()); + } + + private static AetheriaRuntimeLoadoutItemSnapshot ReadFieldLoadoutItem(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return EmptyLoadoutItem(); + var itemFields = reader.ReadArrayHeader(); + var itemKey = ReadFieldString(ref reader, itemFields, 0); + var quality = ReadFieldDouble(ref reader, itemFields, 1, 1); + var durability = ReadFieldDouble(ref reader, itemFields, 2, 1); + var quantity = ReadFieldInt32(ref reader, itemFields, 3); + SkipRemaining(ref reader, itemFields, 4); + return new AetheriaRuntimeLoadoutItemSnapshot(itemKey, quality, durability, quantity); + } + + private static AetheriaRuntimeLoadoutItemSnapshot EmptyLoadoutItem() + { + return new AetheriaRuntimeLoadoutItemSnapshot("", 1, 1, 1); + } + + private static IReadOnlyList ReadFieldLoadoutItemSlots(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return Array.Empty(); + var count = reader.ReadArrayHeader(); + var slots = new AetheriaRuntimeLoadoutItemSlotSnapshot[count]; + for (var slot = 0; slot < count; slot++) + slots[slot] = ReadLoadoutItemSlot(ref reader); + return slots; + } + + private static AetheriaRuntimeLoadoutItemSlotSnapshot ReadLoadoutItemSlot(ref MessagePackReader reader) + { + var slotFields = reader.ReadArrayHeader(); + var position = ReadFieldGridCoord(ref reader, slotFields, 0); + var item = ReadFieldLoadoutItem(ref reader, slotFields, 1); + SkipRemaining(ref reader, slotFields, 2); + return new AetheriaRuntimeLoadoutItemSlotSnapshot(position.X, position.Y, item); + } + + private static GridCoord ReadFieldGridCoord(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return new GridCoord(0, 0); + var coordFields = reader.ReadArrayHeader(); + var x = ReadFieldInt32(ref reader, coordFields, 0); + var y = ReadFieldInt32(ref reader, coordFields, 1); + SkipRemaining(ref reader, coordFields, 2); + return new GridCoord(x, y); + } + + private static IReadOnlyList ReadFieldCargoBayLoadouts(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return Array.Empty(); + var count = reader.ReadArrayHeader(); + var bays = new AetheriaRuntimeCargoBayLoadoutSnapshot[count]; + for (var bay = 0; bay < count; bay++) + { + var bayFields = reader.ReadArrayHeader(); + var items = ReadFieldLoadoutItemSlots(ref reader, bayFields, 0); + SkipRemaining(ref reader, bayFields, 1); + bays[bay] = new AetheriaRuntimeCargoBayLoadoutSnapshot(items); + } + + return bays; + } + + private static IReadOnlyList ReadFieldInt32Array(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return Array.Empty(); + var count = reader.ReadArrayHeader(); + var values = new int[count]; + for (var item = 0; item < count; item++) + values[item] = reader.ReadInt32(); + return values; + } + + private static IReadOnlyList> ReadFieldInt32Arrays(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return Array.Empty>(); + var count = reader.ReadArrayHeader(); + var values = new IReadOnlyList[count]; + for (var item = 0; item < count; item++) + { + var groupCount = reader.ReadArrayHeader(); + var group = new int[groupCount]; + for (var groupItem = 0; groupItem < groupCount; groupItem++) + group[groupItem] = reader.ReadInt32(); + values[item] = group; + } + + return values; + } + private static IReadOnlyList ReadFieldShapeCells(ref MessagePackReader reader, int fields, int index) { return index >= fields ? Array.Empty() : ReadShapeCells(ref reader); @@ -859,5 +1052,18 @@ namespace GameCult.Aetheria.State.Unity public IReadOnlyList ActionBarInputs { get; } } + + private readonly struct GridCoord + { + public GridCoord(int x, int y) + { + X = x; + Y = y; + } + + public int X { get; } + + public int Y { get; } + } } } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 8d50e490c..dcbd476d3 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -147,8 +147,11 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. equipment, cargo bay, docking bay, child-entity, assignment, and weapon-group state through record-key references and typed value slots instead of opaque runtime blueprint serialization. Unity's save/loadout UI now projects its - in-memory `RuntimeEntityBlueprint` into a typed Verse commit command; the - in-memory list remains a UI/session cache, not durable authority. + in-memory `RuntimeEntityBlueprint` into a typed Verse commit command, and + gameplay boot reads typed loadout templates back from `aetheria-world.cc` + through `AetheriaRuntimeCatalogStore` before lowering them into runtime + construction blueprints for the restore menu. The in-memory list remains a + UI/session cache, not durable authority. - `ActionGameManager` opens `AetheriaRuntimeCatalogStore` over `aetheria-world.cc`, projects it through `AetheriaRuntimeItemCatalog`, and gives `ItemManager` explicit item lookup authority. Item instances carry @@ -730,6 +733,9 @@ First Aetheria surfaces to publish: values. - Done: add typed `AetheriaLoadoutTemplate` documents and smoke coverage so `.loadout` no longer lacks a durable Verse replacement. + - Done: add the Unity runtime read projection for typed loadout templates, + so the restore menu can rehydrate saved loadouts from CultCache instead + of relying on the in-memory session list after restart. - Done: add typed node ports and smoke coverage for run -> zone -> entity snapshots so `.zone` no longer lacks a durable Verse replacement graph. - Done: extend run checkpoint commits and smoke coverage to carry typed @@ -1145,8 +1151,10 @@ First Aetheria surfaces to publish: replacement, loadout templates as the `.loadout` replacement, and a run -> zone -> entity snapshot graph as the `.zone` replacement. The zone smoke includes orbit/body rows for generated celestial state, and the entity smoke - includes typed simulation stat grids. It also proves `aetheria.runtime_session.v1` - is advertised and survives reopen as the typed daemon-session signal. + includes typed simulation stat grids. The Unity runtime smoke also proves + package-owned readback of typed loadout templates from `.cc` records. It also + proves `aetheria.runtime_session.v1` is advertised and survives reopen as the + typed daemon-session signal. - CultMesh smoke proves node start, typed put/get, subscription, flush, and reopen. - Eve surface smoke proves provider-owned surface documents are generated from