blob: afef6efe6c19800ffd276a19f807482ebf07515c (
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
39
40
41
42
43
44
45
|
@using Sandbox;
@using Sandbox.UI;
@namespace MurderGame
@inherits Panel
<style>
Health {
width: 350px;
height: 100%;
background-color: rgba(0, 0, 0, 0.90);
}
.colour-bar {
height: 100%;
}
.transition-bar {
height: 100%;
transition: width 1s ease-out 0.5s;
position: absolute;
top: 0;
left: 0;
}
</style>
<div class="transition-bar" style="background-color: rgba(255, 255, 255, 0.8); width: @(GetHealth())%;"></div>
<div class="colour-bar" style="background-color: @(Colour); width: @(GetHealth())%;"></div>
@code
{
public string Colour { get; set; }
public int GetHealth()
{
var clientPawn = Game.LocalPawn;
if (clientPawn is Player {Camera: not null } player)
{
return player.Camera.GetObservedHealth().CeilToInt();
}
return 0;
}
protected override int BuildHash()
{
return GetHealth().GetHashCode();
}
}
|