src/ai/core/ai_map.hpp
author truelight
Thu, 15 Mar 2007 13:36:45 +0000
branchnoai
changeset 9404 ef9e171617a3
parent 9397 d8f8db9c1a2e
child 9422 33efcc5f1b09
permissions -rw-r--r--
(svn r9201) [NoAI] -Change: make adding a default-constructor for DefSQClass optional
-Add: added AIFactory code for squirrel. Now scripts can make theirself
known to the core in a simular way as in C++. Just make sure to add
your AIFactory instance to the GLOBAL space!
-Add: even more function in SquirrelEngine
/* $Id$ */

/** @file ai_map.hpp Everything to query map metadata */

#ifndef AI_MAP_HPP
#define AI_MAP_HPP

#include "ai_object.hpp"

class AIMap : public AIObject {
public:
	/**
	 * Checks whether the given tile is valid
	 * @param t the tile to check
	 * @return true is the tile it within the boundaries of the map
	 */
	bool IsValidTile(TileIndex t);

	/**
	 * Gets the number of tiles in the map
	 * @return the size of the map in tiles
	 * @post return > 0
	 */
	TileIndex GetMapSize();

	/**
	 * Gets the amount of tiles along the SW and NE border
	 * @return the length along the SW and NE borders
	 * @post return > 0
	 */
	uint32 GetMapSizeX();

	/**
	 * Gets the amount of tiles along the SE and NW border
	 * @return the length along the SE and NW borders
	 * @post return > 0
	 */
	uint32 GetMapSizeY();

	/**
	 * Gets the X (place along the SW/NE border)
	 * @param t the tile to get the X of
	 * @pre this->IsValidTile(t)
	 * @return the x-position
	 * @post return <= this->GetMapSizeX()
	 */
	uint32 GetTileX(TileIndex t);

	/**
	 * Gets the Y (place along the SE/NW border)
	 * @param t the tile to get the Y of
	 * @pre this->IsValidTile(t)
	 * @return the y-position
	 * @post return <= this->GetMapSizeY()
	 */
	uint32 GetTileY(TileIndex t);
};

#ifdef SQUIRREL_CLASS
void SQAIMapRegister(SquirrelEngine *engine) {
	DefSQClass <AIMap> SQAIMap("AIMap");
	SQAIMap.PreRegister(engine);
	SQAIMap.AddConstructor(engine);
	SQAIMap.DefSQFunction(engine, &AIMap::IsValidTile, "IsValidTile");
	SQAIMap.DefSQFunction(engine, &AIMap::GetMapSize,  "GetMapSize");
	SQAIMap.DefSQFunction(engine, &AIMap::GetMapSizeX, "GetMapSizeX");
	SQAIMap.DefSQFunction(engine, &AIMap::GetMapSizeY, "GetMapSizeY");
	SQAIMap.DefSQFunction(engine, &AIMap::GetTileX,    "GetTileX");
	SQAIMap.DefSQFunction(engine, &AIMap::GetTileY,    "GetTileY");
	SQAIMap.PostRegister(engine);
}
#endif /* SQUIRREL_CLASS */

#endif /* AI_MAP_HPP */