diff --git a/HarmonySrc/FpArms.cs b/HarmonySrc/FpArms.cs index add7835..e3c2418 100644 --- a/HarmonySrc/FpArms.cs +++ b/HarmonySrc/FpArms.cs @@ -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()); } } + + /// Скрипт состояния удара в аниматоре рук (AnimatorMeleeAttackState) берёт персонажа через + /// AnimationEventBridge и бьёт предметом в его руке. У рук одержимого моста нет (FpArms снимает скрипты) - без этой + /// заплатки NullReferenceException на каждом ударе (тест 13.10), а с мостом руки зомби били бы предметом тела. + /// У рук персонажа мост есть всегда - их не трогаем. + [HarmonyPatch(typeof(AnimatorMeleeAttackState))] + public static class Patch_AnimatorMeleeAttackState_FpArms + { + static bool Ours(Animator _a) => _a != null && _a.GetComponent() == 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); + } }