2022-06-29 15:00:44 -07:00
|
|
|
|
using QSB.Localization;
|
2022-06-04 16:19:55 +01:00
|
|
|
|
using QSB.ShipSync;
|
2022-05-14 13:15:06 +01:00
|
|
|
|
using UnityEngine;
|
2021-11-18 11:34:14 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.RespawnSync;
|
|
|
|
|
|
|
|
|
|
public class RespawnHUDMarker : HUDDistanceMarker
|
2021-11-18 11:34:14 +00:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private bool _isReady;
|
|
|
|
|
|
|
|
|
|
public override void InitCanvasMarker()
|
2021-11-18 11:34:14 +00:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_markerRadius = 0.2f;
|
|
|
|
|
_markerTarget = transform;
|
2022-10-11 16:51:00 -07:00
|
|
|
|
_markerLabel = QSBLocalization.Current.RespawnPlayer.ToUpper();
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_isReady = true;
|
2021-11-18 11:34:14 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
base.InitCanvasMarker();
|
|
|
|
|
}
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (!_isReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
2021-11-18 11:34:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (_canvasMarker != null)
|
2021-11-18 11:34:14 +00:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var isVisible = _canvasMarker.IsVisible();
|
2022-05-14 13:15:06 +01:00
|
|
|
|
var shouldBeVisible = RespawnManager.Instance.RespawnNeeded
|
2022-08-16 16:45:13 +01:00
|
|
|
|
&& !ShipManager.Instance.IsShipWrecked;
|
2021-11-18 11:34:14 +00:00
|
|
|
|
|
2022-05-14 13:15:06 +01:00
|
|
|
|
if (shouldBeVisible != isVisible)
|
2021-11-18 11:34:14 +00:00
|
|
|
|
{
|
2022-05-14 13:15:06 +01:00
|
|
|
|
_isVisible = shouldBeVisible;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_canvasMarker.SetVisibility(_isVisible);
|
2021-11-18 11:34:14 +00:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-11-18 11:34:14 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (_isVisible && _canvasMarker != null)
|
|
|
|
|
{
|
|
|
|
|
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;
|
2021-11-18 11:34:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|