Use typed payloads for behavior construction

This commit is contained in:
Meta Vens 2026-06-14 05:51:15 +01:00
commit 18dc4a61ce
5 changed files with 37 additions and 8 deletions

Binary file not shown.

View file

@ -9,6 +9,7 @@ using Unity.Mathematics;
public interface IRuntimeItemProjectionReader
{
AetheriaRuntimeCatalogItem GetRuntimeItem(Guid guid);
IReadOnlyList<BehaviorData> GetBehaviorProjections(Guid guid);
ItemData Get(Guid guid);
T Get<T>(Guid guid) where T : ItemData;
}
@ -72,6 +73,14 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemProjectionReader
return item;
}
public IReadOnlyList<BehaviorData> GetBehaviorProjections(Guid guid)
{
var item = GetRuntimeItem(guid);
return item == null
? Array.Empty<BehaviorData>()
: 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)

View file

@ -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();

View file

@ -69,6 +69,14 @@ public class ItemManager
return itemId == Guid.Empty ? null : _itemProjections.GetRuntimeItem(itemId);
}
public IReadOnlyList<BehaviorData> GetRuntimeBehaviorProjections(ItemInstance item)
{
var itemId = item?.Data?.ItemId ?? Guid.Empty;
return itemId == Guid.Empty
? Array.Empty<BehaviorData>()
: _itemProjections.GetBehaviorProjections(itemId);
}
public Shape GetRuntimeShape(ItemInstance item)
{
var typedItem = GetRuntimeItem(item);

View file

@ -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