Add example event listener on player_footstep.
Signed-off-by: aixxe <me@aixxe.net>
This commit is contained in:
23
src/Events/TestListener.h
Normal file
23
src/Events/TestListener.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
class TestEventListener: public IGameEventListener2 {
|
||||
public:
|
||||
TestEventListener(const char* name) {
|
||||
// Register self as an event listener.
|
||||
gameevents->AddListener(this, name, false);
|
||||
};
|
||||
|
||||
~TestEventListener() {
|
||||
// Unregister when destructor is called.
|
||||
gameevents->RemoveListener(this);
|
||||
}
|
||||
|
||||
void FireGameEvent(IGameEvent* event) {
|
||||
// Print text to console when event is fired.
|
||||
cvar->ConsoleColorPrintf(Color(150, 255, 150), "Event fired: %s\n", event->GetName());
|
||||
}
|
||||
|
||||
int GetEventDebugID() override {
|
||||
return EVENT_DEBUG_ID_INIT;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user