rubidium@9405: /* $Id$ */ rubidium@9405: truebrain@9829: /** @file ai_industry.hpp Everything to query and build industries. */ rubidium@9405: rubidium@9405: #ifndef AI_INDUSTRY_HPP rubidium@9405: #define AI_INDUSTRY_HPP rubidium@9405: rubidium@9405: #include "ai_object.hpp" rubidium@9723: #include "../../industry.h" rubidium@9405: truelight@9448: /** truelight@9448: * Class that handles all industry related functions. truelight@9448: */ rubidium@9405: class AIIndustry : public AIObject { rubidium@9405: public: truelight@9529: static const char *GetClassName() { return "AIIndustry"; } truelight@9529: truelight@9529: /** truelight@9448: * Gets the maximum industry index; there are no valid industries with a truelight@9448: * higher index. truebrain@9836: * @return The maximum industry index. truebrain@9836: * @post Return value is always non-negative. rubidium@9405: */ truebrain@9737: static IndustryID GetMaxIndustryID(); rubidium@9405: rubidium@9405: /** truelight@9448: * Gets the number of industries. This is different than GetMaxIndustryID() truelight@9448: * because of the way OpenTTD works internally. truebrain@9836: * @return The number of industries. truebrain@9836: * @post Return value is always non-negative. rubidium@9405: */ truebrain@9737: static int32 GetIndustryCount(); rubidium@9405: rubidium@9405: /** truelight@9448: * Checks whether the given industry index is valid. truebrain@9836: * @param industry_id The index to check. truebrain@9836: * @return True if and only if the industry is valid. rubidium@9405: */ rubidium@9497: static bool IsValidIndustry(IndustryID industry_id); rubidium@9405: rubidium@9405: /** truelight@9448: * Get the name of the industry. truebrain@9836: * @param industry_id The industry to get the name of. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @return The name of the industry. rubidium@9405: */ truebrain@9737: static char *GetName(IndustryID industry_id); rubidium@9405: rubidium@9405: /** truelight@9649: * Gets the production of a cargo of the industry. truebrain@9836: * @param industry_id The index of the industry. truebrain@9836: * @param cargo_id The index of the cargo. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @pre AICargo::IsValidCargo(cargo_id). truebrain@9836: * @return The production of the cargo for this industry, or -1 if truebrain@9787: * this industry doesn't produce this cargo. truelight@9649: */ truelight@9650: static int32 GetProduction(IndustryID industry_id, CargoID cargo_id); truelight@9649: truelight@9649: /** truelight@9710: * See if an industry accepts a certain cargo. truebrain@9836: * @param industry_id The index of the industry. truebrain@9836: * @param cargo_id The index of the cargo. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @pre AICargo::IsValidCargo(cargo_id). truebrain@9836: * @return The production of the cargo for this industry. truelight@9710: */ truelight@9710: static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id); truelight@9710: truelight@9710: /** truebrain@9810: * Get the total last month's production of the given cargo at an industry. truebrain@9836: * @param industry_id The index of the industry. truebrain@9836: * @param cargo_id The index of the cargo. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @pre AICargo::IsValidCargo(cargo_id). truebrain@9836: * @return The last month's production of the given cargo for this industry. truebrain@9810: */ truebrain@9810: static uint16 GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id); truebrain@9810: truebrain@9810: /** truebrain@9810: * Get the total amount of cargo transported from an industry last month. truebrain@9836: * @param industry_id The index of the industry. truebrain@9836: * @param cargo_id The index of the cargo. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @pre AICargo::IsValidCargo(cargo_id). truebrain@9836: * @return The amount of given cargo transported from this industry last month. truebrain@9810: */ truebrain@9810: static uint16 GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id); truebrain@9814: truebrain@9814: /** truebrain@9836: * Gets the location of the industry. truebrain@9836: * @param industry_id The index of the industry. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @return The location of the industry. truebrain@9836: */ truebrain@9836: static TileIndex GetLocation(IndustryID industry_id); truebrain@9836: truebrain@9836: /** truebrain@9814: * Get the manhattan distance from the tile to the AIIndustry::GetLocation() truebrain@9814: * of the industry. truebrain@9814: * @param industry_id The industry to get the distance to. truebrain@9814: * @param tile The tile to get the distance to. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @pre AIMap::IsValidTile(tile). truebrain@9814: * @return The distance between industry and tile. truebrain@9814: */ truebrain@9814: static int32 GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile); truebrain@9814: truebrain@9814: /** truebrain@9814: * Get the square distance from the tile to the AIIndustry::GetLocation() truebrain@9814: * of the industry. truebrain@9814: * @param industry_id The industry to get the distance to. truebrain@9814: * @param tile The tile to get the distance to. truebrain@9836: * @pre IsValidIndustry(industry_id). truebrain@9836: * @pre AIMap::IsValidTile(tile). truebrain@9814: * @return The distance between industry and tile. truebrain@9814: */ truebrain@9814: static int32 GetDistanceSquareToTile(IndustryID industry_id, TileIndex tile); rubidium@9405: }; rubidium@9405: rubidium@9405: #endif /* AI_INDUSTRY_HPP */