From 37f4ef4a1290bb4c47b91870de113c8306bd7b27 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 10:29:17 +0100 Subject: [PATCH] Route runtime behavior construction through item manager --- .voidbot/state/aetheria.cc | Bin 84406 -> 84802 bytes .../AetheriaRuntimeItemCatalog.cs | 4 +-- .../ServerShared/Behaviors/StatModifier.cs | 4 +-- Assets/Scripts/ServerShared/Entity.cs | 8 ++---- Assets/Scripts/ServerShared/ItemManager.cs | 23 ++++++++++++++++-- docs/aetheria-perfect-machine-map.md | 14 ++++++++--- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 726e0aeec49e424adf50eecbed6d550ab7903ced..e3bf1a9356513b9e85bfcb569b4240aac606d6d6 100644 GIT binary patch delta 1836 zcma)7-D@0G6z8UirhWvACed2zm6qBCGfCX0n~$ccNuym#n~>JhisIazIkR)k?49-A zJJ~K27R_s)9O=A?MWi4W6|4n8DFy!k9~<-!5TA`0zCKJQ)d*2Oo7!|AmE|rncyaCi>jt*s;HYIOx%{O3?ns|Ac)Eye zgsQ-73=z{*Gg$|XxQ6Rd6X%S7`gP>^I!9!b=0QLe1c;?dC&9rp@(Ny&LZuA$+y!dK zzpU>+WLvj1U?3D*gdl3$s>sS=b1M05ioARwti7KW=0bxM$O85Y4#R})4ry8+IYp8I z+1IpW3!HgXD#GEZRGBK86551@0Q4XhIuhIY@bdhrJ3C z!D<*ynQ{mnhro?LTz>A*7CCl0Oxt0uO9ixY!KL~Dsc7gW`wo-Q2_yYXX$bp&2<$wT ziNC!w(oudG1!$@;GTr$2Tlc%7`&Z2wJsZUdxN2a^t>h84l)a zNNE{48u_CwuKna*g^VN{2g$QfTVEm=ekj+#Q=cR&{=M(zuw3U?w< z@#>`m@u}8mQko@)pD7zLrnbn|LrT#Th9aCAmrb(r3R#Ogm7z|LXt!5c+Dg~S-7y}~ zT1|4d4%Sz&frdck7^ptp{9Jf@=wf!xBVH?C^<5?dEQ7oNQGxsy8Ta7&g~`+aYsjGkYu=Wfez3t20Q^WwJBbo!FVlm}FWPg(4oj zcpEVO15ywwUeu!x@G5%pfmiIZXZ;Hbnl5u%M% zJERV7P?xMQF7Pr79LyXVD5l!wXSPR}{{wxt;xEgCyDaRJP-Z1o{IztTuY3*)EWARz zh{6unucpw!H7Ju3{t18ud=*PYd?=*EcCpQaCTrnUrd+ICqB1yhaT!}z6;bE8!{tw&W2^Y@3G49P?<4*llc` zB#KyAM$IO>3qA6{YhxlY^FuCF3Z__td4>SI=u*tR4uYb9@c=JVsDa_kmUSW{F9&X< z^J8g~;3%|B3=|HDawV{VJsz~Ez><2@R#-$pwNEz{$oR=Mz)es^xlASi<#j~^2_1aj z_~Y7~a;cc7cMPNcF#rMGi7ExNSB3)UAMGTh@fl7 zQU5Jhw6NK~*tiY$m-qkE3HS5+j7yB>n}T=VrpHFmp?duSPm8dcH6?ky;0T3xTAh3?91ML(*d*`W<-66I%)*30ynDHUPRzpAK~Kire? z=kCGmXL2HWp*5XH?{=gQ`;>lHL;GUhy GetRuntimeBehaviorConfigs(Guid guid); + IReadOnlyList GetTemporaryBehaviorConfigs(Guid guid); } public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader @@ -65,7 +65,7 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader return item; } - public IReadOnlyList GetRuntimeBehaviorConfigs(Guid guid) + public IReadOnlyList GetTemporaryBehaviorConfigs(Guid guid) { var item = GetRuntimeItem(guid); return item == null diff --git a/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs b/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs index ab75d2e8b..7c34d0836 100644 --- a/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs +++ b/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs @@ -55,7 +55,7 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa _stats = Entity.Equipment .Select(hp => hp.EquippableItem) .Where(HasRequiredBehavior) - .SelectMany(gear => ItemManager.GetRuntimeBehaviorConfigs(gear)) + .SelectMany(gear => ItemManager.GetTemporaryRuntimeBehaviorConfigs(gear)) .Where(behavior => BehaviorKindMatches(behavior.Kind, _data.Stat.Target)) .Select(FindTargetStat) .Where(stat => stat != null) @@ -93,7 +93,7 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa private bool HasRequiredBehavior(EquippableItem gear) { return string.IsNullOrWhiteSpace(_data.RequireBehavior) || - ItemManager.GetRuntimeBehaviorConfigs(gear) + ItemManager.GetTemporaryRuntimeBehaviorConfigs(gear) .Any(behavior => BehaviorKindMatches(behavior.Kind, _data.RequireBehavior)); } diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 96ca3bfa4..0f280b0d6 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -1188,9 +1188,7 @@ public class ConsumableItemEffect _effectiveness = CreateEffectivenessCurve(RuntimeItem); RemainingDuration = _duration; - Behaviors = entity.ItemManager.GetRuntimeBehaviorConfigs(item) - .Select(bd => bd.CreateInstance(this)) - .ToArray(); + Behaviors = entity.ItemManager.CreateRuntimeBehaviors(this); } public void Update(float delta) @@ -1393,9 +1391,7 @@ public class EquippedItem .CombineLatest(Online, (enabled, online) => enabled && online).DistinctUntilChanged()); - Behaviors = ItemManager.GetRuntimeBehaviorConfigs(item) - .Select(bd => bd.CreateInstance(this)) - .ToArray(); + Behaviors = ItemManager.CreateRuntimeBehaviors(this); BehaviorGroups = Behaviors .GroupBy(b => b.Data.Group) diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 35fe300e1..7b5b77b9f 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -64,12 +64,31 @@ public class ItemManager return itemId == Guid.Empty ? null : _runtimeItems.GetRuntimeItem(itemId); } - public IReadOnlyList GetRuntimeBehaviorConfigs(ItemInstance item) + public IReadOnlyList GetTemporaryRuntimeBehaviorConfigs(ItemInstance item) { var itemId = item?.Data?.ItemId ?? Guid.Empty; return itemId == Guid.Empty ? Array.Empty() - : _runtimeItems.GetRuntimeBehaviorConfigs(itemId); + : _runtimeItems.GetTemporaryBehaviorConfigs(itemId); + } + + public Behavior[] CreateRuntimeBehaviors(EquippedItem item) + { + return CreateRuntimeBehaviorConfigs(item?.EquippableItem) + .Select(config => config.CreateInstance(item)) + .ToArray(); + } + + public Behavior[] CreateRuntimeBehaviors(ConsumableItemEffect effect) + { + return CreateRuntimeBehaviorConfigs(effect?.Item) + .Select(config => config.CreateInstance(effect)) + .ToArray(); + } + + private IReadOnlyList CreateRuntimeBehaviorConfigs(ItemInstance item) + { + return GetTemporaryRuntimeBehaviorConfigs(item); } public Shape GetRuntimeShape(ItemInstance item) diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index e15d642a4..63ac68e3b 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -158,8 +158,10 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. receives the typed runtime catalog and uses typed candidate-kind selectors for item selection and instantiation. Hull type, hardpoint type, shape fit, station bay fit, hull/category, and behavior-kind prefilters run against typed - catalog rows; the remaining behavior bridge builds temporary `BehaviorData` - config from typed payloads only at behavior-constructor boundaries. The unused `TradeMenuDebug` + catalog rows. `EquippedItem` and `ConsumableItemEffect` now create behavior + instances through `ItemManager.CreateRuntimeBehaviors`; the remaining + `BehaviorData` config list is explicitly temporary and exposed only for the + surviving `StatModifier` stat-target bridge. The unused `TradeMenuDebug` script has been deleted instead of preserving an old uGUI debug path that turned typed trade rows back into legacy `ItemData` objects. That hydration now comes from typed state, not `AetherDB.msgpack`. The surviving trade menu @@ -530,7 +532,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. owns simulation. The runtime no longer has a MessagePack catalog cache or whole-item DTO projection cache. `AetheriaRuntimeItemCatalog` exposes typed item rows and temporarily builds `BehaviorData` config objects from typed - behavior payloads for the old behavior class constructors. + behavior payloads behind the `ItemManager.CreateRuntimeBehaviors` runtime + construction primitive. Direct config reads are named temporary and remain + only where `StatModifier` still needs behavior-stat target lookup. `RuntimeItemReference.ItemId` is the only item reference value. The reader interface for this bridge is named `IRuntimeItemCatalogReader` so callers see typed catalog row ownership rather than old DTO projection ownership. Behavior @@ -804,6 +808,10 @@ First Aetheria surfaces to publish: off `Data.Behaviors` and onto typed runtime behavior payload config construction; `BehaviorData` remains only the temporary behavior-class config bridge. + - Done: route `EquippedItem` and `ConsumableItemEffect` behavior instance + creation through `ItemManager.CreateRuntimeBehaviors`; direct + `GetTemporaryRuntimeBehaviorConfigs` access remains only for the + `StatModifier` behavior-stat target bridge. - Done: move the temporary behavior config constructor map from legacy union keys to typed behavior payload kind strings; union keys remain migration provenance only for this runtime path.