diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index d88d87ec1..28d51eeb4 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 280ec3a89..3140c3636 100644 --- a/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs +++ b/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs @@ -106,6 +106,7 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader return null; } + behavior.Kind = payload.Kind; behavior.Group = payload.Group; foreach (var field in GetKeyedFields(behaviorType)) diff --git a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs index 99481c389..9e72b19b3 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs @@ -136,6 +136,8 @@ public interface IPopulationAssignment [Inspectable] public abstract class BehaviorData { + public string Kind { get; set; } = ""; + [Inspectable, LegacyPayloadKey(0)] public int Group; diff --git a/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs b/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs index 08617a7cc..ab75d2e8b 100644 --- a/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs +++ b/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs @@ -17,7 +17,7 @@ public class StatModifierData : BehaviorData public StatModifierType Type; [InspectableType(typeof(BehaviorData)), LegacyPayloadKey(4)] - public Type RequireBehavior; + public string RequireBehavior; public override Behavior CreateInstance(EquippedItem item) { @@ -37,13 +37,9 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa private PerformanceStat[] _stats; - private static Type[] _statObjects; - private bool _applied; private bool _executed; - private static Type[] StatObjects => _statObjects = _statObjects ?? typeof(BehaviorData).GetAllChildClasses().ToArray(); - public StatModifier(StatModifierData data, EquippedItem item) : base(data, item) { _data = data; @@ -56,29 +52,49 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa public void Initialize() { - var targetType = StatObjects.FirstOrDefault(so => so.Name == _data.Stat.Target); - if (targetType != null) + _stats = Entity.Equipment + .Select(hp => hp.EquippableItem) + .Where(HasRequiredBehavior) + .SelectMany(gear => ItemManager.GetRuntimeBehaviorConfigs(gear)) + .Where(behavior => BehaviorKindMatches(behavior.Kind, _data.Stat.Target)) + .Select(FindTargetStat) + .Where(stat => stat != null) + .ToArray(); + } + + private PerformanceStat FindTargetStat(BehaviorData behavior) + { + var statField = behavior + .GetType() + .GetFields() + .Where(f => f.FieldType == typeof(PerformanceStat)) + .FirstOrDefault(f => f.Name == _data.Stat.Stat); + + return statField?.GetValue(behavior) as PerformanceStat; + } + + private static bool BehaviorKindMatches(string runtimeKind, string expectedKind) + { + if (string.IsNullOrWhiteSpace(expectedKind)) { - var statField = targetType.GetFields() - .Where(f => f.FieldType == typeof(PerformanceStat)).FirstOrDefault(f => f.Name == _data.Stat.Stat); - if (statField != null) - { - _stats = Entity.Equipment - .Select(hp => hp.EquippableItem) - .Where(HasRequiredBehavior) - .SelectMany(gear => ItemManager.GetRuntimeBehaviorConfigs(gear)) - .Where(behaviorData => behaviorData.GetType() == targetType) - .Select(behaviorData => statField.GetValue(behaviorData) as PerformanceStat) - .ToArray(); - } + return false; } + + if (string.Equals(runtimeKind, expectedKind, StringComparison.Ordinal)) + { + return true; + } + + const string legacyDataSuffix = "Data"; + return expectedKind.EndsWith(legacyDataSuffix, StringComparison.Ordinal) && + string.Equals(runtimeKind, expectedKind.Substring(0, expectedKind.Length - legacyDataSuffix.Length), StringComparison.Ordinal); } private bool HasRequiredBehavior(EquippableItem gear) { - return _data.RequireBehavior == null || + return string.IsNullOrWhiteSpace(_data.RequireBehavior) || ItemManager.GetRuntimeBehaviorConfigs(gear) - .Any(behavior => behavior.GetType() == _data.RequireBehavior); + .Any(behavior => BehaviorKindMatches(behavior.Kind, _data.RequireBehavior)); } private void ApplyModifier() diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 2522547f5..b5c2b76b1 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -211,9 +211,11 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. through the runtime behavior config bridge before instantiating the current `BehaviorData`-backed behavior classes. `BehaviorData` remains the temporary behavior-class config bridge, not the runtime behavior payload - owner. `StatModifier` behavior requirements and behavior-stat targets also - read that typed behavior config bridge instead of hydrating - `EquippableItemData.Behaviors`. `ConsumableItemData` and + owner; bridge instances carry the typed behavior payload kind so runtime + logic does not have to reselect behavior identity from the old class graph. + `StatModifier` behavior requirements and behavior-stat targets compare typed + behavior kinds from that bridge instead of scanning `BehaviorData` subclasses + or hydrating `EquippableItemData.Behaviors`. `ConsumableItemData` and `EquippableItemData` no longer expose legacy `Behaviors` lists at all. The old item-DTO stat branch was deleted after inspection showed no active `PerformanceStat` fields on the live equippable item DTO hierarchy. @@ -792,9 +794,11 @@ First Aetheria surfaces to publish: keys to typed behavior payload kind strings; union keys remain migration provenance only for this runtime path. - Done: move `StatModifier` behavior requirements and behavior-stat targets - off `EquippableItemData.Behaviors` and onto typed runtime behavior config; - the obsolete item-DTO stat target branch is deleted because the live - equippable item DTO hierarchy has no active `PerformanceStat` fields. + off `EquippableItemData.Behaviors` and old `BehaviorData` subclass + identity checks. Temporary behavior configs carry typed payload kinds, and + `StatModifier` matches those kind strings for target and requirement + selection. The obsolete item-DTO stat target branch is deleted because the + live equippable item DTO hierarchy has no active `PerformanceStat` fields. - Done: delete the legacy `Behaviors` lists from `ConsumableItemData` and `EquippableItemData`; item DTOs can no longer carry behavior config state. - Done: move runtime blueprint price aggregation and conductivity restore