Use typed behavior metadata for modifier matching

This commit is contained in:
Meta Vens 2026-06-14 10:42:31 +01:00
commit 2ad4596d94
3 changed files with 24 additions and 14 deletions

View file

@ -4,6 +4,8 @@
using System;
using System.Linq;
using GameCult.Aetheria.State.Unity;
[Inspectable]
public class StatModifierData : BehaviorData
{
@ -74,20 +76,23 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa
}
private static bool BehaviorKindMatches(string runtimeKind, string expectedKind)
{
return AetheriaRuntimeBehaviorMetadataCatalog.IsKindOrDescendant(
runtimeKind,
NormalizeExpectedBehaviorKind(expectedKind));
}
private static string NormalizeExpectedBehaviorKind(string expectedKind)
{
if (string.IsNullOrWhiteSpace(expectedKind))
{
return false;
}
if (string.Equals(runtimeKind, expectedKind, StringComparison.Ordinal))
{
return true;
return "";
}
const string legacyDataSuffix = "Data";
return expectedKind.EndsWith(legacyDataSuffix, StringComparison.Ordinal) &&
string.Equals(runtimeKind, expectedKind.Substring(0, expectedKind.Length - legacyDataSuffix.Length), StringComparison.Ordinal);
return expectedKind.EndsWith(legacyDataSuffix, StringComparison.Ordinal)
? expectedKind.Substring(0, expectedKind.Length - legacyDataSuffix.Length)
: expectedKind;
}
private bool HasRequiredBehavior(EquippedItem gear)