From 5f91d5e60909056ac93d34be3ccdf79ea03016db Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Sat, 10 Sep 2022 22:24:58 +0200 Subject: [PATCH] add: using coroutines for players --- DevourClient/Helpers/StateHelper.cs | 18 ++++++++---------- DevourClient/MelonMain.cs | 7 ++++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/DevourClient/Helpers/StateHelper.cs b/DevourClient/Helpers/StateHelper.cs index d13a8e4..b1cb94d 100644 --- a/DevourClient/Helpers/StateHelper.cs +++ b/DevourClient/Helpers/StateHelper.cs @@ -45,6 +45,7 @@ namespace DevourClient.Helpers public class Entities { public static GameObject LocalPlayer_; + public static GameObject[] Players; public static GoatBehaviour[] GoatsAndRats; public static SurvivalInteractable[] SurvivalInteractables; public static KeyBehaviour[] Keys; @@ -73,18 +74,15 @@ namespace DevourClient.Helpers } } - public static List GetAllPlayers() + public static IEnumerator GetAllPlayers() { - GameObject[] currentPlayers = GameObject.FindGameObjectsWithTag("Player"); - List result = new List(); - - for (int i = 0; i < currentPlayers.Length; i++) + for (;;) { - result.Add(currentPlayers[i]); - } + Players = GameObject.FindGameObjectsWithTag("Player"); - return result; - + // Wait 5 seconds before caching objects again. + yield return new WaitForSeconds(5f); + } } public static IEnumerator GetGoatsAndRats() @@ -153,7 +151,7 @@ namespace DevourClient.Helpers } } - public static IEnumerator GeAzazels() + public static IEnumerator GetAzazels() { /* * ikr AzazelS, because in case we spawn multiple we want the esp to render all of them diff --git a/DevourClient/MelonMain.cs b/DevourClient/MelonMain.cs index 20bb3b2..1282f03 100644 --- a/DevourClient/MelonMain.cs +++ b/DevourClient/MelonMain.cs @@ -46,7 +46,8 @@ namespace DevourClient MelonCoroutines.Start(Helpers.Entities.GetDemons()); MelonCoroutines.Start(Helpers.Entities.GetSpiders()); MelonCoroutines.Start(Helpers.Entities.GetGhosts()); - MelonCoroutines.Start(Helpers.Entities.GeAzazels()); + MelonCoroutines.Start(Helpers.Entities.GetAzazels()); + MelonCoroutines.Start(Helpers.Entities.GetAllPlayers()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -150,7 +151,7 @@ namespace DevourClient { if (this.player_esp || this.player_snapline) { - foreach (NolanBehaviour player in UnityEngine.Object.FindObjectsOfType() as UnhollowerBaseLib.Il2CppReferenceArray) + foreach (GameObject player in Helpers.Entities.Players) { if (player != null) { @@ -172,7 +173,7 @@ namespace DevourClient { //string playername = player.field_Private_PhotonView_0.field_Private_ObjectPublicObInBoStBoHaStObInHaUnique_0.field_Private_String_0;//player.photonView._Controller_k__BackingField.NickName; - if (player.entity.IsOwner) + if (player.GetComponent().entity.IsOwner) { continue; }