|
1 /* $Id$ */ |
|
2 |
|
3 /** @file ai_execmode.hpp class to switch the AI to Execute mode */ |
|
4 |
|
5 #ifndef AI_EXECMODE_HPP |
|
6 #define AI_EXECMODE_HPP |
|
7 |
|
8 #include "ai_object.hpp" |
|
9 |
|
10 /** |
|
11 * Class to switch current mode to Execute mode. |
|
12 * If you create an instance of this class, the mode will be switched to |
|
13 * Execute. The original mode is stored and recovered from when ever the |
|
14 * instance is destroyed. |
|
15 * In Execute mode all commands you do are executed for real. |
|
16 */ |
|
17 class AIExecMode : public AIObject { |
|
18 private: |
|
19 AIModeProc *last_mode; |
|
20 |
|
21 protected: |
|
22 static bool ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); |
|
23 |
|
24 public: |
|
25 /** |
|
26 * Creating instance of this class switches the build mode to Execute. |
|
27 * @note when the instance is destroyed, he restores the mode that was |
|
28 * current when the instance was created! |
|
29 */ |
|
30 AIExecMode(); |
|
31 |
|
32 /** |
|
33 * Destroying this instance reset the building mode to the mode it was |
|
34 * in when the instance was created. |
|
35 */ |
|
36 ~AIExecMode(); |
|
37 }; |
|
38 |
|
39 #ifdef DEFINE_SQUIRREL_CLASS |
|
40 void SQAIExecModeRegister(Squirrel *engine) { |
|
41 DefSQClass <AIExecMode> SQAIExecMode("AIExecMode"); |
|
42 SQAIExecMode.PreRegister(engine); |
|
43 SQAIExecMode.AddConstructor(engine); |
|
44 SQAIExecMode.PostRegister(engine); |
|
45 } |
|
46 #endif /* SQUIRREL_CLASS */ |
|
47 |
|
48 #endif /* AI_EXECMODE_HPP */ |