# 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.

## Detailed Description

Class that handles all industry-type related functions.

Definition at line 15 of file ai_industrytype.hpp.

## Member Function Documentation

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 12 of file ai_industrytype.cpp.

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

Referenced by CanBuildIndustry(), CanProspectIndustry(), GetAcceptedCargo(), GetConstructionCost(), GetName(), GetProducedCargo(), IsRawIndustry(), and ProductionCanIncrease().

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 41 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 52 of file ai_industrytype.cpp.

References GetIndustrySpec(), IsValidIndustryType(), lengthof, and IndustrySpec::produced_cargo.

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 66 of file ai_industrytype.cpp.

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

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 19 of file ai_industrytype.cpp.

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

Referenced by CanBuildIndustry(), and CanProspectIndustry().

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 26 of file ai_industrytype.cpp.

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

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 34 of file ai_industrytype.cpp.

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

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 80 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 89 of file ai_industrytype.cpp.

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

Referenced by ProspectIndustry().

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 98 of file ai_industrytype.cpp.

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

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 107 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