added nametags

This commit is contained in:
mccarreon
2023-08-09 17:50:57 -07:00
parent bce1f8e1f7
commit bbf0a765d5
12 changed files with 129 additions and 37 deletions

View File

@@ -0,0 +1,30 @@
@using Sandbox;
@using Sandbox.UI;
@namespace LuckerGame.UI
@attribute [StyleSheet]
@inherits WorldPanel
<root class="card">
<label class="text">@Text</label>
</root>
@code {
private Entity TargetEntity;
private string Text;
public HoveringText(string text, Entity targetEntity)
{
Text = text;
TargetEntity = targetEntity;
}
[GameEvent.Client.Frame]
private void OnFrame()
{
if (!TargetEntity.IsValid()) return;
Log.Info($"{Text} to {TargetEntity.Position}");
Position = TargetEntity.Position + Vector3.Up * 65f;
Rotation = Rotation.LookAt(-Screen.GetDirection(new Vector2(Screen.Width * 0.5f, Screen.Height * 0.5f)));
}
}