Seaside/SpyCustom/sdk/GameEventListener.h
2021-06-16 18:45:17 +03:00

52 lines
942 B
C++

#ifndef GAME_EVENT_LISTENER_H
#define GAME_EVENT_LISTENER_H
#ifdef _WIN32
#pragma once
#endif
#include "igameevents.h"
extern IGameEventManager2* gameeventmanager;
class CGameEventListener : public IGameEventListener2
{
public:
CGameEventListener() : m_bRegisteredForEvents(false)
{
}
~CGameEventListener()
{
StopListeningForAllEvents();
}
void ListenForGameEvent(const char* name)
{
m_bRegisteredForEvents = true;
#ifdef CLIENT_DLL
bool bServerSide = false;
#else
bool bServerSide = true;
#endif
if (gameeventmanager)
gameeventmanager->AddListener(this, name, bServerSide);
}
void StopListeningForAllEvents()
{
if (m_bRegisteredForEvents)
{
if (gameeventmanager)
gameeventmanager->RemoveListener(this);
m_bRegisteredForEvents = false;
}
}
virtual void FireGameEvent(IGameEvent* event) = 0;
private:
bool m_bRegisteredForEvents;
};
#endif