aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/health
diff options
context:
space:
mode:
Diffstat (limited to 'code/ui/health')
-rw-r--r--code/ui/health/Health.razor38
1 files changed, 38 insertions, 0 deletions
diff --git a/code/ui/health/Health.razor b/code/ui/health/Health.razor
new file mode 100644
index 0000000..9d7037b
--- /dev/null
+++ b/code/ui/health/Health.razor
@@ -0,0 +1,38 @@
+@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+Health {
+ width: 400px;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.90);
+}
+.fill {
+ height: 100%;
+ transition: width 0.2s ease-out;
+}
+</style>
+<div class="fill" style="background-color: @(Colour); width: @(GetHealth())%;"></div>
+
+@code
+{
+ public string Colour { get; set; }
+
+ public int GetHealth()
+ {
+ var ClientPawn = Game.LocalPawn;
+ if (ClientPawn is Player)
+ {
+ return ClientPawn.Health.CeilToInt();
+ }
+ return 0;
+ }
+
+ protected override int BuildHash()
+ {
+ return GetHealth().GetHashCode();
+ }
+}