|
VoltMod
C++23 framework for CS2 server plugins
|
Creates, fires and listens to game events. More...
#include <GameEvents.hpp>
Public Member Functions | |
| GameEvents (Interfaces &interfaces, const Bindings &bindings) | |
| ~GameEvents () override | |
| GameEvents (const GameEvents &)=delete | |
| GameEvents & | operator= (const GameEvents &)=delete |
| Status | Available () const |
| IGameEvent * | CreateEvent (std::string_view name) |
| bool | FireEvent (IGameEvent *event, bool broadcast=true) |
| void | FreeEvent (IGameEvent *event) |
| template<class TEvent> | |
| Subscription | On (std::function< void(const TEvent &)> handler) |
| void | RemoveAllListeners () |
| void | OnServerStartup () |
| IGameEventListener2 * | GetClientLegacyListener (int slot) const |
| bool | ClientListensTo (int slot, std::string_view eventName) const |
| void | FireGameEvent (IGameEvent *event) override |
Creates, fires and listens to game events.
Definition at line 22 of file GameEvents.hpp.
| VoltMod::GameEvents::GameEvents | ( | Interfaces & | interfaces, |
| const Bindings & | bindings ) |
Reads IGameEventManager2 into interfaces. Both must outlive this service.
Definition at line 14 of file GameEvents.cpp.
Referenced by GameEvents(), and operator=().
|
override |
Definition at line 31 of file GameEvents.cpp.
References RemoveAllListeners().
|
delete |
References GameEvents().
| Status VoltMod::GameEvents::Available | ( | ) | const |
An error when the event manager did not resolve.
Definition at line 37 of file GameEvents.cpp.
References VoltMod::Error::Engine(), and VoltMod::Error::Unsupported().
| bool VoltMod::GameEvents::ClientListensTo | ( | int | slot, |
| std::string_view | eventName ) const |
Whether slot's client listens to eventName; a vanilla client takes only what its HUD needs, so an extra one can mean injected code.
Definition at line 60 of file GameEvents.cpp.
References GetClientLegacyListener().
| IGameEvent * VoltMod::GameEvents::CreateEvent | ( | std::string_view | name | ) |
Definition at line 72 of file GameEvents.cpp.
| bool VoltMod::GameEvents::FireEvent | ( | IGameEvent * | event, |
| bool | broadcast = true ) |
Definition at line 84 of file GameEvents.cpp.
|
override |
Definition at line 178 of file GameEvents.cpp.
| void VoltMod::GameEvents::FreeEvent | ( | IGameEvent * | event | ) |
Definition at line 95 of file GameEvents.cpp.
| IGameEventListener2 * VoltMod::GameEvents::GetClientLegacyListener | ( | int | slot | ) | const |
slot's client listener: an event fired at it reaches that client alone. Null without a client or when the GetLegacyGameEventListener signature did not bind.
Definition at line 50 of file GameEvents.cpp.
References VoltMod::IsValidSlot().
Referenced by ClientListensTo().
|
inlinenodiscard |
Subscribe to TEvent, a struct from <VoltMod/Events/EventTypes.hpp>, while the returned Subscription lives. An event whose Slot is invalid never reaches handler.
Definition at line 41 of file GameEvents.hpp.
References VoltMod::IsValidSlot().
| void VoltMod::GameEvents::OnServerStartup | ( | ) |
Re-attach every event that still has a handler: map startup resets the engine's listeners.
Definition at line 128 of file GameEvents.cpp.
References VoltMod::Log::Info(), and VoltMod::Log::Warn().
|
delete |
References GameEvents().
| void VoltMod::GameEvents::RemoveAllListeners | ( | ) |
Remove every handler and detach from the engine.
Definition at line 163 of file GameEvents.cpp.
Referenced by ~GameEvents().