VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
MenuFreeze.hpp
Go to the documentation of this file.
1#pragma once
2
9
10namespace VoltMod
11{
12
13/**
14 * @brief Holding players still while a menu is open, for every menu surface.
15 *
16 * One per server, on the @ref Runtime: the setting is server-wide, so a player is treated the
17 * same way whichever surface drew their menu. A surface says only when a session opens and
18 * closes; honouring the setting and re-applying the hold across a respawn happen here.
19 *
20 * Costs nothing per frame while nobody is held.
21 */
23{
24public:
25 /** All three must outlive this instance. @p slots drops a hold when a slot changes hands. */
26 MenuFreeze(EntitySystem& entities, Scheduler& scheduler, SlotEvents& slots);
27
28 /**
29 * Freeze movement for the duration of a session, so navigating does not also walk the player
30 * around. The original move type is restored when the session closes. Off by default; turning
31 * it off also releases whoever the previous setting had already frozen.
32 */
33 void Enable(bool enabled);
34
35 bool Enabled() const noexcept { return _enabled; }
36
37 /** A session opened for @p slot. @p requested is that session's @ref MenuOptions::FreezeMovement,
38 * so a menu players reach mid-round can opt out while the setting stays on. */
39 void Open(int slot, bool requested);
40
41 /** The session closed: give the pawn its movement back. */
42 void Close(int slot);
43
44private:
45 /** Re-apply every hold, which is what carries one across a death and respawn. */
46 void OnGameFrame();
47
48 /** Start or stop the per-frame work to match what is currently held. */
49 void SyncFrameWork();
50
51 /** Whether this session asked to be held still, and the pawn it is holding. */
52 struct State
53 {
54 bool Requested = false;
56 };
57
58 EntitySystem& _entities;
59 Scheduler& _scheduler;
60 bool _enabled = false;
61 PerSlot<State> _states;
62 /** Declared last: per-frame delivery drops before the state it touches. */
63 Subscription _onFrame;
64};
65
66} // namespace VoltMod
runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see...
bool Enabled() const noexcept
void Close(int slot)
void Open(int slot, bool requested)
MenuFreeze(EntitySystem &entities, Scheduler &scheduler, SlotEvents &slots)
Definition MenuFreeze.cpp:7
void Enable(bool enabled)
Holds one pawn still and gives its move type back to that pawn only, so a player who respawns while h...
Each player's command from CCSPlayer_MovementServices::RunCommand.
Definition Movement.hpp:23
One-shot delays and repeating timers, run on the game thread.
Definition Scheduler.hpp:18
"The occupant of this slot changed" - raised by PlayerManager, consumed below it.