|
VoltMod
C++23 framework for CS2 server plugins
|
Creates, fires and listens to game events. More...
#include <GameEvents.hpp>
Inheritance diagram for VoltMod::GameEvents: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.
References VoltMod::Bindings::GameEventManager, VoltMod::Interfaces::GameEventManager, VoltMod::Bindings::LegacyGameEventListener, VoltMod::Address::Ptr(), VoltMod::ReadFile(), and VoltMod::Log::Warn().
|
override |
Definition at line 31 of file GameEvents.cpp.
References RemoveAllListeners().
|
delete |
| 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(), VoltMod::Bindings::GameEventManager, VoltMod::Interfaces::GameEventManager, and VoltMod::Error::Unsupported().
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 VoltMod::Interfaces::GameEventManager, GetClientLegacyListener(), and VoltMod::ReadFile().
| IGameEvent * VoltMod::GameEvents::CreateEvent | ( | std::string_view | name | ) |
Definition at line 72 of file GameEvents.cpp.
References VoltMod::Interfaces::GameEventManager, and VoltMod::ReadFile().
Referenced by VoltMod::Messages::SendCenterHtml().
| bool VoltMod::GameEvents::FireEvent | ( | IGameEvent * | event, |
| bool | broadcast = true |
||
| ) |
Definition at line 84 of file GameEvents.cpp.
References VoltMod::Interfaces::GameEventManager, and VoltMod::ReadFile().
|
override |
Definition at line 178 of file GameEvents.cpp.
References VoltMod::ReadFile().
| void VoltMod::GameEvents::FreeEvent | ( | IGameEvent * | event | ) |
Definition at line 95 of file GameEvents.cpp.
References VoltMod::Interfaces::GameEventManager, and VoltMod::ReadFile().
| 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(), and VoltMod::ReadFile().
Referenced by VoltMod::Messages::Broadcast(), VoltMod::Messages::BroadcastKey(), ClientListensTo(), and VoltMod::Messages::SendCenterHtml().
|
inline |
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(), and VoltMod::ReadFile().
| 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::Interfaces::GameEventManager, VoltMod::Log::Info(), VoltMod::ReadFile(), and VoltMod::Log::Warn().
|
delete |
| void VoltMod::GameEvents::RemoveAllListeners | ( | ) |
Remove every handler and detach from the engine.
Definition at line 163 of file GameEvents.cpp.
References VoltMod::Interfaces::GameEventManager, and VoltMod::ReadFile().
Referenced by ~GameEvents().