From 7cc6031dc112f72698d60e4e42453cb9bef09351 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Mon, 31 Jul 2023 02:59:08 +0100 Subject: Add looking at info --- code/ui/Hud.razor | 1 + code/ui/character/LookingAtInfo.razor | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 code/ui/character/LookingAtInfo.razor (limited to 'code/ui') diff --git a/code/ui/Hud.razor b/code/ui/Hud.razor index 9fcdfdc..d6fe5b6 100644 --- a/code/ui/Hud.razor +++ b/code/ui/Hud.razor @@ -14,6 +14,7 @@ + diff --git a/code/ui/character/LookingAtInfo.razor b/code/ui/character/LookingAtInfo.razor new file mode 100644 index 0000000..4a54b81 --- /dev/null +++ b/code/ui/character/LookingAtInfo.razor @@ -0,0 +1,57 @@ +@using Sandbox; +@using Sandbox.UI; +@using System; + +@namespace MurderGame +@inherits Panel + + + +
+ @GetLookingAtName() +
+ +@code +{ + public string GetLookingAtName() + { + if (Game.LocalPawn is not Player player) return ""; + return player.LookingAt is not { } lookingAt ? "" : lookingAt.CharacterName; + } + + public string GetLookingAtColour() + { + if (Game.LocalPawn is not Player player) return "white"; + return player.LookingAt is not { } lookingAt ? "white" : lookingAt.HexColor; + } + + protected override int BuildHash() + { + return GetLookingAtName().GetHashCode(); + } +} -- cgit v1.2.3-70-g09d2