Skip to content

Commit

Permalink
Fix issue with late action hook registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Oct 15, 2024
1 parent ee149e3 commit fd1afa7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion HKMP/Fsm/FsmPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tk2dWatchAnimationEvents>("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 {
Expand Down
3 changes: 2 additions & 1 deletion HKMP/Game/Client/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit fd1afa7

Please sign in to comment.