forked from nikita/muzika-gromche
Guard against null during shutdown
This commit is contained in:
parent
a71c61b5c7
commit
871c608a33
|
|
@ -112,12 +112,18 @@ namespace MuzikaGromche
|
||||||
Plugin.Log.LogDebug($"{nameof(DiscoBallManager)} Toggle {(on ? "ON" : "OFF")} {CachedDiscoBallAnimators.Count} animators");
|
Plugin.Log.LogDebug($"{nameof(DiscoBallManager)} Toggle {(on ? "ON" : "OFF")} {CachedDiscoBallAnimators.Count} animators");
|
||||||
|
|
||||||
foreach (var discoBall in CachedDiscoBalls)
|
foreach (var discoBall in CachedDiscoBalls)
|
||||||
|
{
|
||||||
|
if (discoBall != null)
|
||||||
{
|
{
|
||||||
discoBall.SetActive(on);
|
discoBall.SetActive(on);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
foreach (var animator in CachedDiscoBallAnimators)
|
foreach (var animator in CachedDiscoBallAnimators)
|
||||||
{
|
{
|
||||||
animator?.SetBool("on", on);
|
if (animator != null)
|
||||||
|
{
|
||||||
|
animator.SetBool("on", on);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue