2020-07-28 13:59:24 +00:00
|
|
|
|
using UnityEngine;
|
2020-05-19 17:41:33 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.TransformSync
|
|
|
|
|
{
|
2020-07-28 13:59:24 +00:00
|
|
|
|
public class PlayerHUDMarker : HUDDistanceMarker
|
2020-05-19 17:41:33 +00:00
|
|
|
|
{
|
|
|
|
|
private uint _netId = uint.MaxValue;
|
|
|
|
|
private bool _isReady;
|
|
|
|
|
|
|
|
|
|
protected override void InitCanvasMarker()
|
|
|
|
|
{
|
2020-07-27 23:13:43 +00:00
|
|
|
|
_markerRadius = 2f;
|
2020-05-19 17:41:33 +00:00
|
|
|
|
|
|
|
|
|
_markerTarget = new GameObject().transform;
|
|
|
|
|
_markerTarget.parent = transform;
|
2020-07-27 23:13:43 +00:00
|
|
|
|
|
|
|
|
|
_markerTarget.localPosition = Vector3.zero;
|
2020-05-19 17:41:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetId(uint netId)
|
|
|
|
|
{
|
|
|
|
|
_netId = netId;
|
|
|
|
|
_isReady = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void RefreshOwnVisibility()
|
|
|
|
|
{
|
|
|
|
|
if (_canvasMarker != null)
|
|
|
|
|
{
|
|
|
|
|
_canvasMarker.SetVisibility(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 13:59:24 +00:00
|
|
|
|
private void Update()
|
2020-05-19 17:41:33 +00:00
|
|
|
|
{
|
2020-07-30 19:57:39 +00:00
|
|
|
|
if (!_isReady || !PlayerRegistry.GetPlayer(_netId).IsReady)
|
2020-05-19 17:41:33 +00:00
|
|
|
|
{
|
2020-07-28 13:59:24 +00:00
|
|
|
|
return;
|
2020-05-19 17:41:33 +00:00
|
|
|
|
}
|
2020-07-30 19:57:39 +00:00
|
|
|
|
_markerLabel = PlayerRegistry.GetPlayer(_netId).Name;
|
2020-07-28 13:59:24 +00:00
|
|
|
|
_isReady = false;
|
|
|
|
|
|
|
|
|
|
base.InitCanvasMarker();
|
2020-05-19 17:41:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|