VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
GlowVision.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <array>
6#include <string>
7#include <utility>
8
9namespace VoltMod
10{
11
12/**
13 * @brief Players as team-colored outlines through walls, for one client or one team alone.
14 *
15 * Each glowing player gets two clones following their pawn: an invisible relay and the glow prop on
16 * it, which renders only the outline. Call @ref Refresh every @ref RefreshIntervalMs.
17 */
19{
20public:
21 /** Suggested tick interval for @ref Refresh. */
22 static constexpr int RefreshIntervalMs = 500;
23
24 /** Both services must outlive this; `runtime.Visibility.CreateGlow` passes them. */
26 : _entities(entities), _visibility(visibility), _viewerSlot(viewerSlot), _config(std::move(config))
27 {}
29 : _entities(entities), _visibility(visibility), _viewerTeam(viewerTeam), _config(std::move(config))
30 {}
32 GlowVision(const GlowVision&) = delete;
33 GlowVision& operator=(const GlowVision&) = delete;
34
35 /** Match the clones to the live players. */
36 void Refresh();
37
38 /** Remove every clone now; @ref Refresh rebuilds them. */
39 void Destroy();
40
41private:
42 struct GlowPair
43 {
44 EntityRef Relay;
45 EntityRef Glow;
47 std::string Model;
48
49 bool Active() const { return static_cast<bool>(Relay); }
50 };
51
52 void CreatePair(int slot, GlowPair& pair);
53 void DestroyPair(GlowPair& pair);
54 void ShowToViewers(EntityRef entity);
55
56 EntitySystem& _entities;
57 Visibility& _visibility;
58 int _viewerSlot = -1;
59 Team _viewerTeam = Team::None; ///< when there is no viewer slot
60 GlowConfig _config;
61 std::array<GlowPair, MaxPlayers> _pairs{};
62};
63
64} // namespace VoltMod
runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see...
Players as team-colored outlines through walls, for one client or one team alone.
GlowVision(EntitySystem &entities, Visibility &visibility, int viewerSlot, GlowConfig config={})
GlowVision & operator=(const GlowVision &)=delete
GlowVision(const GlowVision &)=delete
GlowVision(EntitySystem &entities, Visibility &visibility, Team viewerTeam, GlowConfig config={})
static constexpr int RefreshIntervalMs
Which clients receive which entities, filtered after CheckTransmit.
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56