2021-11-25 15:32:34 +00:00
|
|
|
|
using UnityEngine;
|
2021-11-18 11:34:14 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.RespawnSync
|
|
|
|
|
{
|
|
|
|
|
public class RespawnHUDMarker : HUDDistanceMarker
|
|
|
|
|
{
|
|
|
|
|
private bool _isReady;
|
|
|
|
|
|
|
|
|
|
public override void InitCanvasMarker()
|
|
|
|
|
{
|
2021-11-18 13:21:28 +00:00
|
|
|
|
_markerRadius = 0.2f;
|
|
|
|
|
_markerTarget = transform;
|
|
|
|
|
_markerLabel = "RESPAWN PLAYER";
|
|
|
|
|
_isReady = true;
|
2021-11-18 11:34:14 +00:00
|
|
|
|
|
2021-11-18 13:21:28 +00:00
|
|
|
|
base.InitCanvasMarker();
|
2021-11-18 11:34:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (!_isReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_canvasMarker != null)
|
|
|
|
|
{
|
|
|
|
|
var isVisible = _canvasMarker.IsVisible();
|
|
|
|
|
|
|
|
|
|
if (RespawnManager.Instance.RespawnNeeded != isVisible)
|
|
|
|
|
{
|
2021-11-18 13:21:28 +00:00
|
|
|
|
_isVisible = RespawnManager.Instance.RespawnNeeded;
|
|
|
|
|
_canvasMarker.SetVisibility(_isVisible);
|
2021-11-18 11:34:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 13:21:28 +00:00
|
|
|
|
if (_isVisible && _canvasMarker != null)
|
2021-11-18 11:34:14 +00:00
|
|
|
|
{
|
2021-11-18 13:21:28 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|