author | truelight |
Mon, 19 Mar 2007 14:30:56 +0000 | |
branch | noai |
changeset 9486 | a9b5f6b8667c |
parent 9475 | 58c20c0e394f |
child 9520 | f7cf8bea10db |
permissions | -rw-r--r-- |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
2 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
3 |
/** @file ai_execmode.hpp class to switch the AI to Execute mode */ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
4 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
5 |
#ifndef AI_EXECMODE_HPP |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
6 |
#define AI_EXECMODE_HPP |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
7 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
8 |
#include "ai_object.hpp" |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
9 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
10 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
11 |
* Class to switch current mode to Execute mode. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
12 |
* If you create an instance of this class, the mode will be switched to |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
13 |
* Execute. The original mode is stored and recovered from when ever the |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
14 |
* instance is destroyed. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
15 |
* In Execute mode all commands you do are executed for real. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
16 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
17 |
class AIExecMode : public AIObject { |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
18 |
private: |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
19 |
AIModeProc *last_mode; |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9450
diff
changeset
|
20 |
AIObject *last_instance; |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
21 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
22 |
protected: |
9475
58c20c0e394f
(svn r9320) [NoAI] -Fix: added some doxygen comments to make doxygen happy
truelight
parents:
9473
diff
changeset
|
23 |
/** |
58c20c0e394f
(svn r9320) [NoAI] -Fix: added some doxygen comments to make doxygen happy
truelight
parents:
9473
diff
changeset
|
24 |
* The callback proc for Execute mode. |
58c20c0e394f
(svn r9320) [NoAI] -Fix: added some doxygen comments to make doxygen happy
truelight
parents:
9473
diff
changeset
|
25 |
*/ |
9486
a9b5f6b8667c
(svn r9336) [NoAI] -Fix: remove 'flags' for AI DoCommand and detect its value automaticly
truelight
parents:
9475
diff
changeset
|
26 |
static bool ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint procc, int32 costs); |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
27 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
28 |
public: |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
29 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
30 |
* Creating instance of this class switches the build mode to Execute. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
31 |
* @note when the instance is destroyed, he restores the mode that was |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
32 |
* current when the instance was created! |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
33 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
34 |
AIExecMode(); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
35 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
36 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
37 |
* Destroying this instance reset the building mode to the mode it was |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
38 |
* in when the instance was created. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
39 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
40 |
~AIExecMode(); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
41 |
}; |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
42 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
43 |
#ifdef DEFINE_SQUIRREL_CLASS |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
44 |
void SQAIExecModeRegister(Squirrel *engine) { |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
45 |
DefSQClass <AIExecMode> SQAIExecMode("AIExecMode"); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
46 |
SQAIExecMode.PreRegister(engine); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
47 |
SQAIExecMode.AddConstructor(engine); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
48 |
SQAIExecMode.PostRegister(engine); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
49 |
} |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
50 |
#endif /* SQUIRREL_CLASS */ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
51 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
52 |
#endif /* AI_EXECMODE_HPP */ |