# AIEventEnginePreview Class Reference

Event Engine Preview, indicating a manufacturer offer you to test a new engine. More...

`#include <ai_event_types.hpp>`

Inheritance diagram for AIEventEnginePreview:

## Public Member Functions
| AIEventEnginePreview (EngineID engine)
char * | GetName ()
| Get the name of the offered engine.
CargoID | GetCargoType ()
| Get the cargo-type of the offered engine.
int32 | GetCapacity ()
| Get the capacity of the offered engine.
int32 | GetMaxSpeed ()
| Get the maximum speed of the offered engine.
Money | GetPrice ()
| Get the new cost of the offered engine.
Money | GetRunningCost ()
| Get the running cost of the offered engine.
int32 | GetVehicleType ()
bool | AcceptPreview ()
| Accept the engine preview.
## Static Public Member Functions
static const char * | GetClassName ()
static AIEventEnginePreview * | Convert (AIEvent *instance)
| Convert an AIEvent to the real instance.
## Private Attributes
EngineID | engine

## Detailed Description

Event Engine Preview, indicating a manufacturer offer you to test a new engine.

You can get the same information about the offered engine as a real user would see in the offer window. And you can also accept the offer.

Definition at line 215 of file ai_event_types.hpp.

## Constructor & Destructor Documentation

AIEventEnginePreview::AIEventEnginePreview | ( | EngineID | engine | ) | `[inline]`

Parameters:

  | engine | The engine offered to test.

Definition at line 222 of file ai_event_types.hpp.

## Member Function Documentation

bool AIEventEnginePreview::AcceptPreview | ( |  | ) |

Accept the engine preview.

Returns:
  True when the accepting succeeded.

Definition at line 99 of file ai_event_types.cpp.

References CMD_WANT_ENGINE_PREVIEW, and AIObject::DoCommand().

static AIEventEnginePreview* AIEventEnginePreview::Convert | ( | AIEvent * | instance | ) | `[inline, static]`

Convert an AIEvent to the real instance.

Parameters:

  | instance | The instance to convert.

Returns:
  The converted instance.

Definition at line 232 of file ai_event_types.hpp.

int32 AIEventEnginePreview::GetCapacity | ( |  | ) |

Get the capacity of the offered engine.

In case it can transport multiple cargos, it returns the first/main.

Returns:
  The capacity of the engine.

Definition at line 47 of file ai_event_types.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetDisplayDefaultCapacity(), NUM_CARGO, Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

CargoID AIEventEnginePreview::GetCargoType | ( |  | ) |

Get the cargo-type of the offered engine.

In case it can transport multiple cargos, it returns the first/main.

Returns:
  The cargo-type of the engine.

Definition at line 31 of file ai_event_types.cpp.

References CT_INVALID, and NUM_CARGO.

int32 AIEventEnginePreview::GetMaxSpeed | ( |  | ) |

Get the maximum speed of the offered engine.

Returns:
  The maximum speed the engine has.

Note:
  The speed is in OpenTTD's internal speed unit. This is mph / 1.6, which is roughly km/h. To get km/h multiply this number by 1.00584.

Definition at line 70 of file ai_event_types.cpp.

References _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetDisplayMaxSpeed(), VehicleSettings::plane_speed, Engine::type, VEH_AIRCRAFT, and GameSettings::vehicle.

char * AIEventEnginePreview::GetName | ( |  | ) |

Get the name of the offered engine.

Returns:
  The name the engine has.

Definition at line 21 of file ai_event_types.cpp.

References SetDParam().

Money AIEventEnginePreview::GetPrice | ( |  | ) |

Get the new cost of the offered engine.

Returns:
  The new cost the engine has.

Definition at line 78 of file ai_event_types.cpp.

Money AIEventEnginePreview::GetRunningCost | ( |  | ) |

Get the running cost of the offered engine.

Returns:
  The running cost of the vehicle per year.

Note:
  Cost is per year; divide by 365 to get per day.

Definition at line 83 of file ai_event_types.cpp.

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

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