From 1e5c6393a6b29eb00dbb8fb137d86647cb0c356b Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Fri, 28 Jul 2023 22:06:03 +0100 Subject: Add TryUnstuck and death overlay --- code/ui/overlay/DeathOverlay.Network.cs | 18 +++++++ code/ui/overlay/DeathOverlay.razor | 89 +++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 code/ui/overlay/DeathOverlay.Network.cs create mode 100644 code/ui/overlay/DeathOverlay.razor (limited to 'code/ui/overlay') diff --git a/code/ui/overlay/DeathOverlay.Network.cs b/code/ui/overlay/DeathOverlay.Network.cs new file mode 100644 index 0000000..f1f3bb2 --- /dev/null +++ b/code/ui/overlay/DeathOverlay.Network.cs @@ -0,0 +1,18 @@ +using Sandbox; + +namespace MurderGame; + +public partial class DeathOverlay +{ + [ClientRpc] + public static void Show( ) + { + if (Instance != null) Instance.ShowOverlay = true; + } + + [ClientRpc] + public static void Hide() + { + if (Instance != null) Instance.ShowOverlay = false; + } +} diff --git a/code/ui/overlay/DeathOverlay.razor b/code/ui/overlay/DeathOverlay.razor new file mode 100644 index 0000000..15848f6 --- /dev/null +++ b/code/ui/overlay/DeathOverlay.razor @@ -0,0 +1,89 @@ +@using Sandbox; +@using Sandbox.UI; + +@namespace MurderGame +@inherits Panel + + + +@if (ShowOverlay) +{ +
+
+
+
+ You have died +
+
+} + +@code +{ + public static DeathOverlay Instance { get; private set; } + + public DeathOverlay() + { + Instance = this; + } + + public bool ShowOverlay { get; set; } + + protected override int BuildHash() + { + var clientPawn = Game.LocalPawn; + if (clientPawn is Player player) + { + ShowOverlay = player.LifeState == LifeState.Dead && player.Spectator == null; + } + return ShowOverlay.GetHashCode(); + } + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2