add: using coroutines for players

This commit is contained in:
ALittlePatate
2022-09-10 22:24:58 +02:00
parent cddcb3f833
commit 5f91d5e609
2 changed files with 12 additions and 13 deletions

View File

@@ -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<GameObject> GetAllPlayers()
public static IEnumerator GetAllPlayers()
{
GameObject[] currentPlayers = GameObject.FindGameObjectsWithTag("Player");
List<GameObject> result = new List<GameObject>();
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

View File

@@ -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<NolanBehaviour>() as UnhollowerBaseLib.Il2CppReferenceArray<NolanBehaviour>)
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<NolanBehaviour>().entity.IsOwner)
{
continue;
}