src/ai/api/ai_execmode.hpp
author truelight
Sun, 18 Mar 2007 16:02:23 +0000
branchnoai
changeset 9450 d675836e865c
child 9473 dcbcd1c4496d
permissions -rw-r--r--
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
-Add: added AIExecMode and AITestMode which allows to switch the DoCommand mode
/* $Id$ */

/** @file ai_execmode.hpp class to switch the AI to Execute mode */

#ifndef AI_EXECMODE_HPP
#define AI_EXECMODE_HPP

#include "ai_object.hpp"

/**
 * Class to switch current mode to Execute mode.
 * If you create an instance of this class, the mode will be switched to
 *   Execute. The original mode is stored and recovered from when ever the
 *   instance is destroyed.
 * In Execute mode all commands you do are executed for real.
 */
class AIExecMode : public AIObject {
private:
	AIModeProc *last_mode;

protected:
	static bool ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);

public:
	/**
	 * Creating instance of this class switches the build mode to Execute.
	 * @note when the instance is destroyed, he restores the mode that was
	 *   current when the instance was created!
	 */
	AIExecMode();

	/**
	 * Destroying this instance reset the building mode to the mode it was
	 *   in when the instance was created.
	 */
	~AIExecMode();
};

#ifdef DEFINE_SQUIRREL_CLASS
void SQAIExecModeRegister(Squirrel *engine) {
	DefSQClass <AIExecMode> SQAIExecMode("AIExecMode");
	SQAIExecMode.PreRegister(engine);
	SQAIExecMode.AddConstructor(engine);
	SQAIExecMode.PostRegister(engine);
}
#endif /* SQUIRREL_CLASS */

#endif /* AI_EXECMODE_HPP */