Route runtime behavior construction through item manager
This commit is contained in:
parent
5196ee4c3c
commit
37f4ef4a12
6 changed files with 38 additions and 15 deletions
Binary file not shown.
|
|
@ -9,7 +9,7 @@ using Unity.Mathematics;
|
|||
public interface IRuntimeItemCatalogReader
|
||||
{
|
||||
AetheriaRuntimeCatalogItem GetRuntimeItem(Guid guid);
|
||||
IReadOnlyList<BehaviorData> GetRuntimeBehaviorConfigs(Guid guid);
|
||||
IReadOnlyList<BehaviorData> GetTemporaryBehaviorConfigs(Guid guid);
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
|
||||
|
|
@ -65,7 +65,7 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
|
|||
return item;
|
||||
}
|
||||
|
||||
public IReadOnlyList<BehaviorData> GetRuntimeBehaviorConfigs(Guid guid)
|
||||
public IReadOnlyList<BehaviorData> GetTemporaryBehaviorConfigs(Guid guid)
|
||||
{
|
||||
var item = GetRuntimeItem(guid);
|
||||
return item == null
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -64,12 +64,31 @@ public class ItemManager
|
|||
return itemId == Guid.Empty ? null : _runtimeItems.GetRuntimeItem(itemId);
|
||||
}
|
||||
|
||||
public IReadOnlyList<BehaviorData> GetRuntimeBehaviorConfigs(ItemInstance item)
|
||||
public IReadOnlyList<BehaviorData> GetTemporaryRuntimeBehaviorConfigs(ItemInstance item)
|
||||
{
|
||||
var itemId = item?.Data?.ItemId ?? Guid.Empty;
|
||||
return itemId == Guid.Empty
|
||||
? Array.Empty<BehaviorData>()
|
||||
: _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<BehaviorData> CreateRuntimeBehaviorConfigs(ItemInstance item)
|
||||
{
|
||||
return GetTemporaryRuntimeBehaviorConfigs(item);
|
||||
}
|
||||
|
||||
public Shape GetRuntimeShape(ItemInstance item)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue