VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Voice.hpp
Go to the documentation of this file.
1#pragma once
2
8
9namespace VoltMod
10{
11
12/** The game about to let one player hear another's voice. */
14{
15 int Receiver = -1;
16 int Sender = -1;
17 /** Set to keep @ref Receiver from hearing @ref Sender. */
18 bool Blocked = false;
19};
20
21/**
22 * @brief Who hears whose voice, decided each time the game opens a voice channel.
23 *
24 * The hook installs on the first subscription. Call @ref Refresh after a decision changes, such
25 * as a mute or unmute, so it applies without waiting for the game to set the channel again.
26 *
27 * @code
28 * _subs.Add(runtime.Voice.Before += [this](VoltMod::VoiceListen& listen) {
29 * listen.Blocked = IsMuted(listen.Sender);
30 * });
31 * @endcode
32 */
33class Voice
34{
35public:
36 /** @p interfaces and @p players must outlive it; the Runtime declares both above. */
37 Voice(Interfaces& interfaces, PlayerManager& players);
38 Voice(const Voice&) = delete;
39 Voice& operator=(const Voice&) = delete;
40
41private:
42 LazyHook _hook;
43
44public:
46
47 /** Why voice cannot be filtered: IVEngineServer2 is missing. */
48 Status Available() const;
49
50 /** Ask again whether each connected player hears @p senderSlot, so @ref Before decides now. */
51 void Refresh(int senderSlot);
52
53private:
54 Result<Subscription> Install();
55
56 Interfaces& _interfaces;
57 PlayerManager& _players;
58};
59
60} // namespace VoltMod
A multicast signal with a fixed handler signature: the one way to subscribe in VoltMod.
Definition Event.hpp:54
An engine hook that exists only while one of its events has handlers.
Definition LazyHook.hpp:30
The roster: every connected player, and the signals for the connection lifecycle.
Voice(Interfaces &interfaces, PlayerManager &players)
Definition Voice.cpp:28
Status Available() const
Definition Voice.cpp:47
Event< VoiceListen & > Before
Definition Voice.hpp:45
Voice(const Voice &)=delete
void Refresh(int senderSlot)
Definition Voice.cpp:56
Voice & operator=(const Voice &)=delete
std::expected< void, Error > Status
Definition Result.hpp:67
std::expected< T, Error > Result
Definition Result.hpp:64
Centralized holder for all SDK interface pointers.