truebrain@9829: /* $Id$ */ truebrain@9829: truebrain@9829: /** @file ai_tunnel.hpp Everything to query and build tunnels. */ truebrain@9794: truebrain@9794: #ifndef AI_TUNNEL_HPP truebrain@9794: #define AI_TUNNEL_HPP truebrain@9794: truebrain@9794: #include "ai_object.hpp" truebrain@9794: #include "ai_vehicle.hpp" truebrain@9794: truebrain@9794: /** truebrain@9794: * Class that handles all tunnel related functions. truebrain@9794: */ truebrain@9794: class AITunnel : public AIObject { truebrain@9794: public: truebrain@9794: static const char *GetClassName() { return "AITunnel"; } truebrain@9794: truebrain@9794: /** truebrain@9807: * Check whether the tile is an entrance to a tunnel. truebrain@9838: * @param tile The tile to check. truebrain@9801: * @pre AIMap::IsValidTile(tile). truebrain@9838: * @return True if and only if the tile is the beginning or end of a tunnel. truebrain@9794: */ truebrain@9794: static bool IsTunnelTile(TileIndex tile); truebrain@9794: truebrain@9794: /** truebrain@9838: * Get the tile that exits on the other end of a (would be) tunnel starting truebrain@9838: * at tile. truebrain@9838: * @param tile The tile that is an entrance to a tunnel or the tile where you may want to build a tunnel. truebrain@9807: * @pre AIMap::IsValidTile(tile). truebrain@9838: * @return The TileIndex that is the other end of the (would be) tunnel, or truebrain@9838: * 'tile' if no other end was found (crossing tunnels). truebrain@9794: */ truebrain@9794: static TileIndex GetOtherTunnelEnd(TileIndex tile); truebrain@9794: truebrain@9794: /** truebrain@9794: * Builds a tunnel starting at start. The direction of the tunnel depends truebrain@9794: * on the slope of the start tile. Tunnels can be created for either truebrain@9794: * rails or roads; use the appropriate AIVehicle::VehicleType. truebrain@9794: * @param start Where to start the tunnel. truebrain@9794: * @param vehicle_type The vehicle-type of tunnel to build. truebrain@9801: * @pre AIMap::IsValidTile(start). truebrain@9838: * @pre 'vehicle_type' is either AIVehicle::VEHICLE_RAIL or AIVEHICLE::VEHICLE_ROAD. truebrain@9794: * @return Whether the tunnel has been/can be build or not. truebrain@9794: * @note The slope of a tile can be determined by AITile::GetSlope(TileIndex). truebrain@9794: */ truebrain@9794: static bool BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start); truebrain@9794: truebrain@9794: /** truebrain@9794: * Remove the tunnel whose entrance is located at tile. truebrain@9838: * @param tile The tile that is an entrance to a tunnel. truebrain@9801: * @pre AIMap::IsValidTile(tile) && IsTunnelTile(tile). truebrain@9794: * @return Whether the tunnel has been/can be removed or not. truebrain@9794: */ truebrain@9794: static bool RemoveTunnel(TileIndex tile); truebrain@9794: }; truebrain@9794: truebrain@9794: #endif /* AI_TUNNEL_HPP */