# AIIndustryType Class Reference

Class that handles all industry-type related functions. More...

`#include <ai_industrytype.hpp>`

Inheritance diagram for AIIndustryType:

## Public Types
enum | SpecialIndustryType { INDUSTRYTYPE_UNKNOWN = 0xFE, INDUSTRYTYPE_TOWN = 0xFF }
| Special IndustryTypes. More...
## Static Public Member Functions
static const char * | GetClassName ()
| Get the name of this class to identify it towards squirrel.
static bool | IsValidIndustryType (IndustryType industry_type)
| Checks whether the given industry-type is valid.
static char * | GetName (IndustryType industry_type)
| Get the name of an industry-type.
static AIList * | GetProducedCargo (IndustryType industry_type)
| Get a list of CargoID possible produced by this industry-type.
static AIList * | GetAcceptedCargo (IndustryType industry_type)
| Get a list of CargoID accepted by this industry-type.
static bool | IsRawIndustry (IndustryType industry_type)
| Is this industry type a raw industry?
static bool | ProductionCanIncrease (IndustryType industry_type)
| Can the production of this industry increase?
static Money | GetConstructionCost (IndustryType industry_type)
| Get the cost for building this industry-type.
static bool | CanBuildIndustry (IndustryType industry_type)
| Can you build this type of industry?
static bool | CanProspectIndustry (IndustryType industry_type)
| Can you prospect this type of industry?
static bool | BuildIndustry (IndustryType industry_type, TileIndex tile)
| Build an industry of the specified type.
static bool | ProspectIndustry (IndustryType industry_type)
| Prospect an industry of this type.
static bool | IsBuiltOnWater (IndustryType industry_type)
| Is this type of industry built on water.
static bool | HasHeliport (IndustryType industry_type)
| Does this type of industry have a heliport?
static bool | HasDock (IndustryType industry_type)
| Does this type of industry have a dock?

## Detailed Description

Class that handles all industry-type related functions.

Definition at line 20 of file ai_industrytype.hpp.

## Member Enumeration Documentation

enum AIIndustryType::SpecialIndustryType

Special IndustryTypes.

Enumerator:

  INDUSTRYTYPE_UNKNOWN | Unknown/unspecific industrytype. (Usable for AIRail::BuildNewGRFRailStation()).
  INDUSTRYTYPE_TOWN | No industry, but town. (Usable for AIRail::BuildNewGRFRailStation()).

Definition at line 28 of file ai_industrytype.hpp.

## Member Function Documentation

bool AIIndustryType::BuildIndustry | ( | IndustryType | industry_type,
|  | TileIndex | tile |
| ) |  |  | `[static]`

Build an industry of the specified type.

Parameters:

  | industry_type | The type of the industry to build.
  | tile | The tile to build the industry on.

Precondition:
  CanBuildIndustry(industry_type).

Returns:
  True if the industry was successfully build.

Definition at line 112 of file ai_industrytype.cpp.

References CanBuildIndustry(), CMD_BUILD_INDUSTRY, AIObject::DoCommand(), EnforcePrecondition, GetIndustrySpec(), and AIMap::IsValidTile().

bool AIIndustryType::CanBuildIndustry | ( | IndustryType | industry_type | ) | `[static]`

Can you build this type of industry?

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  True if you can build this type of industry at locations of your choice.

Note:
  Returns false if you can only prospect this type of industry, or not build it at all.

Definition at line 90 of file ai_industrytype.cpp.

References _settings_game, CheckIfCallBackAllowsAvailability(), GameSettings::construction, GetIndustrySpec(), IACT_USERCREATION, IsRawIndustry(), IsValidIndustryType(), and ConstructionSettings::raw_industry_construction.

Referenced by BuildIndustry().

bool AIIndustryType::CanProspectIndustry | ( | IndustryType | industry_type | ) | `[static]`

Can you prospect this type of industry?

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  True if you can prospect this type of industry.

Note:
  If the setting "Manual primary industry construction method" is set to either "None" or "as other industries" this function always returns false.

Definition at line 101 of file ai_industrytype.cpp.

References _settings_game, CheckIfCallBackAllowsAvailability(), GameSettings::construction, GetIndustrySpec(), IACT_USERCREATION, IsRawIndustry(), IsValidIndustryType(), and ConstructionSettings::raw_industry_construction.

Referenced by ProspectIndustry().

AIList * AIIndustryType::GetAcceptedCargo | ( | IndustryType | industry_type | ) | `[static]`

Get a list of CargoID accepted by this industry-type.

Warning:
  This function only returns the default cargos of the industry type. Industries can specify new cargotypes on construction.

Parameters:

  | industry_type | The type to get the CargoIDs for.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  The CargoIDs of all cargotypes this industry accepts.

Definition at line 76 of file ai_industrytype.cpp.

References IndustrySpec::accepts_cargo, CT_INVALID, GetIndustrySpec(), IsValidIndustryType(), and lengthof.

static const char* AIIndustryType::GetClassName | ( |  | ) | `[inline, static]`

