mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-19 18:32:35 +01:00
Add: [Script] Event for when a company's president name changes
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
* API additions:
|
||||
* \li AIEventVehicleCrashed::GetVictims
|
||||
* \li AIEventCompanyRenamed
|
||||
* \li AIEventPresidentRenamed
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* API additions:
|
||||
* \li GSEventVehicleCrashed::GetVictims
|
||||
* \li GSEventCompanyRenamed
|
||||
* \li GSEventPresidentRenamed
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
ET_STORYPAGE_TILE_SELECT,
|
||||
ET_STORYPAGE_VEHICLE_SELECT,
|
||||
ET_COMPANY_RENAMED,
|
||||
ET_PRESIDENT_RENAMED,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1373,4 +1373,48 @@ private:
|
||||
VehicleID vehicle_id;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Event President Renamed, indicating a company's president's name has changed.
|
||||
* This event is not sent to the company for who the president's name changed.
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventPresidentRenamed : public ScriptEvent {
|
||||
public:
|
||||
#ifndef DOXYGEN_API
|
||||
/**
|
||||
* @param company The company of the president.
|
||||
* @param new_name The new name of the president.
|
||||
*/
|
||||
ScriptEventPresidentRenamed(CompanyID company, const std::string &new_name) :
|
||||
ScriptEvent(ET_PRESIDENT_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 ScriptEventPresidentRenamed *Convert(ScriptEvent *instance) { return static_cast<ScriptEventPresidentRenamed *>(instance); }
|
||||
|
||||
/**
|
||||
* Get the CompanyID of the company that got its president renamed.
|
||||
* @return The CompanyID of the company.
|
||||
*/
|
||||
ScriptCompany::CompanyID GetCompanyID() { return this->company; }
|
||||
|
||||
/**
|
||||
* Get the new name of the president.
|
||||
* @return The new name of the president.
|
||||
*/
|
||||
std::optional<std::string> GetNewName() { return this->new_name; }
|
||||
|
||||
private:
|
||||
ScriptCompany::CompanyID company; ///< The company of the renamed president.
|
||||
std::string new_name; ///< The new name of the president.
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_EVENT_TYPES_HPP */
|
||||
|
||||
Reference in New Issue
Block a user