Check Enum has key before trying getValue

This commit is contained in:
CWX
2025-04-07 13:29:49 +01:00
parent d0c3f7fa48
commit d10238b006
@@ -97,8 +97,15 @@ public class HealthController(
// Can remove effects and limb has effects to remove
foreach (var effectKvP in bodyPartToHeal.Effects)
{
// Check enum has effectType
if (!Enum.TryParse<DamageEffectType>(effectKvP.Key, out var effect))
// Enum doesnt contain this key
{
continue;
}
// Check if healing item removes the effect on limb
if (!healItemEffectDetails.TryGetValue(Enum.Parse<DamageEffectType>(effectKvP.Key), out var matchingEffectFromHealingItem))
if (!healItemEffectDetails.TryGetValue(effect, out var matchingEffectFromHealingItem))
// Healing item doesn't have matching effect, it doesn't remove the effect
{
continue;