From 7f87373886b9910fc65817ef36473c05de9df26f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 15 Jun 2026 17:25:40 +0100 Subject: [PATCH] Use typed catalog keys for faction lookups --- .voidbot/state/aetheria.cc | Bin 105412 -> 107388 bytes Aetheria.State.Unity.Smoke/Program.cs | 15 +++++-- Aetheria.State.Verify/Program.cs | 12 ++++-- Aetheria.State/AetheriaCatalogSnapshot.cs | 22 +++++++++- .../Documents/AetheriaCorporation.cs | 20 +++++++++ .../Documents/AetheriaItemDefinition.cs | 5 +++ Aetheria.State/Documents/AetheriaNameFile.cs | 5 +++ Aetheria.State/README.md | 20 +++++---- Assets/Scripts/ServerShared/Corporations.cs | 3 ++ Assets/Scripts/ServerShared/Galaxy.cs | 39 +++++++++++++++++- .../Scripts/ServerShared/LoadoutGenerator.cs | 22 +++++----- .../Runtime/AetheriaRuntimeCatalogSnapshot.cs | 38 ++++++++++++++++- docs/aetheria-perfect-machine-map.md | 21 ++++++---- 13 files changed, 182 insertions(+), 40 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index fd5dbed1b02f00f95380c456413a04bfe740b6d5..113659591121684d524f5e02dcdb6acc95b9aebc 100644 GIT binary patch delta 1692 zcmaJ?O^6&t6sFf@V+6&EVS|e)QPEvyc4x+&F(#lHU3Xd6ACN@NB1onC%}lw~RZacO zq`eGFkbns5(n5nC{fQAl55isoA_Nca#T>_@7tc8gg1+kRndu?mt*iRIuiy8*@4dc# zwD8Zb3qO7{ce1g5uGv~$Z$6jaIq;T}cY2RlFUH)+v}CC`POKRn^211XZ6J%4N5@2XWQ6M)pCa zA7A(08`{^YupR0ft3XwVFI6NJHB5>Mp&}rHhEVM=4ung&XCqC791yF4WWb~VCJ3wv z6L=ODv*PJkvsSW6gL1EgHx4#XAm z^0dh8yam#gxrtR~XIJ+d(~I+D3rrbg4bR2QrLBo)$Igw z>QXagR~UCa>PSVjRejcXwP_Ywp1FW*TzpfX$I2llp+!s~4Zh|e49Cvm_p#}@HHaLb zc)G_TGUz$SU=l`Pj_hR5B~+#{X@HVIK%_8o?51gFF%!)gB>S&CvUt2{oj=QDsMes9 z-+x*hj=%0m1;7CvgIod}2z*iyVu6klFG;0<23RT5!Y4yEnFv;1igPiygBjV@0=Qzk zg<4~=tl*%rImEYWS)ml@Ue1wCrm-f{b$h@xtbT`jW7pn-j{YoZ?=)AwQV_`-+J+%j z@vZ5!l;)@)lzc&VUziCWJ(JH3=FcA2zaeIotW_ZHi;2v3gZB8MnX$8;#Zhdv7c=fts3lJ~bOtyz?( zr}S|jF*GoaNVcwUXs`(4pKbHj!Ix<(xYw>cg_uqZ(Cyj~OJE zS&2r(MgcWwK(B4rEMV>p zdobJa_m%YVL+|v7{KL((edsNwe;s%~7e9z* p{n_z9VTYk=WZACC!l>)OICFcr3!|1d&#KJ4Y0CKxI A1^@s6 diff --git a/Aetheria.State.Unity.Smoke/Program.cs b/Aetheria.State.Unity.Smoke/Program.cs index 036752939..54a107044 100644 --- a/Aetheria.State.Unity.Smoke/Program.cs +++ b/Aetheria.State.Unity.Smoke/Program.cs @@ -118,9 +118,11 @@ if (!catalog.FindItemsByHardpoint(equipment.HardpointType).Any()) var manufactured = catalog.Items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.ManufacturerLegacyId)) ?? throw new InvalidOperationException("Runtime catalog has no manufactured item."); -if (catalog.GetManufacturer(manufactured) == null) +if (string.IsNullOrWhiteSpace(manufactured.ManufacturerKey) || + catalog.FindCorporation(manufactured.ManufacturerKey) == null || + catalog.GetManufacturer(manufactured) == null) { - throw new InvalidOperationException($"Runtime catalog manufacturer lookup failed for {manufactured.Name}."); + throw new InvalidOperationException($"Runtime catalog typed manufacturer lookup failed for {manufactured.Name}."); } var packageCorporation = packageCatalog.Corporations.FirstOrDefault(corporation => !string.IsNullOrWhiteSpace(corporation.GeonameFileLegacyId)); @@ -130,9 +132,14 @@ if (packageCorporation == null) } var packageNameFile = packageCatalog.GetNameFile(packageCorporation); -if (packageNameFile == null || packageNameFile.Names.Count == 0 || packageNameFile.Names.Count != packageNameFile.NameCount) +if (string.IsNullOrWhiteSpace(packageCorporation.GeonameFileKey) || + packageCatalog.FindNameFile(packageCorporation.GeonameFileKey) == null || + packageNameFile == null || + string.IsNullOrWhiteSpace(packageNameFile.NameFileKey) || + packageNameFile.Names.Count == 0 || + packageNameFile.Names.Count != packageNameFile.NameCount) { - throw new InvalidOperationException("Package catalog store did not read corporation/name-file links with full names."); + throw new InvalidOperationException("Package catalog store did not read typed corporation/name-file links with full names."); } if (packageCorporation.Allegiances.Count == 0 || packageCorporation.Allegiances.Count != packageCorporation.AllegianceCount) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 1678b905d..3771ad70e 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -356,19 +356,23 @@ if (!catalog.FindItemsByHardpoint(hardpointType).Any()) var manufacturedItem = items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.ManufacturerLegacyId)) ?? throw new InvalidOperationException("Cannot verify typed catalog manufacturer lookup: no manufactured item."); -if (catalog.GetManufacturer(manufacturedItem) == null) +if (string.IsNullOrWhiteSpace(manufacturedItem.ManufacturerKey) || + catalog.FindCorporation(manufacturedItem.ManufacturerKey) == null || + catalog.GetManufacturer(manufacturedItem) == null) { throw new InvalidOperationException( - $"Typed catalog manufacturer lookup failed for item {manufacturedItem.Name}."); + $"Typed catalog manufacturer-key lookup failed for item {manufacturedItem.Name}."); } var corporationWithNames = corporations.FirstOrDefault(corporation => !string.IsNullOrWhiteSpace(corporation.GeonameFileLegacyId)) ?? throw new InvalidOperationException("Cannot verify typed catalog name-file lookup: no linked corporation."); -if (catalog.GetNameFile(corporationWithNames) == null) +if (string.IsNullOrWhiteSpace(corporationWithNames.GeonameFileKey) || + catalog.FindNameFile(corporationWithNames.GeonameFileKey) == null || + catalog.GetNameFile(corporationWithNames) == null) { throw new InvalidOperationException( - $"Typed catalog name-file lookup failed for corporation {corporationWithNames.Name}."); + $"Typed catalog name-file-key lookup failed for corporation {corporationWithNames.Name}."); } if (surface.Schema != "gamecult.eve.surface.v1" || diff --git a/Aetheria.State/AetheriaCatalogSnapshot.cs b/Aetheria.State/AetheriaCatalogSnapshot.cs index 1f7a2ae29..9d396ada9 100644 --- a/Aetheria.State/AetheriaCatalogSnapshot.cs +++ b/Aetheria.State/AetheriaCatalogSnapshot.cs @@ -9,7 +9,9 @@ public sealed class AetheriaCatalogSnapshot { private readonly Dictionary _itemsByLegacyId; private readonly Dictionary _corporationsByLegacyId; + private readonly Dictionary _corporationsByKey; private readonly Dictionary _nameFilesByLegacyId; + private readonly Dictionary _nameFilesByKey; public AetheriaCatalogSnapshot( IEnumerable items, @@ -26,9 +28,15 @@ public sealed class AetheriaCatalogSnapshot _corporationsByLegacyId = Corporations .Where(corporation => !string.IsNullOrWhiteSpace(corporation.LegacyId)) .ToDictionary(corporation => corporation.LegacyId, StringComparer.OrdinalIgnoreCase); + _corporationsByKey = Corporations + .Where(corporation => !string.IsNullOrWhiteSpace(corporation.CorporationKey)) + .ToDictionary(corporation => corporation.CorporationKey, StringComparer.OrdinalIgnoreCase); _nameFilesByLegacyId = NameFiles .Where(nameFile => !string.IsNullOrWhiteSpace(nameFile.LegacyId)) .ToDictionary(nameFile => nameFile.LegacyId, StringComparer.OrdinalIgnoreCase); + _nameFilesByKey = NameFiles + .Where(nameFile => !string.IsNullOrWhiteSpace(nameFile.NameFileKey)) + .ToDictionary(nameFile => nameFile.NameFileKey, StringComparer.OrdinalIgnoreCase); } public IReadOnlyList Items { get; } @@ -72,11 +80,21 @@ public sealed class AetheriaCatalogSnapshot return TryGet(_corporationsByLegacyId, legacyId); } + public AetheriaCorporation? FindCorporation(string corporationKey) + { + return TryGet(_corporationsByKey, corporationKey); + } + public AetheriaNameFile? FindNameFileByLegacyId(string legacyId) { return TryGet(_nameFilesByLegacyId, legacyId); } + public AetheriaNameFile? FindNameFile(string nameFileKey) + { + return TryGet(_nameFilesByKey, nameFileKey); + } + public AetheriaCorporation? FindCorporationByNamePrefix(string namePrefix) { return string.IsNullOrWhiteSpace(namePrefix) @@ -87,12 +105,12 @@ public sealed class AetheriaCatalogSnapshot public AetheriaCorporation? GetManufacturer(AetheriaItemDefinition item) { - return FindCorporationByLegacyId(item.ManufacturerLegacyId); + return FindCorporation(item.ManufacturerKey); } public AetheriaNameFile? GetNameFile(AetheriaCorporation corporation) { - return FindNameFileByLegacyId(corporation.GeonameFileLegacyId); + return FindNameFile(corporation.GeonameFileKey); } private static T? TryGet(IReadOnlyDictionary dictionary, string key) where T : class diff --git a/Aetheria.State/Documents/AetheriaCorporation.cs b/Aetheria.State/Documents/AetheriaCorporation.cs index 1ec88393a..47baf4a08 100644 --- a/Aetheria.State/Documents/AetheriaCorporation.cs +++ b/Aetheria.State/Documents/AetheriaCorporation.cs @@ -15,6 +15,11 @@ public sealed class AetheriaCorporation [CultIndex("legacyId")] public string LegacyId { get; set; } = ""; + [IgnoreMember] + public string CorporationKey => string.IsNullOrWhiteSpace(LegacyId) + ? "" + : $"aetheria.corporation:legacy:{LegacyId}"; + [Key(2)] public string ShortName { get; set; } = ""; @@ -25,10 +30,20 @@ public sealed class AetheriaCorporation [CultIndex("geonameFileLegacyId")] public string GeonameFileLegacyId { get; set; } = ""; + [IgnoreMember] + public string GeonameFileKey => string.IsNullOrWhiteSpace(GeonameFileLegacyId) + ? "" + : $"aetheria.name_file:legacy:{GeonameFileLegacyId}"; + [Key(5)] [CultIndex("bossHullLegacyId")] public string BossHullLegacyId { get; set; } = ""; + [IgnoreMember] + public string BossHullItemKey => string.IsNullOrWhiteSpace(BossHullLegacyId) + ? "" + : $"aetheria.item_definition:legacy:{BossHullLegacyId}"; + [Key(6)] public int InfluenceDistance { get; set; } @@ -54,6 +69,11 @@ public sealed class AetheriaCorporationAllegiance [Key(0)] public string CorporationLegacyId { get; set; } = ""; + [IgnoreMember] + public string CorporationKey => string.IsNullOrWhiteSpace(CorporationLegacyId) + ? "" + : $"aetheria.corporation:legacy:{CorporationLegacyId}"; + [Key(1)] public double Weight { get; set; } } diff --git a/Aetheria.State/Documents/AetheriaItemDefinition.cs b/Aetheria.State/Documents/AetheriaItemDefinition.cs index e80edfb03..86836af64 100644 --- a/Aetheria.State/Documents/AetheriaItemDefinition.cs +++ b/Aetheria.State/Documents/AetheriaItemDefinition.cs @@ -35,6 +35,11 @@ public sealed class AetheriaItemDefinition [CultIndex("manufacturerLegacyId")] public string ManufacturerLegacyId { get; set; } = ""; + [IgnoreMember] + public string ManufacturerKey => string.IsNullOrWhiteSpace(ManufacturerLegacyId) + ? "" + : $"aetheria.corporation:legacy:{ManufacturerLegacyId}"; + [Key(8)] public int Price { get; set; } diff --git a/Aetheria.State/Documents/AetheriaNameFile.cs b/Aetheria.State/Documents/AetheriaNameFile.cs index 13f9757b1..ec70938a0 100644 --- a/Aetheria.State/Documents/AetheriaNameFile.cs +++ b/Aetheria.State/Documents/AetheriaNameFile.cs @@ -15,6 +15,11 @@ public sealed class AetheriaNameFile [CultIndex("legacyId")] public string LegacyId { get; set; } = ""; + [IgnoreMember] + public string NameFileKey => string.IsNullOrWhiteSpace(LegacyId) + ? "" + : $"aetheria.name_file:legacy:{LegacyId}"; + [Key(2)] public int NameCount { get; set; } diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index a4e1e2bce..f8fc3ae62 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -176,8 +176,8 @@ instances for target stats instead of reading behavior config objects directly. `ItemManager` currently owns the explicit typed-payload-to-config bridge. Typed name-file documents are `aetheria.name_file.v2` records. They carry the legacy ID, display name, count, compact sample names for surfaces, and the full -name array needed to move `Galaxy`/Markov name generation off legacy -`NameFile.Names`. +name array used by `Galaxy`/Markov name generation through typed name-file +keys rather than legacy `NameFile.Names`. Legacy GUID references that are `Guid.Empty` are imported as absent references, not as resolvable catalog links. Before materializing state, the importer clears the generated `.cc`, @@ -186,9 +186,10 @@ catalog inputs are captured first and are not deleted. This lets schema changes rebuild the typed artifact instead of failing on a stale embedded schema catalog. `AetheriaCatalogSnapshot` is the typed read surface over materialized catalog -documents. It exposes trade items, legacy-ID lookup, manufacturer lookup, -corporation prefix lookup, corporation name-file lookup, equipment items, -behavior lookup, and hardpoint lookup without reading runtime projection DTOs. +documents. It exposes trade items, legacy-ID migration lookup, typed +manufacturer/corporation/name-file key lookup, corporation prefix lookup, +equipment items, behavior lookup, and hardpoint lookup without reading runtime +projection DTOs. `AetheriaCatalogSurfaceProjector` publishes the first Eve-compatible provider surface from typed catalog state. The importer materializes @@ -210,10 +211,13 @@ packaging is available. `Galaxy` now consumes this package-owned runtime catalog for faction selection and name generation, so generated sectors use typed corporation v2 and `aetheria.name_file.v2` records instead of legacy `Faction`/`NameFile` -catalog documents. It still projects typed corporations into temporary -`Faction` DTOs, including allegiance dictionaries and local GUID equality, +catalog documents. Loadout manufacturer-distance weighting also resolves +manufacturers through typed corporation keys rather than parsing manufacturer +legacy IDs. `Galaxy` still projects typed corporations into temporary `Faction` +DTOs, including local GUID equality for the surviving simulation surface, because the surrounding simulation has not yet been rebuilt around typed -corporation records. +corporation records. The DTOs now carry typed faction/name-file keys and typed +allegiance edges so they cannot reclaim catalog lookup authority. `Aetheria.State.Smoke` writes and reopens full typed player settings plus a typed loadout template in addition to world, catalog, run state, zone state, and diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs index 398659923..71c13d3e0 100644 --- a/Assets/Scripts/ServerShared/Corporations.cs +++ b/Assets/Scripts/ServerShared/Corporations.cs @@ -11,6 +11,7 @@ using Unity.Mathematics; public class Faction : INamedEntry { public Guid ID = Guid.NewGuid(); + public string FactionKey; [Inspectable] public string Name; @@ -33,6 +34,7 @@ public class Faction : INamedEntry [InspectableColor] public float3 SecondaryColor; public Guid GeonameFile; + public string GeonameFileKey; public Guid BossHull; [Inspectable] @@ -40,6 +42,7 @@ public class Faction : INamedEntry [InspectableRangedFloat(0, 1)] public Dictionary Allegiance = new Dictionary(); + public Dictionary AllegianceByKey = new Dictionary(); [InspectableSoundBank] public uint OverworldMusic; diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs index 18258ab20..1e6036590 100644 --- a/Assets/Scripts/ServerShared/Galaxy.cs +++ b/Assets/Scripts/ServerShared/Galaxy.cs @@ -32,6 +32,7 @@ public class Galaxy public bool IsPrelude { get; } private HashSet _containedFactions; + private HashSet _containedFactionKeys; private GalaxyZone[] _exitPath; private Dictionary _nameGenerators = new Dictionary(); private readonly AetheriaRuntimeCatalogSnapshot _runtimeCatalog; @@ -243,6 +244,12 @@ public class Galaxy { factions[index].Allegiance[corporationId] = (float) allegiance.Weight; } + + if (!string.IsNullOrWhiteSpace(allegiance.CorporationKey) && + factionsByLegacyId.ContainsKey(allegiance.CorporationLegacyId)) + { + factions[index].AllegianceByKey[allegiance.CorporationKey] = (float) allegiance.Weight; + } } } @@ -254,10 +261,12 @@ public class Galaxy return new Faction { ID = ParseLegacyId(corporation.LegacyId, nameof(corporation.LegacyId), corporation.Name), + FactionKey = corporation.CorporationKey, Name = corporation.Name, ShortName = corporation.ShortName, Description = corporation.Description, GeonameFile = ParseLegacyId(corporation.GeonameFileLegacyId, nameof(corporation.GeonameFileLegacyId), corporation.Name), + GeonameFileKey = corporation.GeonameFileKey, BossHull = ParseOptionalLegacyId(corporation.BossHullLegacyId), InfluenceDistance = corporation.InfluenceDistance, }; @@ -358,10 +367,10 @@ public class Galaxy progressCallback?.Invoke($"Feeding Markov Chains: {i + 1} / {Factions.Length}"); //if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao var faction = Factions[i]; - var nameFile = _runtimeCatalog.FindNameFileByLegacyId(faction.GeonameFile.ToString()); + var nameFile = _runtimeCatalog.FindNameFile(faction.GeonameFileKey); if (nameFile == null || nameFile.Names.Count == 0) { - throw new InvalidOperationException($"Typed catalog has no name file for faction {faction.Name} ({faction.GeonameFile})."); + throw new InvalidOperationException($"Typed catalog has no name file for faction {faction.Name} ({faction.GeonameFileKey})."); } _nameGenerators[faction] = new MarkovNameGenerator(ref random, nameFile.Names, nameGeneratorSettings); @@ -470,6 +479,16 @@ public class Galaxy return _containedFactions.Contains(factionID); } + public bool ContainsFaction(string factionKey) + { + _containedFactionKeys ??= new HashSet( + Factions + .Select(f => f.FactionKey) + .Where(key => !string.IsNullOrWhiteSpace(key)), + StringComparer.OrdinalIgnoreCase); + return !string.IsNullOrWhiteSpace(factionKey) && _containedFactionKeys.Contains(factionKey); + } + public Faction ResolveFaction(Guid factionID) { if (factionID == Guid.Empty) @@ -486,6 +505,22 @@ public class Galaxy return _allFactions.FirstOrDefault(f => f.ID == factionID); } + public Faction ResolveFactionByKey(string factionKey) + { + if (string.IsNullOrWhiteSpace(factionKey)) + { + return null; + } + + var faction = Factions.FirstOrDefault(f => string.Equals(f.FactionKey, factionKey, StringComparison.OrdinalIgnoreCase)); + if (faction != null) + { + return faction; + } + + return _allFactions.FirstOrDefault(f => string.Equals(f.FactionKey, factionKey, StringComparison.OrdinalIgnoreCase)); + } + class DijkstraVertex { public float Cost; diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index 045ebbe57..9bf076017 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -150,24 +150,24 @@ public class LoadoutGenerator .Where(item => IsTypedCandidate(item, candidateKind)) .Where(item => item.Price > 0 && - Guid.TryParse(item.ManufacturerLegacyId, out var manufacturer) && - manufacturer != Guid.Empty && - (Galaxy.IsPrelude || Galaxy.ContainsFaction(manufacturer) && - (Faction == null || Faction.Allegiance.ContainsKey(manufacturer))) && + !string.IsNullOrWhiteSpace(item.ManufacturerKey) && + (Galaxy.IsPrelude || Galaxy.ContainsFaction(item.ManufacturerKey) && + (Faction == null || Faction.AllegianceByKey.ContainsKey(item.ManufacturerKey))) && (typedFilter?.Invoke(item) ?? true)) .WeightedRandomElements(ref Random, item => { - if (!Guid.TryParse(item.ManufacturerLegacyId, out var manufacturer)) + var manufacturerKey = item.ManufacturerKey; + if (string.IsNullOrWhiteSpace(manufacturerKey)) { return 0; } var allegianceWeight = Faction == null ? 1 - : manufacturer == Faction.ID + : string.Equals(manufacturerKey, Faction.FactionKey, StringComparison.OrdinalIgnoreCase) ? 1 - : Faction.Allegiance.TryGetValue(manufacturer, out var allegiance) - ? allegiance / ManufacturerDistancePenalty(manufacturer) + : Faction.AllegianceByKey.TryGetValue(manufacturerKey, out var allegiance) + ? allegiance / ManufacturerDistancePenalty(manufacturerKey) : 0; return allegianceWeight * pow(item.OccupiedCells, sizeExponent) / // Prioritize larger items @@ -196,14 +196,14 @@ public class LoadoutGenerator } } - private float ManufacturerDistancePenalty(Guid manufacturer) + private float ManufacturerDistancePenalty(string manufacturerKey) { - if (Galaxy == null || Zone == null || !Galaxy.ContainsFaction(manufacturer)) + if (Galaxy == null || Zone == null || !Galaxy.ContainsFaction(manufacturerKey)) { return 1; } - var faction = Galaxy.ResolveFaction(manufacturer); + var faction = Galaxy.ResolveFactionByKey(manufacturerKey); return faction != null && Galaxy.HomeZones.TryGetValue(faction, out var homeZone) ? Zone.Distance[homeZone] : 1; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index f805af532..62f92bda6 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -11,7 +11,9 @@ namespace GameCult.Aetheria.State.Unity private readonly Dictionary _itemsByLegacyId; private readonly Dictionary _itemsByKey; private readonly Dictionary _corporationsByLegacyId; + private readonly Dictionary _corporationsByKey; private readonly Dictionary _nameFilesByLegacyId; + private readonly Dictionary _nameFilesByKey; public AetheriaRuntimeCatalogSnapshot( AetheriaRuntimeCatalogItem[] items, @@ -33,9 +35,15 @@ namespace GameCult.Aetheria.State.Unity _corporationsByLegacyId = corporations .Where(corporation => !string.IsNullOrWhiteSpace(corporation.LegacyId)) .ToDictionary(corporation => corporation.LegacyId, StringComparer.OrdinalIgnoreCase); + _corporationsByKey = corporations + .Where(corporation => !string.IsNullOrWhiteSpace(corporation.CorporationKey)) + .ToDictionary(corporation => corporation.CorporationKey, StringComparer.OrdinalIgnoreCase); _nameFilesByLegacyId = nameFiles .Where(nameFile => !string.IsNullOrWhiteSpace(nameFile.LegacyId)) .ToDictionary(nameFile => nameFile.LegacyId, StringComparer.OrdinalIgnoreCase); + _nameFilesByKey = nameFiles + .Where(nameFile => !string.IsNullOrWhiteSpace(nameFile.NameFileKey)) + .ToDictionary(nameFile => nameFile.NameFileKey, StringComparer.OrdinalIgnoreCase); } public IReadOnlyList Items { get; } @@ -63,11 +71,21 @@ namespace GameCult.Aetheria.State.Unity return TryGet(_corporationsByLegacyId, legacyId); } + public AetheriaRuntimeCorporation? FindCorporation(string corporationKey) + { + return TryGet(_corporationsByKey, corporationKey); + } + public AetheriaRuntimeNameFile? FindNameFileByLegacyId(string legacyId) { return TryGet(_nameFilesByLegacyId, legacyId); } + public AetheriaRuntimeNameFile? FindNameFile(string nameFileKey) + { + return TryGet(_nameFilesByKey, nameFileKey); + } + public IEnumerable FindItemsByBehavior(string behaviorKind) { return string.IsNullOrWhiteSpace(behaviorKind) @@ -84,12 +102,12 @@ namespace GameCult.Aetheria.State.Unity public AetheriaRuntimeCorporation? GetManufacturer(AetheriaRuntimeCatalogItem item) { - return FindCorporationByLegacyId(item.ManufacturerLegacyId); + return FindCorporation(item.ManufacturerKey); } public AetheriaRuntimeNameFile? GetNameFile(AetheriaRuntimeCorporation corporation) { - return FindNameFileByLegacyId(corporation.GeonameFileLegacyId); + return FindNameFile(corporation.GeonameFileKey); } private static T? TryGet(IReadOnlyDictionary dictionary, string key) where T : class @@ -156,6 +174,9 @@ namespace GameCult.Aetheria.State.Unity Category = category; Description = description; ManufacturerLegacyId = manufacturerLegacyId; + ManufacturerKey = string.IsNullOrWhiteSpace(manufacturerLegacyId) + ? "" + : $"aetheria.corporation:legacy:{manufacturerLegacyId}"; Price = price; Mass = mass; SpecificHeat = specificHeat; @@ -207,6 +228,7 @@ namespace GameCult.Aetheria.State.Unity public string Category { get; } public string Description { get; } public string ManufacturerLegacyId { get; } + public string ManufacturerKey { get; } public int Price { get; } public double Mass { get; } public double SpecificHeat { get; } @@ -470,17 +492,23 @@ namespace GameCult.Aetheria.State.Unity Description = description; GeonameFileLegacyId = geonameFileLegacyId; BossHullLegacyId = bossHullLegacyId; + CorporationKey = string.IsNullOrWhiteSpace(legacyId) ? "" : $"aetheria.corporation:legacy:{legacyId}"; + GeonameFileKey = string.IsNullOrWhiteSpace(geonameFileLegacyId) ? "" : $"aetheria.name_file:legacy:{geonameFileLegacyId}"; + BossHullItemKey = string.IsNullOrWhiteSpace(bossHullLegacyId) ? "" : $"aetheria.item_definition:legacy:{bossHullLegacyId}"; InfluenceDistance = influenceDistance; AllegianceCount = allegianceCount; Allegiances = allegiances; } public string LegacyId { get; } + public string CorporationKey { get; } public string Name { get; } public string ShortName { get; } public string Description { get; } public string GeonameFileLegacyId { get; } + public string GeonameFileKey { get; } public string BossHullLegacyId { get; } + public string BossHullItemKey { get; } public int InfluenceDistance { get; } public int AllegianceCount { get; } public IReadOnlyList Allegiances { get; } @@ -491,10 +519,14 @@ namespace GameCult.Aetheria.State.Unity public AetheriaRuntimeCorporationAllegiance(string corporationLegacyId, double weight) { CorporationLegacyId = corporationLegacyId; + CorporationKey = string.IsNullOrWhiteSpace(corporationLegacyId) + ? "" + : $"aetheria.corporation:legacy:{corporationLegacyId}"; Weight = weight; } public string CorporationLegacyId { get; } + public string CorporationKey { get; } public double Weight { get; } } @@ -508,6 +540,7 @@ namespace GameCult.Aetheria.State.Unity IReadOnlyList names) { LegacyId = legacyId; + NameFileKey = string.IsNullOrWhiteSpace(legacyId) ? "" : $"aetheria.name_file:legacy:{legacyId}"; Name = name; NameCount = nameCount; SampleNames = sampleNames; @@ -515,6 +548,7 @@ namespace GameCult.Aetheria.State.Unity } public string LegacyId { get; } + public string NameFileKey { get; } public string Name { get; } public int NameCount { get; } public IReadOnlyList SampleNames { get; } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 32baf62d3..f6212ee5e 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -394,8 +394,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. legacy-ID record key mapping for migrated item, corporation, and name-file documents. - `AetheriaCatalogSnapshot` is the typed catalog read surface over materialized - `.cc` records. It exposes trade-item, manufacturer, corporation prefix, and - corporation name-file queries, plus equipment, hardpoint, and behavior + `.cc` records. It exposes trade-item, typed + manufacturer/corporation/name-file key queries, corporation prefix queries, + and legacy-ID migration lookup, plus equipment, hardpoint, and behavior queries without touching runtime projection DTOs. - `ItemManager` can now ask its typed runtime item reader for the owning `AetheriaRuntimeCatalogItem` row by item ID. Its generic mass, thermal-mass, @@ -415,7 +416,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. read path for .NET smokes. Neither is a simulation owner and neither writes state. `Aetheria.Shared.Unity` references this package directly so `Galaxy` can - consume typed name files without loading legacy `NameFile` documents. The + consume typed corporation and name-file keys without loading legacy `Faction` + or `NameFile` documents. The package also owns Unity's typed runtime commit log writer for settings, loadout-template, and run-checkpoint command documents under `aetheria-world.cc.pending`. This log is command-only: it cannot decide @@ -797,7 +799,7 @@ First Aetheria surfaces to publish: `DatabaseEntry` union fields into typed item/faction/name-file catalog documents without making `Aetheria.State` depend on Unity's legacy model. - Done: promote typed name files to `aetheria.name_file.v2` with full name - arrays, so future `Galaxy` name generation has a Verse-owned replacement + arrays, so `Galaxy` name generation has a Verse-owned replacement for legacy `NameFile.Names`. - Done: promote typed corporations to `aetheria.corporation.v2` with full allegiance edges, so temporary `Faction` DTO projection can preserve @@ -913,9 +915,14 @@ First Aetheria surfaces to publish: - Done: move `Galaxy` faction selection and name generation to the typed runtime catalog; legacy `Faction`/`NameFile` catalog entries no longer decide generated sector factions or zone names. - - Done: move entity faction restore and loadout manufacturer-distance - weighting to `Galaxy.ResolveFaction`, so legacy `Faction` catalog entries - no longer decide runtime faction references after generation. + - Done: move entity faction restore to `Galaxy.ResolveFaction`, so legacy + `Faction` catalog entries no longer decide runtime faction references + after generation. + - Done: move package and canonical manufacturer/corporation/name-file lookup + to typed keys (`ManufacturerKey`, `CorporationKey`, `GeonameFileKey`, + and `NameFileKey`), and move loadout manufacturer-distance weighting to + `Galaxy.ResolveFactionByKey`, so loadout code no longer parses + manufacturer legacy GUIDs to find faction influence. - Done: move `LoadoutGenerator` weighted candidate selection, hardpoint fit, station bay fit, cargo/capacitor fit, selected-item reuse, hull/category, hull type, hull conductivity setup, and behavior-kind prefilters onto typed