From 20e598c5698e3f6fc796dff0f43728af1507483c Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Sun, 27 Mar 2022 19:20:07 +0200 Subject: [PATCH] Re-wrote IsInGame function with good code practice --- DevourClient/Hacks/Misc.cs | 1 + DevourClient/Helpers/StateHelper.cs | 16 ++-------------- DevourClient/MelonMain.cs | 1 + 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/DevourClient/Hacks/Misc.cs b/DevourClient/Hacks/Misc.cs index 95d94c1..0666e90 100644 --- a/DevourClient/Hacks/Misc.cs +++ b/DevourClient/Hacks/Misc.cs @@ -136,6 +136,7 @@ namespace DevourClient.Hacks public PlayRandomAudioClip burnGoatClips; public PlayRandomAudioClip laughClips; */ + PlayRandomAudioClip playRandomAudioClip = UnityEngine.Object.FindObjectOfType(); NolanVoiceOvers nolanVoiceOvers = UnityEngine.Object.FindObjectOfType(); diff --git a/DevourClient/Helpers/StateHelper.cs b/DevourClient/Helpers/StateHelper.cs index dfa7329..694aaa8 100644 --- a/DevourClient/Helpers/StateHelper.cs +++ b/DevourClient/Helpers/StateHelper.cs @@ -4,20 +4,8 @@ { public static bool IsInGame() { - //Code pas très beau ici - //La variable gameStarted dans la classe Horror.Menu n'existe plus quand on lance une game - //Donc si elle existe on retourne sa valeur (qui est false) - //Et si elle existe pas (donc si on est ingame) on retourne true - - try - { - Horror.Menu menu_class = UnityEngine.ScriptableObject.FindObjectOfType(); - return menu_class.gameStarted; - } - catch - { - return true; - } + OptionsHelpers optionsHelpers = UnityEngine.Object.FindObjectOfType(); + return optionsHelpers.inGame; } } } diff --git a/DevourClient/MelonMain.cs b/DevourClient/MelonMain.cs index 2815696..d3f6cd7 100644 --- a/DevourClient/MelonMain.cs +++ b/DevourClient/MelonMain.cs @@ -137,6 +137,7 @@ namespace DevourClient if (GUI.Button(new Rect(Settings.Settings.x + 200, Settings.Settings.y + 160, 150, 20), "Random sound")) { Hacks.Misc.PlaySound(); + MelonLogger.Msg("Playing a random sound !"); } }