forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.h
47 lines (39 loc) · 2.1 KB
/
event.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
#ifndef _EVENT_H
#define _EVENT_H
#include "util.h"
class Level;
class Creature;
class Item;
class EventListener {
public:
virtual void onPickupEvent(const Creature*, const vector<Item*>& items) {}
virtual void onDropEvent(const Creature*, const vector<Item*>& items) {}
virtual void onItemsAppeared(Vec2 position, const vector<Item*>& items) {}
virtual void onKillEvent(const Creature* victim, const Creature* killer) {}
virtual void onAttackEvent(const Creature* victim, const Creature* attacker) {}
// triggered when the monster AI is either attacking, chasing or fleeing
virtual void onCombatEvent(const Creature*) {}
virtual void onThrowEvent(const Creature* thrower, const Item* item, const vector<Vec2>& trajectory) {}
virtual void onExplosionEvent(const Level* level, Vec2 pos) {}
virtual void onTriggerEvent(const Level*, Vec2 pos) {}
virtual void onSquareReplacedEvent(const Level*, Vec2 pos) {}
virtual void onChangeLevelEvent(const Creature*, const Level* from, Vec2 pos, const Level* to, Vec2 toPos) {}
static void addPickupEvent(const Creature*, const vector<Item*>& items);
static void addDropEvent(const Creature*, const vector<Item*>& items);
static void addItemsAppeared(const Level*, Vec2 position, const vector<Item*>& items);
static void addKillEvent(const Creature* victim, const Creature* killer);
static void addAttackEvent(const Creature* victim, const Creature* attacker);
static void addCombatEvent(const Creature*);
static void addThrowEvent(const Level*, const Creature* thrower, const Item* item, const vector<Vec2>& trajectory);
static void addExplosionEvent(const Level* level, Vec2 pos);
static void addTriggerEvent(const Level*, Vec2 pos);
static void addSquareReplacedEvent(const Level*, Vec2 pos);
static void addChangeLevelEvent(const Creature*, const Level* from, Vec2 pos, const Level* to, Vec2 toPos);
static void addListener(EventListener*);
static void removeListener(EventListener*);
virtual const Level* getListenerLevel() const { return nullptr; }
static void initialize();
private:
static vector<EventListener*> listeners;
};
#endif