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