aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/character/NameInfo.razor
blob: 8b6dce117255697c639c87a54e5977b133e16008 (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
@using Sandbox;
@using Sandbox.UI;

@namespace MurderGame
@inherits Panel

<style>
.team-info {
    font-size: 30px;
    font-weight: 700;
    font-family: "Roboto";
}
</style>

<div class="team-info" style="color: @(Colour)">
@GetName()
</div>

@code
{
    public string Colour { get; set; }

    public string GetName()
    {
        var clientPawn = Game.LocalPawn;
        if (clientPawn is Player {Camera: not null } player)
        {
            return player.Camera.GetObservedName();
        }
        return "";
    }

    protected override int BuildHash()
    {
        return GetName().GetHashCode();
    }
}