From 8e77e67dba1b6a521037f52d7c06da8c3f55d073 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 13 Jun 2026 13:35:00 +0100 Subject: [PATCH] Use typed catalog for loadout item candidates --- .voidbot/state/aetheria.cc | Bin 30145 -> 30436 bytes Assets/Scripts/Gameplay/ActionGameManager.cs | 5 +- .../Scripts/ServerShared/LoadoutGenerator.cs | 43 +++++++++++++++++- Assets/Scripts/ServerShared/ZoneGenerator.cs | 4 +- docs/aetheria-perfect-machine-map.md | 17 +++++-- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 43c798fdb9d64cc933b81eb8758fefe400d53244..2806873be425604d0ed55189995f86087856050b 100644 GIT binary patch delta 1147 zcmZux&r4KM6wV)Hh8Uq%n&lNIqtJ2YO^!dHNYGU17dAu~f_L6KGw5r9nf=D77iwy)3QFXl>i5o#=SM{OF%+uo0YP+rP%2`1z zkyj)O93)jtaKgnr@f4NHBTPY#n3P-0q6&xy4w!z9e${cjZBJM`S}GMXsFYv=n*)#N zRpW3S!CI1GjsodvH_~=2gK67PT_GHgqyb+6u?v<@gJ*Tik%Rheq^==K#uXwHNAN62 zWaBt`Z-gwSP7xo>2?y9@2|S+*XNf*hz&#|qa%*IPnhL2XADoyrn6qA2i3;O5E;oUg z5&{Xj0@`V?=^VorroaT54<<)tnBx!$E!Xl4`8trLW}$>LoVwuomHKO>b@3&(!^Yz| z*I{OWy7DPy1L3fsg7j`n!Y2QNBpO)zICbRAx=pSndge-aHUjHM`Q^~ z;#+9D*`v>4j#+@qFHIBC=MypgU~Io}<)Rcb=ysB$ZdtYvd(&zg2NA6O$5>lUs8R9v z*zLxeGVg~coAuR(1A1zxsbhE|WVVfrke=Vhza4$!OuK$OLoT-skkv1 zo_ca%a!JuFYTv8t*}me>spZO=5UqG`y1uq{BT;{;YA#>DkqoYXjlC~N67ld0u~UDZ d5kVDxHxhmN^z8lezZ1R1)!A>g<&xgm7K@#5W&h5VB?R%SjZ|`zx zLKMaR^;#$jL5Ol)tkT$6TLdiaf}pLH^X?->EO&P1KmYm7o1eeBcJ{hHz0dWGPTm}z z@+L+m?VqKK_FL{nCo)=~NUv3g*E*50@n+;$_oW=ZYz%fs`Tm(F5kknT2)>GACIgVF z1{wwWMgun(Yx}kTTH(~RZ@7|07UL|FEW~tBAFKnRB>e!CS&S(&Xuk}=o%<^pPZCxZ zSR%Cz1AH5F-rKSmX-?$`j(o7o8+*F_q7XkuIPzIXh?8d-_ zb=S0v5vy`it}x%Il%u{5T9Ic?a5S(sDbg5XnTaUF)WOdTkkyD#n21TJWF+oT4h1Tv zp&-dzp7)tFsj?I&g8NM)yT2dfs%hn}x06XtgN{@t0^*bi<|8~wS%9;|c?Qc_2+rvv z#R8R?B1(sz9J_|#(=Q$nhyA6vackT}VCo6+PBVf)w5dN6Dg@etn-Xf#Iu{7bhzXaj zLmdQ$%&)ii;AA9AQ&l7M+E-4?r~_D?wrDr{pCsTa*T&nV^$@r@tmq$y?mmB;Vr9#{ z#m2L%i&vgLq;+NvewGr>fC}6;p@uw+jB}QvR-#IdU6OMZDH>-@$>vK*RTf52WP+{M zy^mPs0aAIZSHHbHHf+z9&UHPoL#6X4TW_kv$1areN4=((int count, float sizeExponent, Predicate filter = null) where T : EquippableItemData { - return ItemManager.GetCatalogEntries() + return RuntimeCatalog.EquipmentItems + .Where(IsTypedCandidate) + .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)))) + .Select(HydrateLegacyItem) + .Where(item => item != null) .Where(item => item.Price > 0 && item.Manufacturer != Guid.Empty && @@ -144,6 +157,34 @@ public class LoadoutGenerator ); } + private static bool IsTypedCandidate(AetheriaRuntimeCatalogItem item) where T : EquippableItemData + { + var requestedType = typeof(T); + if (requestedType == typeof(EquippableItemData)) + { + return !string.IsNullOrWhiteSpace(item.HardpointType); + } + + if (requestedType == typeof(GearData)) + { + return item.Category is "GearData" or "WeaponItemData"; + } + + if (requestedType == typeof(CargoBayData)) + { + return item.Category is "CargoBayData" or "DockingBayData"; + } + + return string.Equals(item.Category, requestedType.Name, StringComparison.Ordinal); + } + + private T HydrateLegacyItem(AetheriaRuntimeCatalogItem item) where T : EquippableItemData + { + return Guid.TryParse(item.LegacyId, out var legacyId) + ? ItemManager.GetCatalogEntry(legacyId) + : null; + } + private float ManufacturerDistancePenalty(Guid manufacturer) { if (Galaxy == null || Zone == null || !Galaxy.ContainsFaction(manufacturer)) diff --git a/Assets/Scripts/ServerShared/ZoneGenerator.cs b/Assets/Scripts/ServerShared/ZoneGenerator.cs index f6b1018f4..f8cd65e4a 100644 --- a/Assets/Scripts/ServerShared/ZoneGenerator.cs +++ b/Assets/Scripts/ServerShared/ZoneGenerator.cs @@ -7,6 +7,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; +using GameCult.Aetheria.State.Unity; using MessagePack; using UniRx; using Unity.Mathematics; @@ -37,6 +38,7 @@ public static class ZoneGenerator public static ZonePack GenerateZone( ItemManager itemManager, + AetheriaRuntimeCatalogSnapshot runtimeCatalog, ZoneGenerationSettings zoneSettings, Galaxy galaxy, GalaxyZone galaxyZone, @@ -245,7 +247,7 @@ public static class ZoneGenerator LoadoutGenerator GetLoadoutGenerator(Faction faction) { if (!loadoutGenerators.ContainsKey(faction)) - loadoutGenerators[faction] = new LoadoutGenerator(ref random, itemManager, galaxy, galaxyZone, faction, .5f); + loadoutGenerators[faction] = new LoadoutGenerator(ref random, itemManager, runtimeCatalog, galaxy, galaxyZone, faction, .5f); return loadoutGenerators[faction]; } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index d12cc68d4..0ed272d20 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -85,7 +85,7 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. deserialization only. UI code no longer reaches into `LegacyCatalogBoundary.GetCatalog` directly. - `ItemManager` no longer exposes the raw `ILegacyCatalogReader` as public - gameplay/UI API. Item instantiation, loadout item selection, and trade consumers + gameplay/UI API. Item instantiation and trade consumers now go through narrow `ItemManager.GetCatalogEntry` and `GetCatalogEntries` methods. This does not remove the legacy reader under the hood; it prevents old catalog authority from leaking into every caller @@ -97,6 +97,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. corporation projection. The `give` command selects matching items from the typed runtime catalog, then temporarily hydrates the selected legacy `EquippableItemData` by ID only for `ItemManager.CreateInstance`. + `LoadoutGenerator` also receives the typed runtime catalog and uses it to own + item candidate selection before hydrating selected legacy item DTOs by ID for + exact fitting checks and behavior construction. - `Galaxy` generation no longer accepts `ILegacyCatalogReader` or `ItemManager`. Sector and tutorial generation receive the package-owned typed runtime catalog. `Galaxy` projects typed corporation v2 records into temporary legacy @@ -197,6 +200,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. - The `give` command no longer enumerates legacy item catalog entries; typed catalog selection owns the command match, with legacy item hydration kept as an instantiation-only bridge. +- `LoadoutGenerator` no longer enumerates legacy item catalog entries for its + candidate pool; typed catalog filtering owns the first item selection pass, + with legacy DTO hydration kept as a fitting/instantiation bridge. - MessagePack is no longer used as a runtime object-cloning shortcut for `EntitySettings`, and UI/player-settings startup no longer registers the old MessagePack resolver. Resolver registration is confined to legacy catalog @@ -255,9 +261,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. contract for full .NET smokes and Eve surface reads. Neither writes state or owns simulation. The legacy cache no longer has a public mutation surface, but it still materializes `ItemManager`. Item properties manufacturer display is - a typed snapshot consumer; the give console command is a typed-selection - consumer with temporary legacy item instantiation; trade debug and loadout - item selection still use `ItemManager` legacy item-domain materialization. + a typed snapshot consumer; the give console command and loadout generation + are typed-selection consumers with temporary legacy item instantiation; trade + debug still uses `ItemManager` legacy item-domain materialization. - Inputs: Unity gameplay code, legacy catalog files, typed state documents, and CultMesh server state. - Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy @@ -412,6 +418,9 @@ First Aetheria surfaces to publish: - 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 `LoadoutGenerator` item candidate selection to the typed + runtime catalog; legacy item DTO hydration remains only for exact fitting + checks and behavior construction. - Replace `ActionGameManager` cache bootstrap with the new state runtime. - Convert domain references from GUID/base-class patterns to typed record refs.