VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
HiddenPlayer.cpp
Go to the documentation of this file.
3
4namespace VoltMod
5{
6
7HiddenPlayer::HiddenPlayer(EntitySystem& entities, Visibility& visibility, int slot)
8 : _entities(entities), _visibility(visibility), _slot(slot), _glow(entities, visibility, slot)
9{
10 // The controller keeps a team while dead or spectating; the pawn may not exist.
11 const Controller controller = _entities.Controller(slot);
12 _team = controller.TeamNum();
13 _name = std::string(controller.PlayerName());
14 // A blank name still hides the player if a CS2 update leaves the visibility filter inert.
15 controller.SetPlayerName("");
16 controller.ChangeTeam(Team::Spectator);
17 _visibility.SetControllerHidden(slot, true);
18 _glow.Refresh();
19}
20
22{
23 if (_hidden)
24 {
25 _glow.Refresh();
26 }
27}
28
30{
31 if (!_hidden)
32 {
33 return;
34 }
35 _hidden = false;
36 _glow.Destroy();
37 _visibility.SetControllerHidden(_slot, false);
38
39 const Controller controller = _entities.Controller(_slot);
40 if (!controller)
41 {
42 return;
43 }
44 controller.SetPlayerName(_name);
45 if (IsPlaying(_team) && controller.TeamNum() == Team::Spectator)
46 {
47 controller.ChangeTeam(_team);
48 }
49}
50
51} // namespace VoltMod
A player's identity behind a slot: name, money, team, scoreboard row. It survives death and respawn; ...
void ChangeTeam(VoltMod::Team team) const
runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see...
HiddenPlayer(EntitySystem &entities, Visibility &visibility, int slot)
Which clients receive which entities, filtered after CheckTransmit.
constexpr bool IsPlaying(Team team)
Definition Team.hpp:18