OpenTTD AI API 20241015-master-gd5b57a56f4
|
Class that handles all group related functions. More...
#include <script_group.hpp>
Public Types | |
enum | GroupID { GROUP_ALL , GROUP_DEFAULT , GROUP_INVALID } |
The group IDs of some special groups. More... | |
Static Public Member Functions | |
static bool | IsValidGroup (GroupID group_id) |
Checks whether the given group is valid. | |
static GroupID | CreateGroup (AIVehicle::VehicleType vehicle_type, GroupID parent_group_id) |
Create a new group. | |
static bool | DeleteGroup (GroupID group_id) |
Delete the given group. | |
static AIVehicle::VehicleType | GetVehicleType (GroupID group_id) |
Get the vehicle type of a group. | |
static bool | SetName (GroupID group_id, Text *name) |
Set the name of a group. | |
static string | GetName (GroupID group_id) |
Get the name of a group. | |
static bool | SetParent (GroupID group_id, GroupID parent_group_id) |
Set parent group of a group. | |
static GroupID | GetParent (GroupID group_id) |
Get parent group of a group. | |
static bool | EnableAutoReplaceProtection (GroupID group_id, bool enable) |
Enable or disable autoreplace protected. | |
static bool | GetAutoReplaceProtection (GroupID group_id) |
Get the autoreplace protection status. | |
static int | GetNumEngines (GroupID group_id, EngineID engine_id) |
Get the number of engines in a given group. | |
static int | GetNumVehicles (GroupID group_id, AIVehicle::VehicleType vehicle_type) |
Get the total number of vehicles in a given group and its sub-groups. | |
static bool | MoveVehicle (GroupID group_id, VehicleID vehicle_id) |
Move a vehicle to a group. | |
static bool | EnableWagonRemoval (bool keep_length) |
Enable or disable the removal of wagons when a (part of a) vehicle is (auto)replaced with a longer variant (longer wagons or longer engines) If enabled, wagons are removed from the end of the vehicle until it fits in the same number of tiles as it did before. | |
static bool | HasWagonRemoval () |
Get the current status of wagon removal. | |
static bool | SetAutoReplace (GroupID group_id, EngineID engine_id_old, EngineID engine_id_new) |
Start replacing all vehicles with a specified engine with another engine. | |
static EngineID | GetEngineReplacement (GroupID group_id, EngineID engine_id) |
Get the EngineID the given EngineID is replaced with. | |
static bool | StopAutoReplace (GroupID group_id, EngineID engine_id) |
Stop replacing a certain engine in the specified group. | |
static Money | GetProfitThisYear (GroupID group_id) |
Get the current profit of a group. | |
static Money | GetProfitLastYear (GroupID group_id) |
Get the profit of last year of a group. | |
static int | GetCurrentUsage (GroupID group_id) |
Get the current vehicle usage of a group. | |
static bool | SetPrimaryColour (GroupID group_id, AICompany::Colours colour) |
Set primary colour for a group. | |
static bool | SetSecondaryColour (GroupID group_id, AICompany::Colours colour) |
Set secondary colour for a group. | |
static AICompany::Colours | GetPrimaryColour (GroupID group_id) |
Get primary colour of a group. | |
static AICompany::Colours | GetSecondaryColour (GroupID group_id) |
Get secondary colour for a group. | |
Class that handles all group related functions.
enum AIGroup::GroupID |
|
static |
Create a new group.
vehicle_type | The type of vehicle to create a group for. |
parent_group_id | The parent group id to create this group under, INVALID_GROUP for top-level. |
|
static |
Delete the given group.
When the deletion succeeds all vehicles in the given group will move to the GROUP_DEFAULT.
group_id | The group to delete. |
|
static |
Enable or disable autoreplace protected.
If the protection is enabled, global autoreplace won't affect vehicles in this group.
group_id | The group to change the protection for. |
enable | True if protection should be enabled. |
|
static |
Enable or disable the removal of wagons when a (part of a) vehicle is (auto)replaced with a longer variant (longer wagons or longer engines) If enabled, wagons are removed from the end of the vehicle until it fits in the same number of tiles as it did before.
keep_length | If true, wagons will be removed if the new engine is longer. |
|
static |
Get the autoreplace protection status.
group_id | The group to get the protection status for. |
|
static |
Get the current vehicle usage of a group.
group_id | The group to get the current usage of. |
Get the EngineID the given EngineID is replaced with.
group_id | The group to get the replacement from. |
engine_id | The engine that is being replaced. |
|
static |
Get the name of a group.
group_id | The group to get the name of. |
Get the number of engines in a given group.
group_id | The group to get the number of engines in. |
engine_id | The engine id to count. |
|
static |
Get the total number of vehicles in a given group and its sub-groups.
group_id | The group to get the number of vehicles in. |
vehicle_type | The type of vehicle of the group. |
Get parent group of a group.
group_id | The group to get the parent of. |
|
static |
Get primary colour of a group.
group_id | The group id to get the colour of. |
Get the profit of last year of a group.
group_id | The group to get the profit of. |
Get the current profit of a group.
group_id | The group to get the profit of. |
|
static |
Get secondary colour for a group.
group_id | The group id to get the colour of. |
|
static |
Get the vehicle type of a group.
group_id | The group to get the type from. |
|
static |
Get the current status of wagon removal.
|
static |
Checks whether the given group is valid.
group_id | The group to check. |
Move a vehicle to a group.
group_id | The group to move the vehicle to. |
vehicle_id | The vehicle to move to the group. |
|
static |
Start replacing all vehicles with a specified engine with another engine.
group_id | The group to replace vehicles from. Use ALL_GROUP to replace vehicles from all groups that haven't set autoreplace protection. |
engine_id_old | The engine id to start replacing. |
engine_id_new | The engine id to replace with. |
|
static |
Set the name of a group.
group_id | The group to set the name for. |
name | The name for the group (can be either a raw string, or a AIText object). |
AIError::ERR_NAME_IS_NOT_UNIQUE |
Set parent group of a group.
group_id | The group to set the parent for. |
parent_group_id | The parent group to set. |
|
static |
Set primary colour for a group.
group_id | The group id to set the colour of. |
colour | Colour to set. |
|
static |
Set secondary colour for a group.
group_id | The group id to set the colour of. |
colour | Colour to set. |
Stop replacing a certain engine in the specified group.
group_id | The group to stop replacing the engine in. |
engine_id | The engine id to stop replacing with another engine. |