From a3dd7506d377b1434f913bd65c019eed52b64b6e Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 12 Jan 2009 17:11:45 +0000 Subject: (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see. NoAI is an API (a framework) to build your own AIs in. See: http://wiki.openttd.org/wiki/index.php/AI:Main_Page With many thanks to: - glx and Rubidium for their syncing, feedback and hard work - Yexo for his feedback, patches, and AIs which tested the system very deep - Morloth for his feedback and patches - TJIP for hosting a challenge which kept NoAI on track - All AI authors for testing our AI API, and all other people who helped in one way or another -Remove: all old AIs and their cheats/hacks --- src/ai/api/ai_industry.hpp | 171 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 src/ai/api/ai_industry.hpp (limited to 'src/ai/api/ai_industry.hpp') diff --git a/src/ai/api/ai_industry.hpp b/src/ai/api/ai_industry.hpp new file mode 100644 index 000000000..1b3365a97 --- /dev/null +++ b/src/ai/api/ai_industry.hpp @@ -0,0 +1,171 @@ +/* $Id$ */ + +/** @file ai_industry.hpp Everything to query and build industries. */ + +#ifndef AI_INDUSTRY_HPP +#define AI_INDUSTRY_HPP + +#include "ai_object.hpp" + +/** + * Class that handles all industry related functions. + */ +class AIIndustry : public AIObject { +public: + static const char *GetClassName() { return "AIIndustry"; } + + /** + * Gets the maximum industry index; there are no valid industries with a + * higher index. + * @return The maximum industry index. + * @post Return value is always non-negative. + */ + static IndustryID GetMaxIndustryID(); + + /** + * Gets the number of industries. This is different than GetMaxIndustryID() + * because of the way OpenTTD works internally. + * @return The number of industries. + * @post Return value is always non-negative. + */ + static int32 GetIndustryCount(); + + /** + * Checks whether the given industry index is valid. + * @param industry_id The index to check. + * @return True if and only if the industry is valid. + */ + static bool IsValidIndustry(IndustryID industry_id); + + /** + * Get the name of the industry. + * @param industry_id The industry to get the name of. + * @pre IsValidIndustry(industry_id). + * @return The name of the industry. + */ + static const char *GetName(IndustryID industry_id); + + /** + * Gets the production of a cargo of the industry. + * @param industry_id The index of the industry. + * @param cargo_id The index of the cargo. + * @pre IsValidIndustry(industry_id). + * @pre AICargo::IsValidCargo(cargo_id). + * @return The production of the cargo for this industry, or -1 if + * this industry doesn't produce this cargo. + */ + static int32 GetProduction(IndustryID industry_id, CargoID cargo_id); + + /** + * See if an industry accepts a certain cargo. + * @param industry_id The index of the industry. + * @param cargo_id The index of the cargo. + * @pre IsValidIndustry(industry_id). + * @pre AICargo::IsValidCargo(cargo_id). + * @return The production of the cargo for this industry. + */ + static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id); + + /** + * Get the amount of cargo stockpiled for processing. + * @param industry_id The index of the industry. + * @param cargo_id The index of the cargo. + * @pre IsValidIndustry(industry_id). + * @pre AICargo::IsValidCargo(cargo_id). + * @return The amount of cargo that is waiting for processing. + */ + static int32 GetStockpiledCargo(IndustryID industry_id, CargoID cargo_id); + + /** + * Get the total last month's production of the given cargo at an industry. + * @param industry_id The index of the industry. + * @param cargo_id The index of the cargo. + * @pre IsValidIndustry(industry_id). + * @pre AICargo::IsValidCargo(cargo_id). + * @return The last month's production of the given cargo for this industry. + */ + static int32 GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id); + + /** + * Get the total amount of cargo transported from an industry last month. + * @param industry_id The index of the industry. + * @param cargo_id The index of the cargo. + * @pre IsValidIndustry(industry_id). + * @pre AICargo::IsValidCargo(cargo_id). + * @return The amount of given cargo transported from this industry last month. + */ + static int32 GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id); + + /** + * Gets the location of the industry. + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @return The location of the industry. + */ + static TileIndex GetLocation(IndustryID industry_id); + + /** + * Get the number of stations around an industry. + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @return The number of stations around an industry. + */ + static int32 GetAmountOfStationsAround(IndustryID industry_id); + + /** + * Get the manhattan distance from the tile to the AIIndustry::GetLocation() + * of the industry. + * @param industry_id The industry to get the distance to. + * @param tile The tile to get the distance to. + * @pre IsValidIndustry(industry_id). + * @pre AIMap::IsValidTile(tile). + * @return The distance between industry and tile. + */ + static int32 GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile); + + /** + * Get the square distance from the tile to the AIIndustry::GetLocation() + * of the industry. + * @param industry_id The industry to get the distance to. + * @param tile The tile to get the distance to. + * @pre IsValidIndustry(industry_id). + * @pre AIMap::IsValidTile(tile). + * @return The distance between industry and tile. + */ + static int32 GetDistanceSquareToTile(IndustryID industry_id, TileIndex tile); + + /** + * Is this industry built on water. + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @return True when the industry is built on water. + */ + static bool IsBuiltOnWater(IndustryID industry_id); + + /** + * Does this industry have a heliport and dock? + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @return True when the industry has a heliport and dock. + */ + static bool HasHeliportAndDock(IndustryID industry_id); + + /** + * Gets the location of the industry's heliport/dock. + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @pre HasHeliportAndDock(industry_id). + * @return The location of the industry's heliport/dock. + */ + static TileIndex GetHeliportAndDockLocation(IndustryID industry_id); + + /** + * Get the IndustryType of the industry. + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @return The IndustryType of the industry. + */ + static IndustryType GetIndustryType(IndustryID industry_id); +}; + +#endif /* AI_INDUSTRY_HPP */ -- cgit v1.2.3-70-g09d2