src/ai/api/ai_tilelist.hpp
author truebrain
Fri, 22 Feb 2008 12:30:17 +0000
branchnoai
changeset 9737 ee408edf3851
parent 9600 59cc173953ae
child 9751 556f25efbc54
permissions -rw-r--r--
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
/* $Id$ */

/** @file ai_tilelist.hpp a simple tilelist which you can manipulate */

#ifndef AI_TILELIST_HPP
#define AI_TILELIST_HPP

#include "ai_abstractlist.hpp"

/**
 * Class that creates a simple list of tiles which you can manipulate.
 */
class AITileList : public AIAbstractList {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileList"; }

private:
	/**
	 * Make sure t1.x is smaller than t2.x and t1.y is smaller than t2.y.
	 * They are swapped to ensure they are after calling this function.
	 */
	void FixRectangleSpan(TileIndex &t1, TileIndex &t2);

public:

	/**
	 * Adds the rectangle between tile_from and tile_to to the to-be-evaluated tiles.
	 * @param tile_from one corner of the tiles to add.
	 * @param tile_to the other corner of the tiles to add.
	 * @pre tile_from is below AIMap::GetMapSize().
	 * @pre tile_to is below AIMap::GetMapSize().
	 */
	void AddRectangle(TileIndex tile_from, TileIndex tile_to);

	/**
	 * Add a tile to the to-be-evaluated tiles.
	 * @param tile the tile to add.
	 * @pre tile is below AIMap::GetMapSize().
	 */
	void AddTile(TileIndex tile);

	/**
	 * Remove the tiles inside the rectangle between tile_from and tile_to form the list.
	 * @param tile_from one corner of the tiles to remove.
	 * @param tile_to the other corner of the files to remove.
	 * @pre tile_from is below AIMap::GetMapSize().
	 * @pre tile_to is below AIMap::GetMapSize().
	 */
	void RemoveRectangle(TileIndex tile_from, TileIndex tile_to);

	/**
	 * Remove a tile from the list.
	 * @param tile the tile to remove.
	 * @pre tile is below AIMap::GetMapSize().
	 */
	void RemoveTile(TileIndex tile);
};

#endif /* AI_TILELIST_HPP */