From 1a306e5ee13919548beea769ce91d608c5ecaf27 Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Sat, 10 Sep 2022 22:02:23 +0200 Subject: [PATCH] add: now using coroutines for demons --- DevourClient/Helpers/StateHelper.cs | 36 +++++++++++++++++++++++++++++ DevourClient/MelonMain.cs | 9 +++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/DevourClient/Helpers/StateHelper.cs b/DevourClient/Helpers/StateHelper.cs index e396a9f..01eb81c 100644 --- a/DevourClient/Helpers/StateHelper.cs +++ b/DevourClient/Helpers/StateHelper.cs @@ -48,6 +48,9 @@ namespace DevourClient.Helpers public static GoatBehaviour[] GoatsAndRats; public static SurvivalInteractable[] SurvivalInteractables; public static KeyBehaviour[] Keys; + public static SurvivalDemonBehaviour[] Demons; + public static SpiderBehaviour[] Spiders; + public static GhostBehaviour[] Ghosts; public static IEnumerator GetLocalPlayer() { @@ -115,5 +118,38 @@ namespace DevourClient.Helpers yield return new WaitForSeconds(5f); } } + + public static IEnumerator GetDemons() + { + for (;;) + { + Demons = SurvivalDemonBehaviour.FindObjectsOfType(); + + // Wait 5 seconds before caching objects again. + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetSpiders() + { + for (;;) + { + Spiders = SpiderBehaviour.FindObjectsOfType(); + + // Wait 5 seconds before caching objects again. + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetGhosts() + { + for (;;) + { + Ghosts = GhostBehaviour.FindObjectsOfType(); + + // Wait 5 seconds before caching objects again. + yield return new WaitForSeconds(5f); + } + } } } diff --git a/DevourClient/MelonMain.cs b/DevourClient/MelonMain.cs index e738d52..19aa348 100644 --- a/DevourClient/MelonMain.cs +++ b/DevourClient/MelonMain.cs @@ -43,6 +43,9 @@ namespace DevourClient MelonCoroutines.Start(Helpers.Entities.GetGoatsAndRats()); MelonCoroutines.Start(Helpers.Entities.GetSurvivalInteractables()); MelonCoroutines.Start(Helpers.Entities.GetKeys()); + MelonCoroutines.Start(Helpers.Entities.GetDemons()); + MelonCoroutines.Start(Helpers.Entities.GetSpiders()); + MelonCoroutines.Start(Helpers.Entities.GetGhosts()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -276,7 +279,7 @@ namespace DevourClient if (this.demon_esp) { - foreach (SurvivalDemonBehaviour demon in UnityEngine.Object.FindObjectsOfType() as UnhollowerBaseLib.Il2CppReferenceArray) + foreach (SurvivalDemonBehaviour demon in Helpers.Entities.Demons) { if (demon != null) { @@ -305,7 +308,7 @@ namespace DevourClient } } - foreach (SpiderBehaviour spider in UnityEngine.Object.FindObjectsOfType() as UnhollowerBaseLib.Il2CppReferenceArray) + foreach (SpiderBehaviour spider in Helpers.Entities.Spiders) { if (spider != null) { @@ -334,7 +337,7 @@ namespace DevourClient } } - foreach (GhostBehaviour ghost in UnityEngine.Object.FindObjectsOfType() as UnhollowerBaseLib.Il2CppReferenceArray) + foreach (GhostBehaviour ghost in Helpers.Entities.Ghosts) { if (ghost != null) {