Cache guys in invul

This commit is contained in:
xen-42 2025-02-15 02:36:00 -05:00
parent 4499bc3312
commit a12395b547

View File

@ -4,7 +4,7 @@ using UnityEngine.SceneManagement;
namespace NewHorizons.Handlers
{
internal class InvulnerabilityHandler
public static class InvulnerabilityHandler
{
/// <summary>
/// Used in patches
@ -32,8 +32,25 @@ namespace NewHorizons.Handlers
}
}
private static DeathManager GetDeathManager() => GameObject.FindObjectOfType<DeathManager>();
private static PlayerResources GetPlayerResouces() => GameObject.FindObjectOfType<PlayerResources>();
private static DeathManager _deathManager;
private static DeathManager GetDeathManager()
{
if (_deathManager == null)
{
_deathManager = GameObject.FindObjectOfType<DeathManager>();
}
return _deathManager;
}
private static PlayerResources _playerResources;
private static PlayerResources GetPlayerResouces()
{
if (_playerResources == null)
{
_playerResources = GameObject.FindObjectOfType<PlayerResources>();
}
return _playerResources;
}
static InvulnerabilityHandler()
{