Руки одержимого: скрипт удара аниматора пропускается у рук без AnimationEventBridge (NRE на каждом ударе)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AlexCube
2026-10-13 16:17:21 +03:00
co-authored by Claude Opus 5.5
parent 65f441bc19
commit c1f7d510e5
+20
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using HarmonyLib;
using System.Globalization;
using UnityEngine;
using UnityEngine.Scripting;
@@ -448,4 +449,23 @@ namespace NecromancerTome
Out(FpArms.Dump());
}
}
/// <summary>Скрипт состояния удара в аниматоре рук (AnimatorMeleeAttackState) берёт персонажа через
/// AnimationEventBridge и бьёт предметом в его руке. У рук одержимого моста нет (FpArms снимает скрипты) - без этой
/// заплатки NullReferenceException на каждом ударе (тест 13.10), а с мостом руки зомби били бы предметом тела.
/// У рук персонажа мост есть всегда - их не трогаем.</summary>
[HarmonyPatch(typeof(AnimatorMeleeAttackState))]
public static class Patch_AnimatorMeleeAttackState_FpArms
{
static bool Ours(Animator _a) => _a != null && _a.GetComponent<AnimationEventBridge>() == null;
[HarmonyPrefix, HarmonyPatch(nameof(AnimatorMeleeAttackState.OnStateEnter))]
public static bool Enter(Animator animator) => !Ours(animator);
[HarmonyPrefix, HarmonyPatch(nameof(AnimatorMeleeAttackState.OnStateUpdate))]
public static bool Update(Animator animator) => !Ours(animator);
[HarmonyPrefix, HarmonyPatch(nameof(AnimatorMeleeAttackState.OnStateExit))]
public static bool Exit(Animator animator) => !Ours(animator);
}
}