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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
@using Sandbox;
@using Sandbox.UI;
@using System;
@namespace MurderGame
@inherits Panel
<style>
@@keyframes blink {
0% {
background-color: rgba(0, 0, 0, 0.20);
}
49% {
background-color: rgba(0, 0, 0, 0.20);
}
50% {
background-color: rgba(255, 0, 0, 0.20);
}
100% {
background-color: rgba(255, 0, 0, 0.20);
}
}
reload {
width: 100vw;
height: 100vh;
}
.box {
position: absolute;
left: 47%;
top: 60%;
width: 6%;
backdrop-filter-blur: 8px;
background-color: rgba(0, 0, 0, 0.20);
padding: 5px;
color: white;
font-weight: 700;
font-size: 30px;
font-family: "Roboto";
display: flex;
align-items: center;
justify-content: center;
}
.blink {
animation-name: blink;
animation-duration: 0.33s;
}
</style>
@if (ReloadNeeded) {
<!--<div class="box @(@Blink ? "blink" : "")">-->
<div class="box blink">
<div>Reload</div>
</div>
}
@code
{
public bool ReloadNeeded { get; set; }
public bool Blink { get; set; }
protected override int BuildHash()
{
var clientPawn = Game.LocalPawn;
if (clientPawn is Player {Camera: not null } player)
{
var inventory = player.Camera.GetObservedInventory();
if (inventory?.GetCurrentWeapon() != null)
{
var weapon = inventory.GetCurrentWeapon();
var ammo = weapon.Ammo;
ReloadNeeded = ammo == 0 && !weapon.Reloading;
Blink = !weapon.Reloading;
return HashCode.Combine(ReloadNeeded.GetHashCode(), Blink.GetHashCode());
}
}
if (ReloadNeeded)
{
ReloadNeeded = false;
}
return ReloadNeeded.GetHashCode();
}
}
|