From d7597b055fd747627489ffe79367e67e55f04e2e Mon Sep 17 00:00:00 2001 From: manafeng <123635537+mana-feng@users.noreply.github.com> Date: Sun, 8 Jun 2025 03:05:16 +1000 Subject: [PATCH] Add files via upload --- DevourClient/Helpers/GUIHelper.cs | 129 +++- DevourClient/Helpers/Map.cs | 2 + DevourClient/Helpers/StateHelper.cs | 951 +++++++++++++++++----------- 3 files changed, 687 insertions(+), 395 deletions(-) diff --git a/DevourClient/Helpers/GUIHelper.cs b/DevourClient/Helpers/GUIHelper.cs index 8d4e1aa..c57aefe 100644 --- a/DevourClient/Helpers/GUIHelper.cs +++ b/DevourClient/Helpers/GUIHelper.cs @@ -1,57 +1,143 @@ using UnityEngine; +using MelonLoader; +using System.Collections.Generic; namespace DevourClient.Helpers { - class GUIHelper + public static class GUIHelper // 改为静态类 { + private static Texture2D previewTexture; + private static GUIStyle boxStyle; + + private static Dictionary colorTextureCache = new Dictionary(); + private static Dictionary circularTextureCache = new Dictionary(); + + // 初始化方法 + public static void Initialize() + { + if (previewTexture == null) + { + previewTexture = new Texture2D(1, 1); + boxStyle = new GUIStyle(GUI.skin.box); + } + } + + // 清理方法 + public static void Cleanup() + { + if (previewTexture != null) + { + UnityEngine.Object.Destroy(previewTexture); + previewTexture = null; + } + + foreach (var texture in colorTextureCache.Values) + { + if (texture != null) + { + UnityEngine.Object.Destroy(texture); + } + } + colorTextureCache.Clear(); + + foreach (var texture in circularTextureCache.Values) + { + if (texture != null) + { + UnityEngine.Object.Destroy(texture); + } + } + circularTextureCache.Clear(); + } + private static float R; private static float G; private static float B; public static Color ColorPick(string title, Color color) { - GUI.Label(new Rect(Settings.Settings.x + 195, Settings.Settings.y + 70, 250, 30), title); + Initialize(); // 确保已初始化 - R = GUI.VerticalSlider(new Rect(Settings.Settings.x + 240, Settings.Settings.y + 100, 30, 90), color.r, 0f, 1f); - G = GUI.VerticalSlider(new Rect(Settings.Settings.x + 270, Settings.Settings.y + 100, 30, 90), color.g, 0f, 1f); - B = GUI.VerticalSlider(new Rect(Settings.Settings.x + 300, Settings.Settings.y + 100, 30, 90), color.b, 0f, 1f); - - GUI.Label(new Rect(Settings.Settings.x + 240, Settings.Settings.y + 190, 30, 30), "R"); - GUI.Label(new Rect(Settings.Settings.x + 270, Settings.Settings.y + 190, 30, 30), "G"); - GUI.Label(new Rect(Settings.Settings.x + 300, Settings.Settings.y + 190, 30, 30), "B"); + // 使用 GUILayout 来创建更可靠的滑动条 + GUILayout.BeginArea(new Rect(Settings.Settings.x + 195, Settings.Settings.y + 70, 250, 250)); - color = new Color(R, G, B, 1); + GUILayout.Label(title); + GUILayout.Space(10); - void DrawPreview(Rect position, Color color_to_draw) + // R 通道 + GUILayout.BeginHorizontal(); + GUILayout.Label("R", GUILayout.Width(20)); + R = GUILayout.HorizontalSlider(color.r, 0f, 1f, GUILayout.Width(150)); + GUILayout.Label(((int)(R * 255)).ToString(), GUILayout.Width(30)); + GUILayout.EndHorizontal(); + + // G 通道 + GUILayout.BeginHorizontal(); + GUILayout.Label("G", GUILayout.Width(20)); + G = GUILayout.HorizontalSlider(color.g, 0f, 1f, GUILayout.Width(150)); + GUILayout.Label(((int)(G * 255)).ToString(), GUILayout.Width(30)); + GUILayout.EndHorizontal(); + + // B 通道 + GUILayout.BeginHorizontal(); + GUILayout.Label("B", GUILayout.Width(20)); + B = GUILayout.HorizontalSlider(color.b, 0f, 1f, GUILayout.Width(150)); + GUILayout.Label(((int)(B * 255)).ToString(), GUILayout.Width(30)); + GUILayout.EndHorizontal(); + + GUILayout.Space(10); + + // 颜色预览 + void DrawPreview(Color color_to_draw) { - Texture2D texture = new Texture2D(1, 1); - texture.SetPixel(0, 0, color_to_draw); - texture.Apply(); - GUIStyle boxStyle = new GUIStyle(GUI.skin.box); - boxStyle.normal.background = texture; - GUI.Box(position, GUIContent.none, boxStyle); + if (previewTexture == null) + { + previewTexture = new Texture2D(1, 1); + } + + previewTexture.SetPixel(0, 0, color_to_draw); + previewTexture.Apply(); + boxStyle.normal.background = previewTexture; + GUILayout.Box(GUIContent.none, boxStyle, GUILayout.Height(30)); } - DrawPreview(new Rect(Settings.Settings.x + 195, Settings.Settings.y + 100, 20, 90), color); + DrawPreview(new Color(R, G, B, 1)); + + GUILayout.EndArea(); - return color; + return new Color(R, G, B, 1); } public static Texture2D MakeTex(int width, int height, Color col) { + string cacheKey = $"{width}x{height}_{col.r}_{col.g}_{col.b}"; + + if (colorTextureCache.TryGetValue(col, out Texture2D cachedTexture)) + { + return cachedTexture; + } + + Texture2D result = new Texture2D(width, height); Color[] pix = new Color[width * height]; for (int i = 0; i < pix.Length; ++i) { pix[i] = col; } - Texture2D result = new Texture2D(width, height); result.SetPixels(pix); result.Apply(); + + colorTextureCache[col] = result; return result; } public static Texture2D GetCircularTexture(int width, int height) { + int size = Mathf.Max(width, height); + if (circularTextureCache.TryGetValue(size, out Texture2D cachedTexture)) + { + return cachedTexture; + } + Texture2D texture = new Texture2D(width, height); for (int x = 0; x < texture.width; x++) { @@ -69,7 +155,8 @@ namespace DevourClient.Helpers } texture.Apply(); - + + circularTextureCache[size] = texture; return texture; } } diff --git a/DevourClient/Helpers/Map.cs b/DevourClient/Helpers/Map.cs index 8e5582a..6540006 100644 --- a/DevourClient/Helpers/Map.cs +++ b/DevourClient/Helpers/Map.cs @@ -40,10 +40,12 @@ Il2CppPhoton.Bolt.BoltNetwork.LoadScene(mapName); MelonLoader.MelonLogger.Warning("Please press the button only once, it may take some time for the map to load."); + Hacks.Misc.ShowMessageBox("Please press the button only once, it may take some time for the map to load."); } else { MelonLoader.MelonLogger.Warning("You must be the host to use this command!"); + Hacks.Misc.ShowMessageBox("You must be the host to use this command!"); } } } diff --git a/DevourClient/Helpers/StateHelper.cs b/DevourClient/Helpers/StateHelper.cs index af82bb4..6590536 100644 --- a/DevourClient/Helpers/StateHelper.cs +++ b/DevourClient/Helpers/StateHelper.cs @@ -1,374 +1,577 @@ -using UnityEngine; -using Il2CppOpsive.UltimateCharacterController.Character; -using System.Collections.Generic; -using System.Collections; -using MelonLoader; -using Il2CppPhoton.Bolt; - -namespace DevourClient.Helpers -{ - public class BasePlayer - { - public GameObject p_GameObject { get; set; } = default!; - public string Name { get; set; } = default!; - public string Id { get; set; } = default!; - - public void Kill() - { - if (p_GameObject == null) - { - return; - } - - Il2Cpp.SurvivalAzazelBehaviour sab = Il2Cpp.SurvivalAzazelBehaviour.FindObjectOfType(); - - if (sab == null) - { - return; - } - - sab.OnKnockout(sab.gameObject, p_GameObject); - } - - public void Revive() - { - if (p_GameObject == null) - { - return; - } - - Il2Cpp.NolanBehaviour nb = p_GameObject.GetComponent(); - Il2Cpp.SurvivalReviveInteractable _reviveInteractable = UnityEngine.Object.FindObjectOfType(); - - _reviveInteractable.Interact(nb.gameObject); - } - - public void Jumpscare() - { - if (!BoltNetwork.IsServer) - { - MelonLogger.Msg("You need to be server !"); - return; - } - - if (p_GameObject == null) - { - return; - } - - Il2Cpp.SurvivalAzazelBehaviour sab = Il2Cpp.SurvivalAzazelBehaviour.FindObjectOfType(); - - if (sab == null) - { - return; - } - - sab.OnPickedUpPlayer(sab.gameObject, p_GameObject, false); - - /* - MelonLogger.Msg(Name); - Il2Cpp.JumpScare _jumpscare = UnityEngine.Object.FindObjectOfType(); - _jumpscare.player = p_GameObject; - _jumpscare.Activate(p_GameObject.GetComponent()); - */ - } - - public void LockInCage() - { - if (p_GameObject == null) - { - return; - } - - BoltNetwork.Instantiate(BoltPrefabs.Cage, p_GameObject.transform.position, Quaternion.identity); - } - - public void TP() - { - if (p_GameObject == null) - { - return; - } - - Il2Cpp.NolanBehaviour nb = Player.GetPlayer(); - nb.TeleportTo(p_GameObject.transform.position, Quaternion.identity); - } - - public void TPAzazel() - { - if (p_GameObject == null) - { - return; - } - - UltimateCharacterLocomotion ucl = Helpers.Map.GetAzazel().GetComponent(); - - if (ucl) - { - ucl.SetPosition(p_GameObject.transform.position); - } - else - { - MelonLogger.Error("Azazel not found!"); - return; - } - } - - public void ShootPlayer() - { - if (!BoltNetwork.IsServer) - { - MelonLogger.Msg("You need to be server !"); - return; - } - - if (p_GameObject == null) - { - return; - } - - Il2Cpp.AzazelSamBehaviour _azazelSam = UnityEngine.Object.FindObjectOfType(); - - if (_azazelSam) - { - _azazelSam.OnShootPlayer(p_GameObject, true); - } - } - } - public class Player - { - public static bool IsInGame() - { - Il2Cpp.OptionsHelpers optionsHelpers = UnityEngine.Object.FindObjectOfType(); - return optionsHelpers.inGame; - } - - public static bool IsInGameOrLobby() - { - return GetPlayer() != null; - } - - public static Il2Cpp.NolanBehaviour GetPlayer() - { - if (Entities.LocalPlayer_.p_GameObject == null) - { - return null!; - } - - return Entities.LocalPlayer_.p_GameObject.GetComponent(); - } - - public static bool IsPlayerCrawling() - { - Il2Cpp.NolanBehaviour nb = Player.GetPlayer(); - - if (nb == null) - { - return false; - } - - return nb.IsCrawling(); - } - - } - - public class Entities - { - public static int MAX_PLAYERS = 4; //will change by calling CreateCustomizedLobby - - public static BasePlayer LocalPlayer_ = new BasePlayer(); - public static BasePlayer[] Players = default!; - public static Il2Cpp.GoatBehaviour[] GoatsAndRats = default!; - public static Il2Cpp.SurvivalInteractable[] SurvivalInteractables = default!; - public static Il2Cpp.KeyBehaviour[] Keys = default!; - public static Il2Cpp.SurvivalDemonBehaviour[] Demons = default!; - public static Il2Cpp.SpiderBehaviour[] Spiders = default!; - public static Il2Cpp.GhostBehaviour[] Ghosts = default!; - public static Il2Cpp.SurvivalAzazelBehaviour[] Azazels = default!; - public static Il2Cpp.BoarBehaviour[] Boars = default!; - public static Il2Cpp.CorpseBehaviour[] Corpses = default!; - public static Il2Cpp.CrowBehaviour[] Crows = default!; - public static Il2Cpp.ManorLumpController[] Lumps = default!; - - public static IEnumerator GetLocalPlayer() - { - while (true) - { - GameObject[] currentPlayers = GameObject.FindGameObjectsWithTag("Player"); - - for (int i = 0; i < currentPlayers.Length; i++) - { - if (currentPlayers[i].GetComponent().entity.IsOwner) - { - LocalPlayer_.p_GameObject = currentPlayers[i]; - break; - } - } - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetAllPlayers() - { - while (true) - { - GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); - Players = new BasePlayer[players.Length]; - - int i = 0; - foreach (GameObject p in players) - { - string player_name = ""; - string player_id = "-1"; - - Il2Cpp.DissonancePlayerTracking dpt = p.gameObject.GetComponent(); - if (dpt != null) - { - player_name = dpt.state.PlayerName; - player_id = dpt.state.PlayerId; - } - - if (Players[i] == null) - { - Players[i] = new BasePlayer(); - } - - Players[i].Id = player_id; - Players[i].Name = player_name; - Players[i].p_GameObject = p; - - i++; - } - - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - public static IEnumerator GetGoatsAndRats() - { - while (true) - { - GoatsAndRats = Il2Cpp.GoatBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetSurvivalInteractables() - { - while (true) - { - SurvivalInteractables = Il2Cpp.SurvivalInteractable.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetKeys() - { - while (true) - { - Keys = Il2Cpp.KeyBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetDemons() - { - while (true) - { - Demons = Il2Cpp.SurvivalDemonBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetSpiders() - { - while (true) - { - Spiders = Il2Cpp.SpiderBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetGhosts() - { - while (true) - { - Ghosts = Il2Cpp.GhostBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetBoars() - { - while (true) - { - Boars = Il2Cpp.BoarBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetCorpses() - { - while (true) - { - Corpses = Il2Cpp.CorpseBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetCrows() - { - while (true) - { - Crows = Il2Cpp.CrowBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetLumps() - { - while (true) - { - Lumps = Il2Cpp.ManorLumpController.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - - public static IEnumerator GetAzazels() - { - /* - * ikr AzazelS, because in case we spawn multiple we want the esp to render all of them - */ - while (true) - { - Azazels = Il2Cpp.SurvivalAzazelBehaviour.FindObjectsOfType(); - - // Wait 5 seconds before caching objects again. - yield return new WaitForSeconds(5f); - } - } - } -} +using UnityEngine; +using Il2CppOpsive.UltimateCharacterController.Character; +using System.Collections.Generic; +using System.Collections; +using MelonLoader; +using Il2CppPhoton.Bolt; + +namespace DevourClient.Helpers +{ + public class BasePlayer + { + public GameObject p_GameObject { get; set; } = default!; + public string Name { get; set; } = default!; + public string Id { get; set; } = default!; + + public void Kill() + { + if (p_GameObject == null) + { + return; + } + + Il2Cpp.SurvivalAzazelBehaviour sab = Il2Cpp.SurvivalAzazelBehaviour.FindObjectOfType(); + + if (sab == null) + { + return; + } + + sab.OnKnockout(sab.gameObject, p_GameObject); + } + + public void Revive() + { + if (p_GameObject == null) + { + return; + } + + Il2Cpp.NolanBehaviour nb = p_GameObject.GetComponent(); + Il2Cpp.SurvivalReviveInteractable _reviveInteractable = UnityEngine.Object.FindObjectOfType(); + + _reviveInteractable.Interact(nb.gameObject); + } + + public void Jumpscare() + { + if (!BoltNetwork.IsServer) + { + MelonLogger.Msg("You need to be server !"); + Hacks.Misc.ShowMessageBox("You need to be server !"); + return; + } + + if (p_GameObject == null) + { + return; + } + + Il2Cpp.SurvivalAzazelBehaviour sab = Il2Cpp.SurvivalAzazelBehaviour.FindObjectOfType(); + + if (sab == null) + { + return; + } + + sab.OnPickedUpPlayer(sab.gameObject, p_GameObject, false); + + MelonLogger.Msg(Name); + Hacks.Misc.ShowMessageBox(Name); + + /* + MelonLogger.Msg(Name); + Il2Cpp.JumpScare _jumpscare = UnityEngine.Object.FindObjectOfType(); + _jumpscare.player = p_GameObject; + _jumpscare.Activate(p_GameObject.GetComponent()); + */ + } + + public void LockInCage() + { + if (p_GameObject == null) + { + return; + } + + BoltNetwork.Instantiate(BoltPrefabs.Cage, p_GameObject.transform.position, Quaternion.identity); + } + + public void TP() + { + if (p_GameObject == null) + { + return; + } + + Il2Cpp.NolanBehaviour nb = Player.GetPlayer(); + nb.TeleportTo(p_GameObject.transform.position, Quaternion.identity); + } + + public void TPAzazel() + { + if (p_GameObject == null) + { + return; + } + + UltimateCharacterLocomotion ucl = Helpers.Map.GetAzazel().GetComponent(); + + if (ucl) + { + ucl.SetPosition(p_GameObject.transform.position); + } + else + { + MelonLogger.Error("Azazel not found!"); + Hacks.Misc.ShowMessageBox("Azazel not found!"); + return; + } + } + + public void ShootPlayer() + { + if (!BoltNetwork.IsServer) + { + MelonLogger.Msg("You need to be server !"); + Hacks.Misc.ShowMessageBox("You need to be server !"); + return; + } + + if (p_GameObject == null) + { + return; + } + + Il2Cpp.AzazelSamBehaviour _azazelSam = UnityEngine.Object.FindObjectOfType(); + + if (_azazelSam) + { + _azazelSam.OnShootPlayer(p_GameObject, true); + } + } + } + public class Player + { + public static bool IsInGame() + { + Il2Cpp.OptionsHelpers optionsHelpers = UnityEngine.Object.FindObjectOfType(); + return optionsHelpers.inGame; + } + + public static bool IsInGameOrLobby() + { + return GetPlayer() != null; + } + + public static Il2Cpp.NolanBehaviour GetPlayer() + { + if (Entities.LocalPlayer_.p_GameObject == null) + { + return null!; + } + + return Entities.LocalPlayer_.p_GameObject.GetComponent(); + } + + public static bool IsPlayerCrawling() + { + Il2Cpp.NolanBehaviour nb = Player.GetPlayer(); + + if (nb == null) + { + return false; + } + + return nb.IsCrawling(); + } + + } + + public class Entities + { + private static bool isRunning = true; // Control coroutine running state + private static List activeCoroutines = new List(); // Track active coroutines + + public static int MAX_PLAYERS = 4; //will change by calling CreateCustomizedLobby + + public static BasePlayer LocalPlayer_ = new BasePlayer(); + public static BasePlayer[] Players = default!; + public static Il2Cpp.GoatBehaviour[] GoatsAndRats = default!; + public static Il2Cpp.SurvivalInteractable[] SurvivalInteractables = default!; + public static Il2Cpp.KeyBehaviour[] Keys = default!; + public static Il2Cpp.SurvivalDemonBehaviour[] Demons = default!; + public static Il2Cpp.SpiderBehaviour[] Spiders = default!; + public static Il2Cpp.GhostBehaviour[] Ghosts = default!; + public static Il2Cpp.SurvivalAzazelBehaviour[] Azazels = default!; + public static Il2Cpp.BoarBehaviour[] Boars = default!; + public static Il2Cpp.CorpseBehaviour[] Corpses = default!; + public static Il2Cpp.CrowBehaviour[] Crows = default!; + public static Il2Cpp.ManorLumpController[] Lumps = default!; + + // Method to stop all coroutines + public static void StopAllCoroutines() + { + isRunning = false; + foreach (var coroutine in activeCoroutines) + { + if (coroutine != null) + { + MelonCoroutines.Stop(coroutine); + } + } + activeCoroutines.Clear(); + + // Clean up all cached objects + CleanupCachedObjects(); + } + + // Clean up cached objects + private static void CleanupCachedObjects() + { + if (Players != null) + { + foreach (var player in Players) + { + if (player != null) + { + player.p_GameObject = null; + } + } + Players = null; + } + + LocalPlayer_.p_GameObject = null; + GoatsAndRats = null; + SurvivalInteractables = null; + Keys = null; + Demons = null; + Spiders = null; + Ghosts = null; + Azazels = null; + Boars = null; + Corpses = null; + Crows = null; + Lumps = null; + } + + // Method to start all coroutines + public static void StartAllCoroutines() + { + isRunning = true; + activeCoroutines.Clear(); + + // Start all coroutines and save references + activeCoroutines.Add(MelonCoroutines.Start(GetLocalPlayer())); + activeCoroutines.Add(MelonCoroutines.Start(GetAllPlayers())); + activeCoroutines.Add(MelonCoroutines.Start(GetGoatsAndRats())); + activeCoroutines.Add(MelonCoroutines.Start(GetSurvivalInteractables())); + activeCoroutines.Add(MelonCoroutines.Start(GetKeys())); + activeCoroutines.Add(MelonCoroutines.Start(GetDemons())); + activeCoroutines.Add(MelonCoroutines.Start(GetSpiders())); + activeCoroutines.Add(MelonCoroutines.Start(GetGhosts())); + activeCoroutines.Add(MelonCoroutines.Start(GetBoars())); + activeCoroutines.Add(MelonCoroutines.Start(GetCorpses())); + activeCoroutines.Add(MelonCoroutines.Start(GetCrows())); + activeCoroutines.Add(MelonCoroutines.Start(GetLumps())); + activeCoroutines.Add(MelonCoroutines.Start(GetAzazels())); + } + + public static IEnumerator GetLocalPlayer() + { + while (isRunning) + { + try + { + GameObject[] currentPlayers = GameObject.FindGameObjectsWithTag("Player"); + if (currentPlayers != null) + { + for (int i = 0; i < currentPlayers.Length; i++) + { + if (currentPlayers[i].GetComponent().entity.IsOwner) + { + // Clean up old references before updating + if (LocalPlayer_.p_GameObject != currentPlayers[i]) + { + LocalPlayer_.p_GameObject = currentPlayers[i]; + } + break; + } + } + } + } + catch (System.Exception e) + { + string err = $"GetLocalPlayer coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetAllPlayers() + { + while (isRunning) + { + try + { + GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); + + // Clean up old array before creating new one + if (Players != null) + { + foreach (var player in Players) + { + if (player != null) + { + player.p_GameObject = null; + } + } + } + + // Create new array + Players = new BasePlayer[players.Length]; + + for (int i = 0; i < players.Length; i++) + { + if (Players[i] == null) + { + Players[i] = new BasePlayer(); + } + + Players[i].p_GameObject = players[i]; + + Il2Cpp.DissonancePlayerTracking dpt = players[i].GetComponent(); + if (dpt != null) + { + Players[i].Name = dpt.state.PlayerName; + Players[i].Id = dpt.state.PlayerId; + } + } + } + catch (System.Exception e) + { + string err = $"GetAllPlayers coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetGoatsAndRats() + { + while (isRunning) + { + try + { + GoatsAndRats = Il2Cpp.GoatBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetGoatsAndRats coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetSurvivalInteractables() + { + while (isRunning) + { + try + { + SurvivalInteractables = Il2Cpp.SurvivalInteractable.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetSurvivalInteractables coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetKeys() + { + while (isRunning) + { + try + { + Keys = Il2Cpp.KeyBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetKeys coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetDemons() + { + while (isRunning) + { + try + { + Demons = Il2Cpp.SurvivalDemonBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetDemons coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetSpiders() + { + while (isRunning) + { + try + { + Spiders = Il2Cpp.SpiderBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetSpiders coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetGhosts() + { + while (isRunning) + { + try + { + Ghosts = Il2Cpp.GhostBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetGhosts coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetBoars() + { + while (isRunning) + { + try + { + Boars = Il2Cpp.BoarBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetBoars coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetCorpses() + { + while (isRunning) + { + try + { + Corpses = Il2Cpp.CorpseBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetCorpses coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetCrows() + { + while (isRunning) + { + try + { + Crows = Il2Cpp.CrowBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetCrows coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetLumps() + { + while (isRunning) + { + try + { + Lumps = Il2Cpp.ManorLumpController.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"GetLumps coroutine encountered an error: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + + public static IEnumerator GetAzazels() + { + while (isRunning) + { + try + { + Azazels = Il2Cpp.SurvivalAzazelBehaviour.FindObjectsOfType(); + } + catch (System.Exception e) + { + string err = $"Error in GetAzazels coroutine: {e.Message}"; + MelonLogger.Error(err); + DevourClient.Settings.Settings.errorMessage = err; + DevourClient.Settings.Settings.showErrorMessage = true; + } + + yield return new WaitForSeconds(5f); + } + } + } +}