blob: 3853233859bc2595d40ef4e0e4add4a936e12e0c (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
|
@namespace MurderGame
@using System
@using Sandbox
@inherits Sandbox.UI.Panel
<style>
spectator {
top: 0;
left: 0;
width: 100vw;
height: 100vh;
position: absolute;
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: column;
}
.box {
backdrop-filter-blur: 8px;
background-color: rgba(0, 0, 0, 0.20);
padding: 10px;
color: white;
font-weight: 700;
font-size: 35px;
font-family: "Roboto";
margin: 30px;
}
</style>
@if (Spectating)
{
<div class="box">
<div>Spectating @TargetName</div>
</div>
}
@code
{
public bool Spectating { get; set; }
public string TargetName { get; set; }
protected override int BuildHash()
{
var localPawn = Game.LocalPawn;
if (localPawn is Player player && player.Camera is SpectatorCameraComponent spectator)
{
var target = spectator.Target;
Spectating = true;
TargetName = target != null && target.IsValid() && target.LifeState == LifeState.Alive ? target.Client.Name : "";
return HashCode.Combine(Spectating.GetHashCode(), TargetName.GetHashCode());
}
if (Spectating)
{
Spectating = false;
}
return Spectating.GetHashCode();
}
}
|