truelight@9638: /* $Id$ */ truelight@9638: truebrain@9829: /** @file ai_station.hpp Everything to query and build stations. */ truelight@9638: truelight@9638: #ifndef AI_STATION_HPP truelight@9638: #define AI_STATION_HPP truelight@9638: truelight@9638: #include "ai_object.hpp" rubidium@9837: #include "../../station_type.h" truelight@9638: truelight@9638: /** truelight@9638: * Class that handles all station related functions. truelight@9638: */ truelight@9638: class AIStation : public AIObject { truelight@9638: public: truebrain@9829: static const char *GetClassName() { return "AIStation"; } truebrain@9829: truelight@9638: /** truelight@9670: * Type of stations known in the game. truelight@9670: */ truelight@9670: enum StationType { truebrain@9838: STATION_ANY = 0x00, //!< All station types truebrain@9838: STATION_TRAIN = 0x01, //!< Train station truebrain@9838: STATION_TRUCK_STOP = 0x02, //!< Truck station truebrain@9838: STATION_BUS_STOP = 0x04, //!< Bus station truebrain@9838: STATION_AIRPORT = 0x08, //!< Airport truebrain@9838: STATION_DOCK = 0x10, //!< Dock truelight@9670: }; truelight@9670: truelight@9670: /** truelight@9638: * Checks whether the given station is valid and owned by you. truebrain@9838: * @param station_id The station to check. truebrain@9838: * @return True if and only if the station is valid. truelight@9638: */ truelight@9638: static bool IsValidStation(StationID station_id); truelight@9638: truelight@9638: /** truebrain@9838: * Get the StationID of a tile, if there is a station. truebrain@9838: * @param tile The tile to find the stationID of truelight@9666: * @return StationID of the station. truebrain@9838: * @post Use IsValidStation() to see if the station is valid. truelight@9666: */ truelight@9666: static StationID GetStationID(TileIndex tile); truelight@9666: truelight@9666: /** truelight@9696: * Get the name of a station. truebrain@9838: * @param station_id The station to get the name of. truelight@9696: * @pre IsValidStation(station_id). truebrain@9838: * @return The name of the station. truelight@9696: */ truelight@9696: static char *GetName(StationID station_id); truelight@9696: truelight@9696: /** truelight@9638: * Get the current location of a station. truebrain@9838: * @param station_id The station to get the location of. truelight@9638: * @pre IsValidStation(station_id). truebrain@9838: * @return The tile the station is currently on. truelight@9638: */ truelight@9638: static TileIndex GetLocation(StationID station_id); truelight@9638: truelight@9638: /** truelight@9638: * See how much cargo there is waiting on a station. truebrain@9838: * @param station_id The station to get the cargo-waiting of. truebrain@9838: * @param cargo_id The cargo to get the cargo-waiting of. truelight@9638: * @pre IsValidStation(station_id). truelight@9638: * @pre IsValidCargo(cargo_id). truebrain@9838: * @return The amount of units waiting at the station. truelight@9638: */ truelight@9638: static int32 GetCargoWaiting(StationID station_id, CargoID cargo_id); truelight@9648: truelight@9648: /** truelight@9648: * See how high the rating is of a cargo on a station. truebrain@9838: * @param station_id The station to get the cargo-rating of. truebrain@9838: * @param cargo_id The cargo to get the cargo-rating of. truelight@9648: * @pre IsValidStation(station_id). truelight@9648: * @pre IsValidCargo(cargo_id). truebrain@9838: * @return The rating in percent of the cargo on the station. truelight@9648: */ truelight@9648: static int32 GetCargoRating(StationID station_id, CargoID cargo_id); truelight@9670: truelight@9670: /** truelight@9670: * Get the coverage radius of this type of station. truebrain@9838: * @param type The type of station. truebrain@9838: * @return The radius in tiles. truelight@9670: */ truelight@9670: static int32 GetCoverageRadius(AIStation::StationType type); truebrain@9814: truebrain@9814: /** truebrain@9814: * Get the manhattan distance from the tile to the AIStation::GetLocation() truebrain@9814: * of the station. truebrain@9814: * @param station_id The station to get the distance to. truebrain@9814: * @param tile The tile to get the distance to. truebrain@9814: * @return The distance between station and tile. truebrain@9814: */ truebrain@9814: static int32 GetDistanceManhattanToTile(StationID station_id, TileIndex tile); truebrain@9814: truebrain@9814: /** truebrain@9814: * Get the square distance from the tile to the AIStation::GetLocation() truebrain@9814: * of the station. truebrain@9814: * @param station_id The station to get the distance to. truebrain@9814: * @param tile The tile to get the distance to. truebrain@9814: * @return The distance between station and tile. truebrain@9814: */ truebrain@9814: static int32 GetDistanceSquareToTile(StationID station_id, TileIndex tile); truelight@9638: }; truebrain@9838: truelight@9670: DECLARE_ENUM_AS_BIT_SET(AIStation::StationType); truelight@9638: truelight@9638: #endif /* AI_STATION_HPP */