mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-19 18:32:35 +01:00
Add: [Script] ScriptEventCompanyRename (#12878)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*
|
||||
* API additions:
|
||||
* \li AIEventVehicleCrashed::GetVictims
|
||||
* \li AIEventCompanyRenamed
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*
|
||||
* API additions:
|
||||
* \li GSEventVehicleCrashed::GetVictims
|
||||
* \li GSEventCompanyRenamed
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
ET_STORYPAGE_BUTTON_CLICK,
|
||||
ET_STORYPAGE_TILE_SELECT,
|
||||
ET_STORYPAGE_VEHICLE_SELECT,
|
||||
ET_COMPANY_RENAMED,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -346,6 +346,48 @@ private:
|
||||
ScriptCompany::CompanyID owner; ///< The new company.
|
||||
};
|
||||
|
||||
/**
|
||||
* Event Company Renamed, indicating a company has changed name.
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventCompanyRenamed : public ScriptEvent {
|
||||
public:
|
||||
#ifndef DOXYGEN_API
|
||||
/**
|
||||
* @param owner The company that is renamed.
|
||||
*/
|
||||
ScriptEventCompanyRenamed(CompanyID company, const std::string &new_name) :
|
||||
ScriptEvent(ET_COMPANY_RENAMED),
|
||||
company(static_cast<ScriptCompany::CompanyID>(company)),
|
||||
new_name(new_name)
|
||||
{}
|
||||
#endif /* DOXYGEN_API */
|
||||
|
||||
/**
|
||||
* Convert an ScriptEvent to the real instance.
|
||||
* @param instance The instance to convert.
|
||||
* @return The converted instance.
|
||||
*/
|
||||
static ScriptEventCompanyRenamed *Convert(ScriptEvent *instance) { return static_cast<ScriptEventCompanyRenamed *>(instance); }
|
||||
|
||||
/**
|
||||
* Get the CompanyID of the company that has been renamed.
|
||||
* @return The CompanyID of the company.
|
||||
*/
|
||||
ScriptCompany::CompanyID GetCompanyID() { return this->company; }
|
||||
|
||||
/**
|
||||
* Get the new name of the company.
|
||||
* @return The new name of the company.
|
||||
*/
|
||||
std::optional<std::string> GetNewName() { return this->new_name; }
|
||||
|
||||
private:
|
||||
|
||||
ScriptCompany::CompanyID company; ///< The company that was renamed.
|
||||
std::string new_name; ///< The new name of the company.
|
||||
};
|
||||
|
||||
/**
|
||||
* Event Company In Trouble, indicating a company is in trouble and might go
|
||||
* bankrupt soon.
|
||||
|
||||
Reference in New Issue
Block a user