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

@ -112,12 +112,18 @@ namespace MuzikaGromche
Plugin.Log.LogDebug($"{nameof(DiscoBallManager)} Toggle {(on ? "ON" : "OFF")} {CachedDiscoBallAnimators.Count} animators");
foreach (var discoBall in CachedDiscoBalls)
{
if (discoBall != null)
{
discoBall.SetActive(on);
}
}
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)
{
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;
// 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);
}