|
1 /* $Id$ */ |
|
2 |
|
3 /** @file ai_event.hpp Everything to handle events from the game */ |
|
4 |
|
5 #ifndef AI_EVENT_HPP |
|
6 #define AI_EVENT_HPP |
|
7 |
|
8 #include "ai_object.hpp" |
|
9 |
|
10 /** |
|
11 * A single event that can be triggered by the game. |
|
12 * You can lookup the type, and than convert it to the real event-class. |
|
13 * That way you can request more detailed information about the event. |
|
14 */ |
|
15 class AIEvent : public AIObject { |
|
16 public: |
|
17 /** |
|
18 * The type of event. Needed to lookup the detailed class. |
|
19 */ |
|
20 enum AIEventType { |
|
21 AI_ET_INVALID = 0, |
|
22 AI_ET_TEST, |
|
23 AI_ET_CRASHED_VEHICLE, |
|
24 }; |
|
25 |
|
26 AIEvent(AIEvent::AIEventType type) : |
|
27 type(type) |
|
28 {} |
|
29 |
|
30 /** |
|
31 * Get the event-type. |
|
32 */ |
|
33 AIEventType GetEventType() { return this->type; } |
|
34 |
|
35 /** |
|
36 * The name of the class, needed by several sub-processes. |
|
37 */ |
|
38 static const char *GetClassName() { return "AIEvent"; } |
|
39 |
|
40 protected: |
|
41 /** |
|
42 * The type of this event. |
|
43 */ |
|
44 AIEventType type; |
|
45 }; |
|
46 |
|
47 /** |
|
48 * Class that handles all event related functions. |
|
49 * @note it is not needed to create an instance of AIEvent to access it, as |
|
50 * all members are static, and all data is stored AI-wide. |
|
51 */ |
|
52 class AIEventController : public AIObject { |
|
53 public: |
|
54 /** |
|
55 * The name of the class, needed by several sub-processes. |
|
56 */ |
|
57 static const char *GetClassName() { return "AIEventController"; } |
|
58 |
|
59 /** |
|
60 * Check if there is an event waiting. |
|
61 * @return true if there is an event on the stack. |
|
62 */ |
|
63 static bool IsEventWaiting(); |
|
64 |
|
65 /** |
|
66 * Get the next event. |
|
67 * @return a class of the event-child issues. |
|
68 */ |
|
69 static AIEvent *GetNextEvent(); |
|
70 |
|
71 /** |
|
72 * No longer report an event of this type. |
|
73 * @param event the event to no longer report. |
|
74 */ |
|
75 static void DisableEvent(AIEvent::AIEventType event); |
|
76 |
|
77 /** |
|
78 * Report events of this type. |
|
79 * @param event the event to report again. |
|
80 */ |
|
81 static void EnableEvent(AIEvent::AIEventType event); |
|
82 |
|
83 /** |
|
84 * Disable all events. |
|
85 */ |
|
86 static void DisableAllEvents(); |
|
87 |
|
88 /** |
|
89 * Enable all events. |
|
90 */ |
|
91 static void EnableAllEvents(); |
|
92 |
|
93 /** |
|
94 * Insert an event to the queue for the player. |
|
95 */ |
|
96 static void InsertEvent(AIEvent *event); |
|
97 |
|
98 /** |
|
99 * Give a test event to the system. |
|
100 */ |
|
101 static void Test(); |
|
102 |
|
103 /** |
|
104 * Free the event pointer. |
|
105 * @note DO NOT CALL YOURSELF; leave it to the internal AI programming. |
|
106 */ |
|
107 static void FreeEventPointer(); |
|
108 |
|
109 private: |
|
110 /** |
|
111 * Create the event pointer. |
|
112 */ |
|
113 static void CreateEventPointer(); |
|
114 }; |
|
115 |
|
116 #endif /* AI_EVENT_HPP */ |