# AIIndustryType Class Reference

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

`#include <ai_industrytype.hpp>`

Inheritance diagram for AIIndustryType:

## Static Public Member Functions
static const char * | GetClassName ()
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 22 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 succesfully build.

Definition at line 106 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 88 of file ai_industrytype.cpp.

References _settings_game, GameSettings::construction, GetIndustrySpec(), 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 97 of file ai_industrytype.cpp.

References _settings_game, GameSettings::construction, GetIndustrySpec(), 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 74 of file ai_industrytype.cpp.

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

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 41 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 49 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 60 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 137 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 130 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 123 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 26 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 19 of file ai_industrytype.cpp.

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

Referenced by 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 33 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 occured 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 115 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