dont do the respawn stuff when ship is destroyed

This commit is contained in:
Mister_Nebula 2022-05-14 13:15:06 +01:00
parent 942535c162
commit d6cbd55dc1
3 changed files with 9 additions and 22 deletions

View File

@ -1,4 +1,5 @@
using UnityEngine;
using QSB.ShipSync;
using UnityEngine;
namespace QSB.RespawnSync;
@ -26,10 +27,12 @@ public class RespawnHUDMarker : HUDDistanceMarker
if (_canvasMarker != null)
{
var isVisible = _canvasMarker.IsVisible();
var shouldBeVisible = RespawnManager.Instance.RespawnNeeded
&& !ShipManager.Instance.ShipCockpitUI._shipDamageCtrlr.IsDestroyed();
if (RespawnManager.Instance.RespawnNeeded != isVisible)
if (shouldBeVisible != isVisible)
{
_isVisible = RespawnManager.Instance.RespawnNeeded;
_isVisible = shouldBeVisible;
_canvasMarker.SetVisibility(_isVisible);
}
}

View File

@ -35,7 +35,6 @@ internal class RespawnManager : MonoBehaviour, IAddComponentOnStart
QSBPlayerManager.OnRemovePlayer += player =>
{
_playersPendingRespawn.Remove(player);
UpdateRespawnNotification();
};
}
@ -148,7 +147,6 @@ internal class RespawnManager : MonoBehaviour, IAddComponentOnStart
player.IsDead = true;
_playersPendingRespawn.Add(player);
UpdateRespawnNotification();
var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead);
@ -172,7 +170,6 @@ internal class RespawnManager : MonoBehaviour, IAddComponentOnStart
player.IsDead = false;
_playersPendingRespawn.Remove(player);
UpdateRespawnNotification();
player.SetVisible(true, 1);
}
@ -182,18 +179,4 @@ internal class RespawnManager : MonoBehaviour, IAddComponentOnStart
var playerToRespawn = _playersPendingRespawn.First();
new PlayerRespawnMessage(playerToRespawn.PlayerId).Send();
}
private void UpdateRespawnNotification()
{
NotificationManager.SharedInstance.UnpinNotification(_previousNotification);
if (_playersPendingRespawn.Count == 0)
{
return;
}
var data = new NotificationData(NotificationTarget.Player, $"[{_playersPendingRespawn.Count}] PLAYER(S) AWAITING RESPAWN");
NotificationManager.SharedInstance.PostNotification(data, true);
_previousNotification = data;
}
}

View File

@ -1,4 +1,5 @@
using QSB.Messaging;
using QSB.ShipSync;
using QSB.Utility;
using UnityEngine;
@ -56,7 +57,7 @@ internal class ShipRecoveryPoint : MonoBehaviour
_playerResources = Locator.GetPlayerTransform().GetComponent<PlayerResources>();
}
if (RespawnManager.Instance.RespawnNeeded)
if (RespawnManager.Instance.RespawnNeeded && !ShipManager.Instance.ShipCockpitUI._shipDamageCtrlr.IsDestroyed())
{
_interactVolume.EnableSingleInteraction(true, _respawnIndex);
_interactVolume.SetKeyCommandVisible(true, _respawnIndex);
@ -124,7 +125,7 @@ internal class ShipRecoveryPoint : MonoBehaviour
}
else if (inputCommand == _interactVolume.GetInteractionAt(_respawnIndex).inputCommand)
{
if (!RespawnManager.Instance.RespawnNeeded)
if (!RespawnManager.Instance.RespawnNeeded || ShipManager.Instance.ShipCockpitUI._shipDamageCtrlr.IsDestroyed())
{
return;
}