Use typed behavior metadata for modifier matching
This commit is contained in:
parent
f403ab28a7
commit
2ad4596d94
3 changed files with 24 additions and 14 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue