fix hud marker persisting after death

This commit is contained in:
Mister_Nebula 2022-08-13 11:52:11 +01:00
parent 63518fd5f6
commit 243e709e89

View File

@ -26,6 +26,16 @@ public class PlayerHUDMarker : HUDDistanceMarker
_needsInitializing = true; _needsInitializing = true;
} }
private bool ShouldBeVisible()
{
if (_player == null)
{
return false;
}
return _player.IsReady && !_player.IsDead && !_player.InDreamWorld && _player.Visible;
}
private void Update() private void Update()
{ {
if (_needsInitializing) if (_needsInitializing)
@ -42,9 +52,9 @@ public class PlayerHUDMarker : HUDDistanceMarker
{ {
var isVisible = _canvasMarker.IsVisible(); var isVisible = _canvasMarker.IsVisible();
if (_player.Visible != isVisible) if (ShouldBeVisible() != isVisible)
{ {
_canvasMarker.SetVisibility(_player.Visible); _canvasMarker.SetVisibility(ShouldBeVisible());
} }
} }
else else