src/ai/api/ai_accounting.hpp
author rubidium
Sun, 25 Mar 2007 12:38:29 +0000
branchnoai
changeset 9521 b9dabdbe1dc5
parent 9520 f7cf8bea10db
child 9524 283d23931bb4
permissions -rw-r--r--
(svn r9441) [NoAI] -Codechange: make the Squirrel method registration happen in the same order as the methods occur in the class.
/* $Id$ */

/** @file ai_accounting.hpp everything to handle AI accounting things */

#ifndef AI_ACCOUNTING_HPP
#define AI_ACCOUNTING_HPP

#include "ai_object.hpp"

/**
 * Class that handles all AI accounting related functions.
 * Example:
 *   {
 *     local costs = AIAccounting();
 *     BuildRoad(from_here, to_here);
 *     BuildRoad(from_there, to_there);
 *     print("Costs for route is: " + costs.GetCosts());
 *   }
 */
class AIAccounting : public AIObject {
private:
	int32 last_costs;
public:
	/**
	 * Creating instance of this class starts counting the costs of commands
	 *   from zero.
	 * @note when the instance is destroyed, he restores the costs that was
	 *   current when the instance was created!
	 */
	AIAccounting();

	/**
	 * Destroying this instance reset the costs to the value it was
	 *   in when the instance was created.
	 */
	~AIAccounting();

	/**
	 * Get the current value of the costs.
	 */
	int32 GetCosts();

	/**
	 * Reset the costs to zero.
	 */
	void ResetCosts();
};

#ifdef DEFINE_SQUIRREL_CLASS
void SQAIAccountingRegister(Squirrel *engine) {
	DefSQClass <AIAccounting> SQAIAccounting("AIAccounting");
	SQAIAccounting.PreRegister(engine);
	SQAIAccounting.AddConstructor(engine);
	SQAIAccounting.DefSQFunction(engine, &AIAccounting::GetCosts,   "GetCosts");
	SQAIAccounting.DefSQFunction(engine, &AIAccounting::ResetCosts, "ResetCosts");
	SQAIAccounting.PostRegister(engine);
}
#endif /* DEFINE_SQUIRREL_CLASS */

#endif /* AI_ACCOUNTING_HPP */