fix respawn marker

This commit is contained in:
Mister_Nebula 2021-11-18 13:21:28 +00:00
parent 4ae50fcccd
commit 7ee8926a0a
3 changed files with 24 additions and 41 deletions

View File

@ -15,14 +15,12 @@ namespace QSB.RespawnSync
public override void InitCanvasMarker() public override void InitCanvasMarker()
{ {
DebugLog.DebugWrite($"InitCanvasMarker"); _markerRadius = 0.2f;
_markerTarget = transform;
_markerLabel = "RESPAWN PLAYER";
_isReady = true;
_markerRadius = 2f; base.InitCanvasMarker();
_markerTarget = new GameObject().transform;
_markerTarget.parent = transform;
_markerTarget.localPosition = Vector3.up * 0.25f;
} }
private void Update() private void Update()
@ -38,36 +36,19 @@ namespace QSB.RespawnSync
if (RespawnManager.Instance.RespawnNeeded != isVisible) if (RespawnManager.Instance.RespawnNeeded != isVisible)
{ {
DebugLog.DebugWrite($"set visibility to {isVisible}"); _isVisible = RespawnManager.Instance.RespawnNeeded;
_canvasMarker.SetVisibility(RespawnManager.Instance.RespawnNeeded); _canvasMarker.SetVisibility(_isVisible);
} }
} }
}
public void Initialize() if (_isVisible && _canvasMarker != null)
{
DebugLog.DebugWrite($"initialize");
_markerLabel = "RESPAWN PLAYER";
_isReady = true;
base.InitCanvasMarker();
}
public void Remove()
{
_isReady = false;
// do N O T destroy the parent - it completely breaks the ENTIRE GAME
if (_canvasMarker != null)
{ {
_canvasMarker.DestroyMarker(); var color = (Mathf.Sin(Time.unscaledTime * 10f) > 0f)
? Color.white
: new Color(1f, 1f, 1f, 0.1f);
_canvasMarker._mainTextField.color = color;
_canvasMarker._offScreenIndicator._textField.color = color;
} }
if (_markerTarget != null)
{
Destroy(_markerTarget.gameObject);
}
Destroy(this);
} }
} }
} }

View File

@ -91,8 +91,7 @@ namespace QSB.RespawnSync
_qsbRecoveryPoint.AddComponent<ShipRecoveryPoint>(); _qsbRecoveryPoint.AddComponent<ShipRecoveryPoint>();
var marker = _qsbRecoveryPoint.AddComponent<RespawnHUDMarker>(); _qsbRecoveryPoint.AddComponent<RespawnHUDMarker>();
marker.Initialize();
} }
_qsbRecoveryPoint.SetActive(true); _qsbRecoveryPoint.SetActive(true);

View File

@ -15,7 +15,6 @@ namespace QSB.RespawnSync
private void Awake() private void Awake()
{ {
DebugLog.DebugWrite($"AWAKE");
_interactVolume = this.GetRequiredComponent<MultipleInteractionVolume>(); _interactVolume = this.GetRequiredComponent<MultipleInteractionVolume>();
_interactVolume.OnPressInteract += OnPressInteract; _interactVolume.OnPressInteract += OnPressInteract;
_interactVolume.OnGainFocus += OnGainFocus; _interactVolume.OnGainFocus += OnGainFocus;
@ -51,8 +50,6 @@ namespace QSB.RespawnSync
private void OnGainFocus() private void OnGainFocus()
{ {
DebugLog.DebugWrite($"OnGainFocus");
if (_playerResources == null) if (_playerResources == null)
{ {
_playerResources = Locator.GetPlayerTransform().GetComponent<PlayerResources>(); _playerResources = Locator.GetPlayerTransform().GetComponent<PlayerResources>();
@ -118,16 +115,22 @@ namespace QSB.RespawnSync
private void OnPressInteract(IInputCommands inputCommand) private void OnPressInteract(IInputCommands inputCommand)
{ {
DebugLog.DebugWrite($"OnPressInteract");
if (inputCommand == _interactVolume.GetInteractionAt(_refillIndex).inputCommand) if (inputCommand == _interactVolume.GetInteractionAt(_refillIndex).inputCommand)
{ {
DebugLog.DebugWrite($"recovery"); if (!_wearingSuit)
{
return;
}
HandleRecovery(); HandleRecovery();
} }
else if (inputCommand == _interactVolume.GetInteractionAt(_respawnIndex).inputCommand) else if (inputCommand == _interactVolume.GetInteractionAt(_respawnIndex).inputCommand)
{ {
DebugLog.DebugWrite($"respawn"); if (!RespawnManager.Instance.RespawnNeeded)
{
return;
}
RespawnManager.Instance.RespawnSomePlayer(); RespawnManager.Instance.RespawnSomePlayer();
} }
else else