Re-wrote IsInGame function with good code practice

This commit is contained in:
ALittlePatate
2022-03-27 19:20:07 +02:00
parent 8b17b26353
commit 20e598c569
3 changed files with 4 additions and 14 deletions

View File

@@ -136,6 +136,7 @@ namespace DevourClient.Hacks
public PlayRandomAudioClip burnGoatClips; public PlayRandomAudioClip burnGoatClips;
public PlayRandomAudioClip laughClips; public PlayRandomAudioClip laughClips;
*/ */
PlayRandomAudioClip playRandomAudioClip = UnityEngine.Object.FindObjectOfType<PlayRandomAudioClip>(); PlayRandomAudioClip playRandomAudioClip = UnityEngine.Object.FindObjectOfType<PlayRandomAudioClip>();
NolanVoiceOvers nolanVoiceOvers = UnityEngine.Object.FindObjectOfType<NolanVoiceOvers>(); NolanVoiceOvers nolanVoiceOvers = UnityEngine.Object.FindObjectOfType<NolanVoiceOvers>();

View File

@@ -4,20 +4,8 @@
{ {
public static bool IsInGame() public static bool IsInGame()
{ {
//Code pas très beau ici OptionsHelpers optionsHelpers = UnityEngine.Object.FindObjectOfType<OptionsHelpers>();
//La variable gameStarted dans la classe Horror.Menu n'existe plus quand on lance une game return optionsHelpers.inGame;
//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<Horror.Menu>();
return menu_class.gameStarted;
}
catch
{
return true;
}
} }
} }
} }

View File

@@ -137,6 +137,7 @@ namespace DevourClient
if (GUI.Button(new Rect(Settings.Settings.x + 200, Settings.Settings.y + 160, 150, 20), "Random sound")) if (GUI.Button(new Rect(Settings.Settings.x + 200, Settings.Settings.y + 160, 150, 20), "Random sound"))
{ {
Hacks.Misc.PlaySound(); Hacks.Misc.PlaySound();
MelonLogger.Msg("Playing a random sound !");
} }
} }