Guard against null during shutdown

This commit is contained in:
ivan tkachenko 2026-04-05 00:01:07 +03:00
parent a71c61b5c7
commit 871c608a33
3 changed files with 16 additions and 4 deletions

View File

@ -113,11 +113,17 @@ namespace MuzikaGromche
foreach (var discoBall in CachedDiscoBalls) foreach (var discoBall in CachedDiscoBalls)
{ {
discoBall.SetActive(on); if (discoBall != null)
{
discoBall.SetActive(on);
}
} }
foreach (var animator in CachedDiscoBallAnimators) foreach (var animator in CachedDiscoBallAnimators)
{ {
animator?.SetBool("on", on); if (animator != null)
{
animator.SetBool("on", on);
}
} }
} }

View File

@ -68,7 +68,11 @@ namespace MuzikaGromche
{ {
foreach (var data in AllPoweredLights) foreach (var data in AllPoweredLights)
{ {
data.Light.color = data.InitialColor; var light = data.Light;
if (light != null)
{
light.color = data.InitialColor;
}
} }
} }
} }

View File

@ -120,7 +120,9 @@ namespace MuzikaGromche
{ {
drunkness = 0f; drunkness = 0f;
// Only the stop animation if vanilla doesn't animate TZP right now. // Only the stop animation if vanilla doesn't animate TZP right now.
if (GameNetworkManager.Instance.localPlayerController.drunkness == 0f) // Objects may be null on shutdown
var network = GameNetworkManager.Instance;
if (network != null && network.localPlayerController != null && network.localPlayerController.drunkness == 0f)
{ {
HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", value: false); HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", value: false);
} }