diff --git a/QSB/RespawnSync/RespawnHUDMarker.cs b/QSB/RespawnSync/RespawnHUDMarker.cs index a260eef9..f9653a5a 100644 --- a/QSB/RespawnSync/RespawnHUDMarker.cs +++ b/QSB/RespawnSync/RespawnHUDMarker.cs @@ -29,7 +29,7 @@ public class RespawnHUDMarker : HUDDistanceMarker { var isVisible = _canvasMarker.IsVisible(); var shouldBeVisible = RespawnManager.Instance.RespawnNeeded - && !ShipManager.Instance.ShipCockpitUI._shipDamageCtrlr.IsDestroyed(); + && !ShipManager.Instance.IsShipWrecked; if (shouldBeVisible != isVisible) { diff --git a/QSB/RespawnSync/ShipRecoveryPoint.cs b/QSB/RespawnSync/ShipRecoveryPoint.cs index ce1ca50a..f42bc528 100644 --- a/QSB/RespawnSync/ShipRecoveryPoint.cs +++ b/QSB/RespawnSync/ShipRecoveryPoint.cs @@ -59,7 +59,7 @@ internal class ShipRecoveryPoint : MonoBehaviour _playerResources = Locator.GetPlayerTransform().GetComponent(); } - if (RespawnManager.Instance.RespawnNeeded && !ShipManager.Instance.ShipCockpitUI._shipDamageCtrlr.IsDestroyed()) + if (RespawnManager.Instance.RespawnNeeded && !ShipManager.Instance.IsShipWrecked) { _interactVolume.EnableSingleInteraction(true, _respawnIndex); _interactVolume.SetKeyCommandVisible(true, _respawnIndex); @@ -127,7 +127,7 @@ internal class ShipRecoveryPoint : MonoBehaviour } else if (inputCommand == _interactVolume.GetInteractionAt(_respawnIndex).inputCommand) { - if (!RespawnManager.Instance.RespawnNeeded || ShipManager.Instance.ShipCockpitUI._shipDamageCtrlr.IsDestroyed()) + if (!RespawnManager.Instance.RespawnNeeded || ShipManager.Instance.IsShipWrecked) { return; } diff --git a/QSB/ShipSync/ShipManager.cs b/QSB/ShipSync/ShipManager.cs index 102b3398..c85a2751 100644 --- a/QSB/ShipSync/ShipManager.cs +++ b/QSB/ShipSync/ShipManager.cs @@ -42,15 +42,28 @@ internal class ShipManager : WorldObjectManager _currentFlyer = value; } } + public bool IsShipWrecked => _shipDestroyed || ShipCockpitUI._shipDamageCtrlr.IsDestroyed(); private readonly List _playersInShip = new(); private uint _currentFlyer = uint.MaxValue; + private bool _shipDestroyed; public void Start() { Instance = this; QSBPlayerManager.OnRemovePlayer += OnRemovePlayer; + GlobalMessenger.AddListener("ShipDestroyed", OnShipDestroyed); + } + + public void OnDestroy() + { + GlobalMessenger.RemoveListener("ShipDestroyed", OnShipDestroyed); + } + + private void OnShipDestroyed() + { + _shipDestroyed = true; } private void OnRemovePlayer(PlayerInfo player) @@ -63,6 +76,8 @@ internal class ShipManager : WorldObjectManager public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) { + _shipDestroyed = false; + var shipBody = Locator.GetShipBody(); if (shipBody == null) {