-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.h
62 lines (50 loc) · 1.53 KB
/
events.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
class Listener : public IGameEventListener2 {
using game_event_t = void(__cdecl*)(IGameEvent*);
private:
std::map< std::string, std::vector< game_event_t > > m_events;
public:
// ctor.
__forceinline Listener() : m_events{} {
m_debug_id = 42;
}
void init();
__forceinline void add(const std::string& name, game_event_t fn) {
m_events[name].push_back(fn);
}
__forceinline void register_events() {
if (m_events.empty())
return;
for (const auto& e : m_events)
g_csgo.m_game_events->AddListener(this, e.first.data(), false);
}
//__forceinline void unregister_events( ) {
// g_csgo.m_game_events->RemoveListener( this );
//}
void FireGameEvent(IGameEvent* evt) override {
const std::string name = evt->GetName();
if (m_events.count(name) != 0) {
const auto& events = m_events[name];
for (const auto& e : events)
e(evt);
}
}
};
namespace events {
void round_start(IGameEvent* evt);
void round_end(IGameEvent* evt);
void player_hurt(IGameEvent* evt);
void bullet_impact(IGameEvent* evt);
void item_purchase(IGameEvent* evt);
void player_death(IGameEvent* evt);
void player_given_c4(IGameEvent* evt);
void bomb_beginplant(IGameEvent* evt);
void bomb_abortplant(IGameEvent* evt);
void bomb_planted(IGameEvent* evt);
void bomb_beep(IGameEvent* evt);
void bomb_begindefuse(IGameEvent* evt);
void bomb_abortdefuse(IGameEvent* evt);
void bomb_defused(IGameEvent* evt);
void bomb_exploded(IGameEvent* evt);
}
extern Listener g_listener;