1 class Observer
2 {
3 public:
4 virtual ~Observer() {}
5 virtual void onNotify(const Entity& entity, Event event) = 0;
6 };
7 class Achievements : public Observer
8 {
9 public:
10 virtual void onNotify(const Entity& entity, Event event)
11 {
12 switch (event)
13 {
14 case EVENT_ENTITY_FELL:
15 if (entity.isHero() && heroIsOnBridge_)
16 {
17 unlock(ACHIEVEMENT_FELL_OFF_BRIDGE);
18 }
19 break;
20
21 // Handle other events, and update heroIsOnBridge_...
22 }
23 }
24
25 private:
26 void unlock(Achievement achievement)
27 {
28 // Unlock if not already unlocked...
29 }
30
31 bool heroIsOnBridge_;
32 };