Get the name of this class to identify it towards squirrel.

Definition at line 23 of file ai_industrytype.hpp.

Money AIIndustryType::GetConstructionCost | ( | IndustryType | industry_type | ) | `[static]`

Get the cost for building this industry-type.

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  The cost for building this industry-type.

Definition at line 43 of file ai_industrytype.cpp.

References _settings_game, GameSettings::construction, IndustrySpec::GetConstructionCost(), GetIndustrySpec(), IsRawIndustry(), IsValidIndustryType(), and ConstructionSettings::raw_industry_construction.

char * AIIndustryType::GetName | ( | IndustryType | industry_type | ) | `[static]`

Get the name of an industry-type.

Parameters:

  | industry_type | The type to get the name for.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  The name of an industry.

Definition at line 51 of file ai_industrytype.cpp.

References GetIndustrySpec(), and IsValidIndustryType().

AIList * AIIndustryType::GetProducedCargo | ( | IndustryType | industry_type | ) | `[static]`

Get a list of CargoID possible produced by this industry-type.

Warning:
  This function only returns the default cargos of the industry type. Industries can specify new cargotypes on construction.

Parameters:

  | industry_type | The type to get the CargoIDs for.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  The CargoIDs of all cargotypes this industry could produce.

Definition at line 62 of file ai_industrytype.cpp.

References CT_INVALID, GetIndustrySpec(), IsValidIndustryType(), and lengthof.

bool AIIndustryType::HasDock | ( | IndustryType | industry_type | ) | `[static]`

Does this type of industry have a dock?

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  True when this type has a dock.

Definition at line 143 of file ai_industrytype.cpp.

References GetIndustrySpec(), INDUSTRYBEH_AI_AIRSHIP_ROUTES, and IsValidIndustryType().

bool AIIndustryType::HasHeliport | ( | IndustryType | industry_type | ) | `[static]`

Does this type of industry have a heliport?

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  True when this type has a heliport.

Definition at line 136 of file ai_industrytype.cpp.

References GetIndustrySpec(), INDUSTRYBEH_AI_AIRSHIP_ROUTES, and IsValidIndustryType().

bool AIIndustryType::IsBuiltOnWater | ( | IndustryType | industry_type | ) | `[static]`

Is this type of industry built on water.

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  True when this type is built on water.

Definition at line 129 of file ai_industrytype.cpp.

References GetIndustrySpec(), INDUSTRYBEH_BUILT_ONWATER, and IsValidIndustryType().

bool AIIndustryType::IsRawIndustry | ( | IndustryType | industry_type | ) | `[static]`

Is this industry type a raw industry?

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  True if it should be handled as a raw industry.

Definition at line 28 of file ai_industrytype.cpp.

References GetIndustrySpec(), IndustrySpec::IsRawIndustry(), and IsValidIndustryType().

Referenced by CanBuildIndustry(), CanProspectIndustry(), and GetConstructionCost().

bool AIIndustryType::IsValidIndustryType | ( | IndustryType | industry_type | ) | `[static]`

Checks whether the given industry-type is valid.

Parameters:

  | industry_type | The type check.

Returns:
  True if and only if the industry-type is valid.

Definition at line 21 of file ai_industrytype.cpp.

References IndustrySpec::enabled, GetIndustrySpec(), and NUM_INDUSTRYTYPES.

Referenced by AIRail::BuildNewGRFRailStation(), CanBuildIndustry(), CanProspectIndustry(), GetAcceptedCargo(), GetConstructionCost(), GetName(), GetProducedCargo(), HasDock(), HasHeliport(), IsBuiltOnWater(), IsRawIndustry(), and ProductionCanIncrease().

bool AIIndustryType::ProductionCanIncrease | ( | IndustryType | industry_type | ) | `[static]`

Can the production of this industry increase?

Parameters:

  | industry_type | The type of the industry.

Precondition:
  IsValidIndustryType(industry_type).

Returns:
  True if the production of this industry can increase.

Definition at line 35 of file ai_industrytype.cpp.

References _settings_game, GameSettings::game_creation, GetIndustrySpec(), INDUSTRYBEH_DONT_INCR_PROD, IsValidIndustryType(), and GameCreationSettings::landscape.

bool AIIndustryType::ProspectIndustry | ( | IndustryType | industry_type | ) | `[static]`

Prospect an industry of this type.

Prospecting an industries let the game try to create an industry on a random place on the map.

Parameters:

  | industry_type | The type of the industry.

Precondition:
  CanProspectIndustry(industry_type).

Returns:
  True if no error occurred while trying to prospect.

Note:
  Even if true is returned there is no guarantee a new industry is build.
  If true is returned the money is paid, whether a new industry was build or not.

Definition at line 121 of file ai_industrytype.cpp.

References CanProspectIndustry(), CMD_BUILD_INDUSTRY, AIObject::DoCommand(), and EnforcePrecondition.

The documentation for this class was generated from the following files:

- src/ai/api/ai_industrytype.hpp
- src/ai/api/ai_industrytype.cpp