diff options
author | glx <glx@openttd.org> | 2019-09-01 18:27:18 +0200 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-10-22 11:55:40 +0200 |
commit | 12e43c697d2ea4a0a9736ab2517a1921e6e690b8 (patch) | |
tree | 12cb2c77a7db7d0aa198ec7a522fafab9b30a2be /src/script/api/script_event_types.hpp | |
parent | cbefc1d99491def454fe25d1700c6d41925c81d6 (diff) | |
download | openttd-12e43c697d2ea4a0a9736ab2517a1921e6e690b8.tar.xz |
Add: [Script] ScriptEventVehicleAutoReplaced.
Diffstat (limited to 'src/script/api/script_event_types.hpp')
-rw-r--r-- | src/script/api/script_event_types.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index f9b2fb87f..aeb5ebe2d 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -1060,4 +1060,44 @@ public: static ScriptEventRoadReconstruction *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventRoadReconstruction *)instance; } }; +/** + * Event VehicleAutoReplaced, indicating a vehicle has been auto replaced. + * @api ai + */ +class ScriptEventVehicleAutoReplaced : public ScriptEvent { +public: + /** + * @param old_id The vehicle that has been replaced. + * @param new_id The vehicle that has been created in replacement. + */ + ScriptEventVehicleAutoReplaced(VehicleID old_id, VehicleID new_id) : + ScriptEvent(ET_VEHICLE_AUTOREPLACED), + old_id(old_id), + new_id(new_id) + {} + + /** + * Convert an ScriptEvent to the real instance. + * @param instance The instance to convert. + * @return The converted instance. + */ + static ScriptEventVehicleAutoReplaced *Convert(ScriptEvent *instance) { return (ScriptEventVehicleAutoReplaced *)instance; } + + /** + * Get the VehicleID of the vehicle that has been replaced. + * @return The VehicleID of the vehicle that has been replaced. This ID is no longer valid for referencing the vehicle. + */ + VehicleID GetOldVehicleID() { return this->old_id; } + + /** + * Get the VehicleID of the vehicle that has been created in replacement. + * @return The VehicleID of the vehicle that has been created in replacement. + */ + VehicleID GetNewVehicleID() { return this->new_id; } + +private: + VehicleID old_id; ///< The vehicle that has been replaced. + VehicleID new_id; ///< The vehicle that has been created in replacement. +}; + #endif /* SCRIPT_EVENT_TYPES_HPP */ |