diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 57c09ee1f..5e52af41c 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs b/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs index 89d3fd1a9..f5e94f4d1 100644 --- a/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs +++ b/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs @@ -9,6 +9,7 @@ using Unity.Mathematics; public interface IRuntimeItemProjectionReader { AetheriaRuntimeCatalogItem GetRuntimeItem(Guid guid); + IReadOnlyList GetBehaviorProjections(Guid guid); ItemData Get(Guid guid); T Get(Guid guid) where T : ItemData; } @@ -72,6 +73,14 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader return item; } + public IReadOnlyList GetBehaviorProjections(Guid guid) + { + var item = GetRuntimeItem(guid); + return item == null + ? Array.Empty() + : ProjectBehaviors(item); + } + public ItemData Get(Guid guid) { ItemData item; @@ -115,10 +124,7 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader if (projected is EquippableItemData equippable) { equippable.Durability = (float)item.Durability; - equippable.Behaviors = item.BehaviorPayloads - .Select(ProjectBehavior) - .Where(behavior => behavior != null) - .ToList(); + equippable.Behaviors = ProjectBehaviors(item).ToList(); } if (projected is GearData gear) @@ -158,6 +164,14 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader return projected; } + private static BehaviorData[] ProjectBehaviors(AetheriaRuntimeCatalogItem item) + { + return item.BehaviorPayloads + .Select(ProjectBehavior) + .Where(behavior => behavior != null) + .ToArray(); + } + private static ItemData CreateItemData(AetheriaRuntimeCatalogItem item) { switch (item.Category) diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 84b811045..4c141a8b3 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -1217,7 +1217,7 @@ public class ConsumableItemEffect Data = entity.ItemManager.GetData(item) as ConsumableItemData; RemainingDuration = Data.Duration; - Behaviors = Data.Behaviors + Behaviors = entity.ItemManager.GetRuntimeBehaviorProjections(item) .Select(bd => bd.CreateInstance(this)) .ToArray(); } @@ -1391,7 +1391,7 @@ public class EquippedItem .CombineLatest(Online, (enabled, online) => enabled && online).DistinctUntilChanged()); - Behaviors = Data.Behaviors + Behaviors = ItemManager.GetRuntimeBehaviorProjections(item) .Select(bd => bd.CreateInstance(this)) .ToArray(); diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 8e8cafa3c..ff72d8e07 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -69,6 +69,14 @@ public class ItemManager return itemId == Guid.Empty ? null : _itemProjections.GetRuntimeItem(itemId); } + public IReadOnlyList GetRuntimeBehaviorProjections(ItemInstance item) + { + var itemId = item?.Data?.ItemId ?? Guid.Empty; + return itemId == Guid.Empty + ? Array.Empty() + : _itemProjections.GetBehaviorProjections(itemId); + } + public Shape GetRuntimeShape(ItemInstance item) { var typedItem = GetRuntimeItem(item); diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 7f17e4b3d..84c0f7716 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -191,8 +191,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. hydration is only the remaining item-instantiation bridge. Docking bay max ship size is imported as typed item state and `EquippedDockingBay.MaxSize` derives from the typed runtime catalog row. `EquippedItem.InsetShape` now - derives from typed hull/item shape rows. `EquippedItem` behavior construction - still belongs to legacy simulation projections until that owner is rebuilt. + derives from typed hull/item shape rows. `EquippedItem` and + `ConsumableItemEffect` behavior construction now read typed behavior payloads + through the runtime behavior projection bridge before instantiating the + current `BehaviorData`-backed behavior classes. `BehaviorData` remains the + temporary behavior-class config bridge, not the runtime behavior payload + owner. Ship drag, combat/turret shot prediction height, and thruster torque geometry now consume typed hull facets and typed shape masks. The item properties panel also reads typed catalog title names, descriptions, @@ -707,6 +711,9 @@ First Aetheria surfaces to publish: - Done: move `EquippedItem.InsetShape` construction onto typed hull and item shape rows; legacy `HullData.Shape`/`EquippableItemData.Shape` no longer decide equipped-item temperature footprint geometry. + - Done: move `EquippedItem` and `ConsumableItemEffect` behavior construction + off `Data.Behaviors` and onto typed runtime behavior payload projection; + `BehaviorData` remains only the temporary behavior-class config bridge. - Done: move final `Entity.ItemFits`, `TryFindSpace`, `TryEquip`, and `TryUnequip` gear occupancy/mass deltas onto typed catalog rows for item shape, hull shape/interior, hardpoint masks, cargo/docking category, and