quantum-space-buddies/QSB/TransformSync/PlayerHUDMarker.cs

47 lines
1.1 KiB
C#
Raw Normal View History

2020-07-28 13:59:24 +00:00
using UnityEngine;
namespace QSB.TransformSync
{
2020-07-28 13:59:24 +00:00
public class PlayerHUDMarker : HUDDistanceMarker
{
private uint _netId = uint.MaxValue;
private bool _isReady;
protected override void InitCanvasMarker()
{
_markerRadius = 2f;
_markerTarget = new GameObject().transform;
_markerTarget.parent = transform;
_markerTarget.localPosition = Vector3.zero;
}
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()
{
if (!_isReady || !PlayerRegistry.GetPlayer(_netId).IsReady)
{
2020-07-28 13:59:24 +00:00
return;
}
_markerLabel = PlayerRegistry.GetPlayer(_netId).Name;
2020-07-28 13:59:24 +00:00
_isReady = false;
base.InitCanvasMarker();
}
}
}