aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/health/Health.razor
blob: 9d7037b33a5439f5fadc119204b0d587e5bbd063 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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();
	}
}