From 301b1251b182b6fc30a364dc9b5ff443489bb275 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 09:38:55 +0100 Subject: [PATCH] Use typed runtime item category tokens --- .voidbot/state/aetheria.cc | Bin 84295 -> 84712 bytes .../Aetheria.State.Unity.csproj | 1 + Assets/Scripts/Gameplay/ActionGameManager.cs | 2 +- Assets/Scripts/ServerShared/Entity.cs | 6 +++--- Assets/Scripts/ServerShared/ItemManager.cs | 4 ++-- .../Scripts/ServerShared/LoadoutGenerator.cs | 20 ++++++------------ Assets/Scripts/Zone Display/ZoneRenderer.cs | 2 +- .../Runtime/AetheriaRuntimeItemCategories.cs | 12 +++++++++++ docs/aetheria-perfect-machine-map.md | 8 ++++++- 9 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeItemCategories.cs diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 54d048ce2e62c5e272bb9ec8619ab006532fcdde..ce6050a150d8318f421103320e5f342c7f1e8fe4 100644 GIT binary patch delta 1672 zcmZ`)&2Jk;6xYNFZ6pNc;G|6|^2A3V#UF9v+KEMi)Ff(qAXrhVNFfJLcE{_%>z(b) zIL4w6eXM-oEWHle`9L! z!PFp0O`nx*PxBVba?M&qdBr`uHj78z!M$76AE;L!4;3|ZnjP>?m5t7 zb`%NfLV_hc)o#&kmt~;QcHIm(jLHmj81;ph!86hkuuZ!epq>r3u$l%E1926*Qgl=f zF47kBUE0mNg4&|3^S#7;j04D7DPHGT3>O}91y^_ulcs6~H4l%A`kPCAGMBMK%T&{; zTBiT?64E;w+nA4d9!$rg6kem5#O6ub*)LmZiQE-X1uowSUo4aKnY$XtgOr{=TgSFV zEruQHwpnnVZXEh$&?m&q>l)Sxy-^?aD62``DCNP zJfOC1rh|Zy`VwhThjLG8s0Dk~k+f-6ZmE}o{WX;x(GvC$p@8-Ti8^B1kTB9p*cwDe zZ4h-7QOl>Mw~*ZAG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N$!9)9iXX5q1x7xmwS0QxOO35R`#OMUx8>TC(DSLu z=C5s%S_o?}7yt45iwxqO_ow4;F1{4symh$Qe24b%nbm#NM_L;vho(b%dWW|^sj~Bo zHIu(;Y-+lwd)Rdm@e4ag6Q|CCLv?q~tvS`kiP>6pc0KuVflW?70exk8U_SqrBdMh& zkLwSQB`=S&@u{D5zGrl}vK#b$rhkQY$0lDau-6Xkrb&KTWRt};tiF+6!(@Ds-7Aoq kTO7>2$v=y%TcY(W?!!0PM + diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index b86c4998b..e091c5519 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -765,7 +765,7 @@ public class ActionGameManager : MonoBehaviour { var typedItem = FindTypedActionBarItem(item); return typedItem != null && - string.Equals(typedItem.Category, nameof(ConsumableItemData), StringComparison.Ordinal) + string.Equals(typedItem.Category, AetheriaRuntimeItemCategories.Consumable, StringComparison.Ordinal) ? typedItem : null; } diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 43ff1841c..96ca3bfa4 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -613,13 +613,13 @@ public abstract class Entity private static bool IsCargoBay(AetheriaRuntimeCatalogItem typedItem) { return typedItem != null && - (string.Equals(typedItem.Category, "CargoBayData", StringComparison.Ordinal) || - string.Equals(typedItem.Category, "DockingBayData", StringComparison.Ordinal)); + (string.Equals(typedItem.Category, AetheriaRuntimeItemCategories.CargoBay, StringComparison.Ordinal) || + string.Equals(typedItem.Category, AetheriaRuntimeItemCategories.DockingBay, StringComparison.Ordinal)); } private static bool IsDockingBay(AetheriaRuntimeCatalogItem typedItem) { - return typedItem != null && string.Equals(typedItem.Category, "DockingBayData", StringComparison.Ordinal); + return typedItem != null && string.Equals(typedItem.Category, AetheriaRuntimeItemCategories.DockingBay, StringComparison.Ordinal); } private static Shape ToShape(int width, int height, IReadOnlyList cells) diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 0ebb9fbeb..35fe300e1 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -227,7 +227,7 @@ public class ItemManager throw new NullReferenceException("Attempted to create crafted item instance using missing typed item data!"); } - if (string.Equals(item.Category, nameof(ConsumableItemData), StringComparison.Ordinal)) + if (string.Equals(item.Category, AetheriaRuntimeItemCategories.Consumable, StringComparison.Ordinal)) { return new ConsumableItem { @@ -292,7 +292,7 @@ public class ItemManager private static bool IsEquippable(AetheriaRuntimeCatalogItem item) { return !string.IsNullOrWhiteSpace(item?.HardpointType) || - string.Equals(item?.Category, nameof(HullData), StringComparison.Ordinal); + string.Equals(item?.Category, AetheriaRuntimeItemCategories.Hull, StringComparison.Ordinal); } public (RarityTier tier, int upgrades) GetTier(CraftedItemInstance item) diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index 9339f8ff7..1927cf08e 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -17,12 +17,6 @@ public class LoadoutGenerator Hull } - private const string GearCategory = "GearData"; - private const string WeaponCategory = "WeaponItemData"; - private const string CargoBayCategory = "CargoBayData"; - private const string DockingBayCategory = "DockingBayData"; - private const string HullCategory = "HullData"; - public Random Random; public ItemManager ItemManager { get; } public AetheriaRuntimeCatalogSnapshot RuntimeCatalog { get; } @@ -122,8 +116,8 @@ public class LoadoutGenerator var cargo = entity.CargoBays.First(); IEnumerable inventory = RandomCatalogItems(RuntimeItemCandidateKind.Equipment, 16, 1, - item => item.Category != CargoBayCategory && item.Category != DockingBayCategory && - (item.Category != HullCategory || item.HullType == nameof(HullType.Ship))); + item => item.Category != AetheriaRuntimeItemCategories.CargoBay && item.Category != AetheriaRuntimeItemCategories.DockingBay && + (item.Category != AetheriaRuntimeItemCategories.Hull || item.HullType == nameof(HullType.Ship))); inventory = inventory .Where(item => item != null); inventory = inventory @@ -190,13 +184,13 @@ public class LoadoutGenerator case RuntimeItemCandidateKind.Equipment: return !string.IsNullOrWhiteSpace(item.HardpointType); case RuntimeItemCandidateKind.Gear: - return item.Category == GearCategory || item.Category == WeaponCategory; + return item.Category == AetheriaRuntimeItemCategories.Gear || item.Category == AetheriaRuntimeItemCategories.Weapon; case RuntimeItemCandidateKind.CargoBay: - return item.Category == CargoBayCategory || item.Category == DockingBayCategory; + return item.Category == AetheriaRuntimeItemCategories.CargoBay || item.Category == AetheriaRuntimeItemCategories.DockingBay; case RuntimeItemCandidateKind.DockingBay: - return item.Category == DockingBayCategory; + return item.Category == AetheriaRuntimeItemCategories.DockingBay; case RuntimeItemCandidateKind.Hull: - return item.Category == HullCategory; + return item.Category == AetheriaRuntimeItemCategories.Hull; default: throw new ArgumentOutOfRangeException(nameof(candidateKind), candidateKind, null); } @@ -365,7 +359,7 @@ public class LoadoutGenerator var emptyShape = entity.UnoccupiedSpace; - var cargoRow = RandomCatalogItem(RuntimeItemCandidateKind.CargoBay, 3, item => item.Category != DockingBayCategory && FitsWithin(item, emptyShape)); + var cargoRow = RandomCatalogItem(RuntimeItemCandidateKind.CargoBay, 3, item => item.Category != AetheriaRuntimeItemCategories.DockingBay && FitsWithin(item, emptyShape)); if (cargoRow == null) throw new InvalidLoadoutException("No compatible cargo bay found for entity!"); ToShape(cargoRow).FitsWithin(emptyShape, out var cargoRotation, out var cargoPosition); diff --git a/Assets/Scripts/Zone Display/ZoneRenderer.cs b/Assets/Scripts/Zone Display/ZoneRenderer.cs index 8eb0ddd59..74bd497c4 100644 --- a/Assets/Scripts/Zone Display/ZoneRenderer.cs +++ b/Assets/Scripts/Zone Display/ZoneRenderer.cs @@ -606,7 +606,7 @@ public class ZoneRenderer : MonoBehaviour private static bool IsWeaponPickup(AetheriaRuntimeCatalogItem typedItem) { - return typedItem != null && string.Equals(typedItem.Category, nameof(WeaponItemData), StringComparison.Ordinal); + return typedItem != null && string.Equals(typedItem.Category, AetheriaRuntimeItemCategories.Weapon, StringComparison.Ordinal); } private static AetheriaRuntimeCatalogItem FindTypedZoneItem(ItemInstance item) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeItemCategories.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeItemCategories.cs new file mode 100644 index 000000000..d910cc236 --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeItemCategories.cs @@ -0,0 +1,12 @@ +namespace GameCult.Aetheria.State.Unity +{ + public static class AetheriaRuntimeItemCategories + { + public const string CargoBay = "CargoBayData"; + public const string Consumable = "ConsumableItemData"; + public const string DockingBay = "DockingBayData"; + public const string Gear = "GearData"; + public const string Hull = "HullData"; + public const string Weapon = "WeaponItemData"; + } +} diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 2760872e4..27236fed4 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -529,7 +529,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. interface for this bridge is named `IRuntimeItemCatalogReader` so callers see typed catalog row ownership rather than old DTO projection ownership. Behavior type selection now uses an explicit runtime catalog map instead of - `UnionAttribute` reflection. + `UnionAttribute` reflection. Runtime item category classification uses + package-owned `AetheriaRuntimeItemCategories` tokens; gameplay code should not + ask C# legacy DTO class names to classify typed catalog rows. Item/behavior DTO field layout for the temporary projection bridge is now marked with project-owned `LegacyPayloadKeyAttribute`, not MessagePack metadata. Item properties @@ -711,6 +713,10 @@ First Aetheria surfaces to publish: private typed candidate-kind selectors, so loadout code no longer asks for `HullData`, `GearData`, `CargoBayData`, or `EquippableItemData` as candidate-selection authority. + - Done: add package-owned `AetheriaRuntimeItemCategories` tokens and move + runtime category checks off `nameof(ConsumableItemData)`, + `nameof(HullData)`, `nameof(WeaponItemData)`, and scattered raw category + strings in gameplay/loadout/docking classification. - Done: delete unused `TradeMenuDebug`; the old debug uGUI trade path no longer hydrates typed trade rows back into legacy `ItemData` objects. - Done: move surviving trade menu size, hardpoint, and behavior filters onto