From fd1afa796d99ed2f6846cf851fa8715f67c23cb6 Mon Sep 17 00:00:00 2001 From: Extremelyd1 <10898310+Extremelyd1@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:45:36 +0200 Subject: [PATCH] Fix issue with late action hook registration --- HKMP/Fsm/FsmPatcher.cs | 7 ++++++- HKMP/Game/Client/Entity/Entity.cs | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/HKMP/Fsm/FsmPatcher.cs b/HKMP/Fsm/FsmPatcher.cs index 46aad80..f68b183 100644 --- a/HKMP/Fsm/FsmPatcher.cs +++ b/HKMP/Fsm/FsmPatcher.cs @@ -75,7 +75,12 @@ private void OnFsmEnable(On.PlayMakerFSM.orig_OnEnable orig, PlayMakerFSM self) // Get the original watch animation action for the FSM event it sends var watchAnimationAction = self.GetFirstAction("End Challenge"); - + // If the action was already removed before (maybe because the OnEnable triggers multiple times) + // we don't have to do anything anymore + if (watchAnimationAction == null) { + return; + } + // Insert a wait action that takes exactly the duration of the animation and sends the original event // when it finishes self.InsertAction("End Challenge", new Wait { diff --git a/HKMP/Game/Client/Entity/Entity.cs b/HKMP/Game/Client/Entity/Entity.cs index 4983f22..551bbbe 100644 --- a/HKMP/Game/Client/Entity/Entity.cs +++ b/HKMP/Game/Client/Entity/Entity.cs @@ -308,7 +308,8 @@ private void ProcessHostFsm(PlayMakerFSM fsm) { MonoBehaviourUtil.Instance.StartCoroutine(WaitForActionInitialization()); IEnumerator WaitForActionInitialization() { while (checkFunc.Invoke()) { - if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != sceneName) { + if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != + global::GameManager.GetBaseSceneName(sceneName)) { yield break; }