From 6b2f33a4e77b65530f1169e96b9407659c183edd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 25 May 2024 23:11:45 -0400 Subject: Prevent item receipt when paused --- AnodyneArchipelago/ArchipelagoManager.cs | 7 ++++++- AnodyneArchipelago/Patches/StatePatches.cs | 24 ++++++++++++++++++++++++ AnodyneArchipelago/Plugin.cs | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) (limited to 'AnodyneArchipelago') diff --git a/AnodyneArchipelago/ArchipelagoManager.cs b/AnodyneArchipelago/ArchipelagoManager.cs index 4570c39..8ee5584 100644 --- a/AnodyneArchipelago/ArchipelagoManager.cs +++ b/AnodyneArchipelago/ArchipelagoManager.cs @@ -111,7 +111,12 @@ namespace AnodyneArchipelago _itemIndex = _session.Items.AllItemsReceived.Count; } - if (_itemsToCollect.Count > 0 && (GlobalState.Dialogue == null || GlobalState.Dialogue == "") && !GlobalState.ScreenTransition && Plugin.Player != null && GlobalState.black_overlay.alpha == 0f) + if (_itemsToCollect.Count > 0 && + (GlobalState.Dialogue == null || GlobalState.Dialogue == "") && + !GlobalState.ScreenTransition && + Plugin.Player != null && + GlobalState.black_overlay.alpha == 0f && + !Plugin.IsGamePaused) { NetworkItem item = _itemsToCollect.Dequeue(); HandleItem(item); diff --git a/AnodyneArchipelago/Patches/StatePatches.cs b/AnodyneArchipelago/Patches/StatePatches.cs index 40b30fe..31c0aef 100644 --- a/AnodyneArchipelago/Patches/StatePatches.cs +++ b/AnodyneArchipelago/Patches/StatePatches.cs @@ -9,6 +9,7 @@ using AnodyneSharp.States.MainMenu; using static AnodyneSharp.AnodyneGame; using AnodyneSharp.Drawing; using System.IO; +using System; namespace AnodyneArchipelago.Patches { @@ -83,6 +84,8 @@ namespace AnodyneArchipelago.Patches { static void Prefix(PlayState __instance) { + Plugin.IsGamePaused = false; + // Get player for later access. FieldInfo playerField = typeof(PlayState).GetField("_player", BindingFlags.NonPublic | BindingFlags.Instance); Plugin.Player = (Player)playerField.GetValue(__instance); @@ -93,4 +96,25 @@ namespace AnodyneArchipelago.Patches GlobalState.events.SetEvent("red_cave_r_ss", 999); } } + + [HarmonyPatch(typeof(PauseState), MethodType.Constructor, new Type[] { })] + class CreatePausePatch + { + static void Postfix() + { + Plugin.IsGamePaused = true; + } + } + + [HarmonyPatch(typeof(PauseState), nameof(PauseState.Update))] + class UpdatePausePatch + { + static void Postfix(PauseState __instance) + { + if (__instance.Exit) + { + Plugin.IsGamePaused = false; + } + } + } } diff --git a/AnodyneArchipelago/Plugin.cs b/AnodyneArchipelago/Plugin.cs index 10a30b9..18f0d36 100644 --- a/AnodyneArchipelago/Plugin.cs +++ b/AnodyneArchipelago/Plugin.cs @@ -12,8 +12,10 @@ namespace AnodyneArchipelago public class Plugin : BasePlugin { public static Plugin Instance = null; + public static Player Player = null; public static ArchipelagoManager ArchipelagoManager = null; + public static bool IsGamePaused = false; public static string GetVersion() { -- cgit 1.4.1