src/ai/api/ai_tunnel.hpp
author truebrain
Wed, 26 Mar 2008 15:17:40 +0000
branchnoai
changeset 9823 0b7f816cf46f
parent 9807 5b3be41b3ce6
child 9829 80fbe02a4184
permissions -rw-r--r--
(svn r12431) [NoAI] -Add: added AIEventSubsidiaryOffer, which keeps you informed about new Subsidiaries
/** @file ai_tunnel.hpp Used to query and build tunnels. */

#ifndef AI_TUNNEL_HPP
#define AI_TUNNEL_HPP

#include "ai_object.hpp"
#include "ai_vehicle.hpp"

/**
 * Class that handles all tunnel related functions.
 */
class AITunnel : public AIObject {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITunnel"; }

	/**
	 * Check whether the tile is an entrance to a tunnel.
	 * @pre AIMap::IsValidTile(tile).
	 * @param tile The tile to check.
	 * @note true if and only if the tile is the beginning or end of a tunnel.
	 */
	static bool IsTunnelTile(TileIndex tile);

	/**
	 * Get the tile that exits on the other end of a (would be) tunnel starting at tile.
	 * @pre AIMap::IsValidTile(tile).
	 * @param tile A tile that is an entrance to a tunnel or a tile where you may want to build a tunnel.
	 * @return The TileIndex that is the other end of the (would be) tunnel, or 'tile' if no other end was found (crossing tunnels).
	 */
	static TileIndex GetOtherTunnelEnd(TileIndex tile);

	/**
	 * Builds a tunnel starting at start. The direction of the tunnel depends
	 *  on the slope of the start tile. Tunnels can be created for either
	 *  rails or roads; use the appropriate AIVehicle::VehicleType.
	 * @param start Where to start the tunnel.
	 * @param vehicle_type The vehicle-type of tunnel to build.
	 * @pre AIMap::IsValidTile(start).
	 * @pre vehicle_type is either AIVehicle::VEHICLE_RAIL or AIVEHICLE::VEHICLE_ROAD.
	 * @return Whether the tunnel has been/can be build or not.
	 * @note The slope of a tile can be determined by AITile::GetSlope(TileIndex).
	 */
	static bool BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start);

	/**
	 * Remove the tunnel whose entrance is located at tile.
	 * @param tile a tile that is an entrance to a tunnel.
	 * @pre AIMap::IsValidTile(tile) && IsTunnelTile(tile).
	 * @return Whether the tunnel has been/can be removed or not.
	 */
	static bool RemoveTunnel(TileIndex tile);
};

#endif /* AI_TUNNEL_HPP */