add: now using coroutine for getting the localplayer
This commit is contained in:
@@ -48,13 +48,13 @@ namespace DevourClient.Hacks
|
|||||||
public static void WalkInLobby(bool walk)
|
public static void WalkInLobby(bool walk)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (Helpers.LocalPlayer.GetLocalPlayer().GetComponent<UltimateCharacterLocomotionHandler>() == null)
|
if (Helpers.LocalPlayer.LocalPlayer_.GetComponent<UltimateCharacterLocomotionHandler>() == null)
|
||||||
{
|
{
|
||||||
Helpers.LocalPlayer.GetLocalPlayer().AddComponent<UltimateCharacterLocomotionHandler>();
|
Helpers.LocalPlayer.LocalPlayer_.AddComponent<UltimateCharacterLocomotionHandler>();
|
||||||
Helpers.LocalPlayer.GetLocalPlayer().GetComponent<UltimateCharacterLocomotionHandler>().enabled = false;
|
Helpers.LocalPlayer.LocalPlayer_.GetComponent<UltimateCharacterLocomotionHandler>().enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Helpers.LocalPlayer.GetLocalPlayer().GetComponent<UltimateCharacterLocomotionHandler>().enabled = walk;
|
Helpers.LocalPlayer.LocalPlayer_.GetComponent<UltimateCharacterLocomotionHandler>().enabled = walk;
|
||||||
}
|
}
|
||||||
catch { return; }
|
catch { return; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Opsive.UltimateCharacterController.Character;
|
using Opsive.UltimateCharacterController.Character;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace DevourClient.Helpers
|
namespace DevourClient.Helpers
|
||||||
{
|
{
|
||||||
public class Player
|
public class Player
|
||||||
{
|
{
|
||||||
@@ -19,16 +20,14 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
public static NolanBehaviour GetPlayer()
|
public static NolanBehaviour GetPlayer()
|
||||||
{
|
{
|
||||||
foreach (NolanBehaviour nb in UnityEngine.Object.FindObjectsOfType<NolanBehaviour>())
|
if (LocalPlayer.LocalPlayer_ == null)
|
||||||
{
|
{
|
||||||
if (nb.entity.IsOwner)
|
|
||||||
{
|
|
||||||
return nb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return LocalPlayer.LocalPlayer_.GetComponent<NolanBehaviour>();
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsPlayerCrawling()
|
public static bool IsPlayerCrawling()
|
||||||
{
|
{
|
||||||
NolanBehaviour nb = Player.GetPlayer();
|
NolanBehaviour nb = Player.GetPlayer();
|
||||||
@@ -45,9 +44,11 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
public class LocalPlayer
|
public class LocalPlayer
|
||||||
{
|
{
|
||||||
public static GameObject player;
|
public static GameObject LocalPlayer_;
|
||||||
|
|
||||||
public static GameObject GetLocalPlayer()
|
public static IEnumerator GetLocalPlayer()
|
||||||
|
{
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
GameObject[] currentPlayers = GameObject.FindGameObjectsWithTag("Player");
|
GameObject[] currentPlayers = GameObject.FindGameObjectsWithTag("Player");
|
||||||
|
|
||||||
@@ -55,12 +56,14 @@ using System.Collections.Generic;
|
|||||||
{
|
{
|
||||||
if (currentPlayers[i].GetComponent<NolanBehaviour>().entity.IsOwner)
|
if (currentPlayers[i].GetComponent<NolanBehaviour>().entity.IsOwner)
|
||||||
{
|
{
|
||||||
player = currentPlayers[i];
|
LocalPlayer_ = currentPlayers[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return player;
|
// Wait 5 seconds before caching objects again.
|
||||||
|
yield return new WaitForSeconds(5f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<GameObject> GetAllPlayers()
|
public static List<GameObject> GetAllPlayers()
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace DevourClient
|
|||||||
public override void OnApplicationStart()
|
public override void OnApplicationStart()
|
||||||
{
|
{
|
||||||
MelonLogger.Msg("For the Queen !");
|
MelonLogger.Msg("For the Queen !");
|
||||||
|
MelonCoroutines.Start(Helpers.LocalPlayer.GetLocalPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@@ -129,7 +130,7 @@ namespace DevourClient
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Helpers.LocalPlayer.GetLocalPlayer().GetComponent<Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion>().TimeScale = this._PlayerSpeedMultiplier;
|
Helpers.LocalPlayer.LocalPlayer_.GetComponent<Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion>().TimeScale = this._PlayerSpeedMultiplier;
|
||||||
}
|
}
|
||||||
catch { return; }
|
catch { return; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user