Skip to content

Commit

Permalink
Only show the button for standard single player
Browse files Browse the repository at this point in the history
  • Loading branch information
qe201020335 committed Nov 15, 2024
1 parent 953309c commit 066f13d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions FailButton/HarmonyPatches/AddButtonToPauseMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ static class AddButtonToPauseMenu

static void Postfix(PauseMenuManager __instance)
{
__instance.StartCoroutine(DoTheFunny(__instance));
var gameplayManager = Resources.FindObjectsOfTypeAll<StandardLevelGameplayManager>().FirstOrDefault();
if (gameplayManager != null) __instance.StartCoroutine(DoTheFunny(__instance, gameplayManager));
}

static IEnumerator DoTheFunny(PauseMenuManager __instance)
static IEnumerator DoTheFunny(PauseMenuManager __instance, StandardLevelGameplayManager gameplayManager)
{
if (_b != null)
yield break;
Expand Down Expand Up @@ -52,13 +53,8 @@ static IEnumerator DoTheFunny(PauseMenuManager __instance)

b.onClick.AddListener(() =>
{
var s = Resources.FindObjectsOfTypeAll<StandardLevelGameplayManager>().FirstOrDefault();

if (s == null)
return;

s._initData.SetField(nameof(s._initData.continueGameplayWith0Energy), false);
s.HandleGameEnergyDidReach0();
gameplayManager._initData.SetField(nameof(gameplayManager._initData.continueGameplayWith0Energy), false);
gameplayManager.HandleGameEnergyDidReach0();
});

yield return null;
Expand Down

0 comments on commit 066f13d

Please sign in to comment.