|
1 /* $Id$ */ |
|
2 |
|
3 /** @file ai_event_types.hpp The detailed types of all events */ |
|
4 |
|
5 #ifndef AI_EVENT_TYPES_HPP |
|
6 #define AI_EVENT_TYPES_HPP |
|
7 |
|
8 #include "ai_object.hpp" |
|
9 #include "ai_event.hpp" |
|
10 |
|
11 /** |
|
12 * A simple test event, to see if the event system is working. Triggered via |
|
13 * AIEventController::Test(); |
|
14 */ |
|
15 class AIEventTest : public AIEvent { |
|
16 public: |
|
17 /** |
|
18 * The name of the class, needed by several sub-processes. |
|
19 */ |
|
20 static const char *GetClassName() { return "AIEventTest"; } |
|
21 |
|
22 /** |
|
23 * Constructor for this event class. |
|
24 */ |
|
25 AIEventTest(uint test) : |
|
26 AIEvent(AI_ET_TEST), |
|
27 test(test) |
|
28 {} |
|
29 |
|
30 /** |
|
31 * Convert an AIEvent to the real instance. |
|
32 */ |
|
33 static AIEventTest *Convert(AIEvent *instance) { return (AIEventTest *)instance; } |
|
34 |
|
35 /** |
|
36 * Return the test value. |
|
37 */ |
|
38 uint GetTest() { return this->test; } |
|
39 |
|
40 private: |
|
41 uint test; |
|
42 }; |
|
43 |
|
44 /** |
|
45 * A vehicle crashed, and because of that this event is triggered. |
|
46 * It contains both the crash site as the vehicle crashed. It has a nice |
|
47 * helper that creates a new vehicle in a depot with the same type |
|
48 * and orders as the crashed one. In case the vehicle type isn't available |
|
49 * anymore, it will find the next best. |
|
50 */ |
|
51 class AIEventVehicleCrash : public AIEvent { |
|
52 public: |
|
53 /** |
|
54 * The name of the class, needed by several sub-processes. |
|
55 */ |
|
56 static const char *GetClassName() { return "AIEventVehicleCrash"; } |
|
57 |
|
58 /** |
|
59 * Constructor for this event class. |
|
60 */ |
|
61 AIEventVehicleCrash(VehicleID vehicle, TileIndex crash_site) : |
|
62 AIEvent(AI_ET_CRASHED_VEHICLE), |
|
63 crash_site(crash_site), |
|
64 vehicle(vehicle) |
|
65 {} |
|
66 |
|
67 /** |
|
68 * Convert an AIEvent to the real instance. |
|
69 */ |
|
70 static AIEventVehicleCrash *Convert(AIEvent *instance) { return (AIEventVehicleCrash *)instance; } |
|
71 |
|
72 /** |
|
73 * Get the vehicleID of the crashed vehicle. |
|
74 */ |
|
75 VehicleID GetVehicleID() { return vehicle; } |
|
76 |
|
77 /** |
|
78 * Find the tile the vehicle crashed. |
|
79 */ |
|
80 TileIndex GetCrashSite() { return crash_site; } |
|
81 |
|
82 /** |
|
83 * Clone the crashed vehicle and send it on its way again/ |
|
84 * @param depot the depot to build the vehicle in. |
|
85 */ |
|
86 bool CloneCrashedVehicle(TileIndex depot); |
|
87 |
|
88 private: |
|
89 TileIndex crash_site; |
|
90 VehicleID vehicle; |
|
91 }; |
|
92 |
|
93 #endif /* AI_EVENT_TYPES_HPP */ |