1
/* $Id: ai_event_types.hpp 15520 2009-02-19 09:01:34Z yexo $ */
3
/** @file ai_event_types.hpp The detailed types of all events. */
5
#ifndef AI_EVENT_TYPES_HPP
6
#define AI_EVENT_TYPES_HPP
8
#include "ai_object.hpp"
9
#include "ai_event.hpp"
10
#include "ai_town.hpp"
11
#include "ai_industry.hpp"
12
#include "ai_engine.hpp"
13
#include "ai_subsidy.hpp"
16
* Event Vehicle Crash, indicating a vehicle of yours is crashed.
17
* It contains the crash site, the crashed vehicle and the reason for the crash.
19
class AIEventVehicleCrashed : public AIEvent {
21
static const char *GetClassName() { return "AIEventVehicleCrashed"; }
24
* The reasons for vehicle crashes
27
CRASH_TRAIN, //!< Two trains collided
28
CRASH_RV_LEVEL_CROSSING, //!< Road vehicle got under a train
29
CRASH_RV_UFO, //!< Road vehicle got under a landing ufo
30
CRASH_PLANE_LANDING, //!< Plane crashed on landing
31
CRASH_AIRCRAFT_NO_AIRPORT, //!< Aircraft crashed after it found not a single airport for landing
32
CRASH_FLOODED, //!< Vehicle was flooded
36
* @param vehicle The vehicle that crashed.
37
* @param crash_site Where the vehicle crashed.
39
AIEventVehicleCrashed(VehicleID vehicle, TileIndex crash_site, CrashReason crash_reason) :
40
AIEvent(AI_ET_VEHICLE_CRASHED),
41
crash_site(crash_site),
43
crash_reason(crash_reason)
47
* Convert an AIEvent to the real instance.
48
* @param instance The instance to convert.
49
* @return The converted instance.
51
static AIEventVehicleCrashed *Convert(AIEvent *instance) { return (AIEventVehicleCrashed *)instance; }
54
* Get the VehicleID of the crashed vehicle.
55
* @return The crashed vehicle.
57
VehicleID GetVehicleID() { return vehicle; }
60
* Find the tile the vehicle crashed.
61
* @return The crash site.
63
TileIndex GetCrashSite() { return crash_site; }
66
* Get the reason for crashing
67
* @return The reason for crashing
69
CrashReason GetCrashReason() { return crash_reason; }
74
CrashReason crash_reason;
78
* Event Subsidy Offered, indicating someone offered a subsidy.
80
class AIEventSubsidyOffer : public AIEvent {
82
static const char *GetClassName() { return "AIEventSubsidyOffer"; }
85
* @param subsidy_id The index of this subsidy in the _subsidies array.
87
AIEventSubsidyOffer(SubsidyID subsidy_id) :
88
AIEvent(AI_ET_SUBSIDY_OFFER),
89
subsidy_id(subsidy_id)
93
* Convert an AIEvent to the real instance.
94
* @param instance The instance to convert.
95
* @return The converted instance.
97
static AIEventSubsidyOffer *Convert(AIEvent *instance) { return (AIEventSubsidyOffer *)instance; }
100
* Get the SubsidyID of the subsidy.
101
* @return The subsidy id.
103
SubsidyID GetSubsidyID() { return subsidy_id; }
106
SubsidyID subsidy_id;
110
* Event Subsidy Offer Expired, indicating a subsidy will no longer be awarded.
112
class AIEventSubsidyOfferExpired : public AIEvent {
114
static const char *GetClassName() { return "AIEventSubsidyOfferExpired"; }
117
* @param subsidy_id The index of this subsidy in the _subsidies array.
119
AIEventSubsidyOfferExpired(SubsidyID subsidy_id) :
120
AIEvent(AI_ET_SUBSIDY_OFFER_EXPIRED),
121
subsidy_id(subsidy_id)
125
* Convert an AIEvent to the real instance.
126
* @param instance The instance to convert.
127
* @return The converted instance.
129
static AIEventSubsidyOfferExpired *Convert(AIEvent *instance) { return (AIEventSubsidyOfferExpired *)instance; }
132
* Get the SubsidyID of the subsidy.
133
* @return The subsidy id.
135
SubsidyID GetSubsidyID() { return subsidy_id; }
138
SubsidyID subsidy_id;
142
* Event Subidy Awarded, indicating a subsidy is awarded to some company.
144
class AIEventSubsidyAwarded : public AIEvent {
146
static const char *GetClassName() { return "AIEventSubsidyAwarded"; }
149
* @param subsidy_id The index of this subsidy in the _subsidies array.
151
AIEventSubsidyAwarded(SubsidyID subsidy_id) :
152
AIEvent(AI_ET_SUBSIDY_AWARDED),
153
subsidy_id(subsidy_id)
157
* Convert an AIEvent to the real instance.
158
* @param instance The instance to convert.
159
* @return The converted instance.
161
static AIEventSubsidyAwarded *Convert(AIEvent *instance) { return (AIEventSubsidyAwarded *)instance; }
164
* Get the SubsidyID of the subsidy.
165
* @return The subsidy id.
167
SubsidyID GetSubsidyID() { return subsidy_id; }
170
SubsidyID subsidy_id;
174
* Event Subsidy Expired, indicating a route that was once subsidized no longer is.
176
class AIEventSubsidyExpired : public AIEvent {
178
static const char *GetClassName() { return "AIEventSubsidyExpired"; }
181
* @param subsidy_id The index of this subsidy in the _subsidies array.
183
AIEventSubsidyExpired(SubsidyID subsidy_id) :
184
AIEvent(AI_ET_SUBSIDY_EXPIRED),
185
subsidy_id(subsidy_id)
189
* Convert an AIEvent to the real instance.
190
* @param instance The instance to convert.
191
* @return The converted instance.
193
static AIEventSubsidyExpired *Convert(AIEvent *instance) { return (AIEventSubsidyExpired *)instance; }
196
* Get the SubsidyID of the subsidy.
197
* @return The subsidy id.
199
SubsidyID GetSubsidyID() { return subsidy_id; }
202
SubsidyID subsidy_id;
206
* Event Engine Preview, indicating a manufacturer offer you to test a new engine.
207
* You can get the same information about the offered engine as a real user
208
* would see in the offer window. And you can also accept the offer.
210
class AIEventEnginePreview : public AIEvent {
212
static const char *GetClassName() { return "AIEventEnginePreview"; }
215
* @param engine The engine offered to test.
217
AIEventEnginePreview(EngineID engine) :
218
AIEvent(AI_ET_ENGINE_PREVIEW),
223
* Convert an AIEvent to the real instance.
224
* @param instance The instance to convert.
225
* @return The converted instance.
227
static AIEventEnginePreview *Convert(AIEvent *instance) { return (AIEventEnginePreview *)instance; }
230
* Get the name of the offered engine.
231
* @return The name the engine has.
236
* Get the cargo-type of the offered engine. In case it can transport 2 cargos, it
238
* @return The cargo-type of the engine.
240
CargoID GetCargoType();
243
* Get the capacity of the offered engine. In case it can transport 2 cargos, it
245
* @return The capacity of the engine.
250
* Get the maximum speed of the offered engine.
251
* @return The maximum speed the engine has.
252
* @note The speed is in OpenTTD's internal speed unit.
253
* This is mph / 1.6, which is roughly km/h.
254
* To get km/h multiply this number by 1.00584.
259
* Get the new cost of the offered engine.
260
* @return The new cost the engine has.
265
* Get the running cost of the offered engine.
266
* @return The running cost of the vehicle per year.
267
* @note Cost is per year; divide by 365 to get per day.
269
Money GetRunningCost();
272
* Get the type of the offered engine.
273
* @return The type the engine has.
275
AIVehicle::VehicleType GetVehicleType();
278
* Accept the engine preview.
279
* @return True when the accepting succeeded.
281
bool AcceptPreview();
288
* Event Company New, indicating a new company has been created.
290
class AIEventCompanyNew : public AIEvent {
292
static const char *GetClassName() { return "AIEventCompanyNew"; }
295
* @param owner The new company.
297
AIEventCompanyNew(Owner owner) :
298
AIEvent(AI_ET_COMPANY_NEW),
299
owner((AICompany::CompanyID)(byte)owner)
303
* Convert an AIEvent to the real instance.
304
* @param instance The instance to convert.
305
* @return The converted instance.
307
static AIEventCompanyNew *Convert(AIEvent *instance) { return (AIEventCompanyNew *)instance; }
310
* Get the CompanyID of the company that has been created.
311
* @return The CompanyID of the company.
313
AICompany::CompanyID GetCompanyID() { return owner; }
316
AICompany::CompanyID owner;
320
* Event Company In Trouble, indicating a company is in trouble and might go
323
class AIEventCompanyInTrouble : public AIEvent {
325
static const char *GetClassName() { return "AIEventCompanyInTrouble"; }
328
* @param owner The company that is in trouble.
330
AIEventCompanyInTrouble(Owner owner) :
331
AIEvent(AI_ET_COMPANY_IN_TROUBLE),
332
owner((AICompany::CompanyID)(byte)owner)
336
* Convert an AIEvent to the real instance.
337
* @param instance The instance to convert.
338
* @return The converted instance.
340
static AIEventCompanyInTrouble *Convert(AIEvent *instance) { return (AIEventCompanyInTrouble *)instance; }
343
* Get the CompanyID of the company that is in trouble.
344
* @return The CompanyID of the company in trouble.
346
AICompany::CompanyID GetCompanyID() { return owner; }
349
AICompany::CompanyID owner;
353
* Event Company Merger, indicating a company has been bought by another
356
class AIEventCompanyMerger : public AIEvent {
358
static const char *GetClassName() { return "AIEventCompanyMerger"; }
361
* @param old_owner The company bought off.
362
* @param new_owner The company that bougth owner.
364
AIEventCompanyMerger(Owner old_owner, Owner new_owner) :
365
AIEvent(AI_ET_COMPANY_MERGER),
366
old_owner((AICompany::CompanyID)(byte)old_owner),
367
new_owner((AICompany::CompanyID)(byte)new_owner)
371
* Convert an AIEvent to the real instance.
372
* @param instance The instance to convert.
373
* @return The converted instance.
375
static AIEventCompanyMerger *Convert(AIEvent *instance) { return (AIEventCompanyMerger *)instance; }
378
* Get the CompanyID of the company that has been bought.
379
* @return The CompanyID of the company that has been bought.
380
* @note: The value below is not valid anymore as CompanyID, and
381
* AICompany::ResolveCompanyID will return COMPANY_COMPANY. It's
382
* only usefull if you're keeping track of company's yourself.
384
AICompany::CompanyID GetOldCompanyID() { return old_owner; }
387
* Get the CompanyID of the new owner.
388
* @return The CompanyID of the new owner.
390
AICompany::CompanyID GetNewCompanyID() { return new_owner; }
393
AICompany::CompanyID old_owner;
394
AICompany::CompanyID new_owner;
398
* Event Company Bankrupt, indicating a company has gone bankrupt.
400
class AIEventCompanyBankrupt : public AIEvent {
402
static const char *GetClassName() { return "AIEventCompanyBankrupt"; }
405
* @param owner The company that has gone bankrupt.
407
AIEventCompanyBankrupt(Owner owner) :
408
AIEvent(AI_ET_COMPANY_BANKRUPT),
409
owner((AICompany::CompanyID)(byte)owner)
413
* Convert an AIEvent to the real instance.
414
* @param instance The instance to convert.
415
* @return The converted instance.
417
static AIEventCompanyBankrupt *Convert(AIEvent *instance) { return (AIEventCompanyBankrupt *)instance; }
420
* Get the CompanyID of the company that has gone bankrupt.
421
* @return The CompanyID of the company that has gone bankrupt.
423
AICompany::CompanyID GetCompanyID() { return owner; }
426
AICompany::CompanyID owner;
430
* Event Vehicle Lost, indicating a vehicle can't find its way to its destination.
432
class AIEventVehicleLost : public AIEvent {
434
static const char *GetClassName() { return "AIEventVehicleLost"; }
437
* @param vehicle_id The vehicle that is lost.
439
AIEventVehicleLost(VehicleID vehicle_id) :
440
AIEvent(AI_ET_VEHICLE_LOST),
441
vehicle_id(vehicle_id)
445
* Convert an AIEvent to the real instance.
446
* @param instance The instance to convert.
447
* @return The converted instance.
449
static AIEventVehicleLost *Convert(AIEvent *instance) { return (AIEventVehicleLost *)instance; }
452
* Get the VehicleID of the vehicle that is lost.
453
* @return The VehicleID of the vehicle that is lost.
455
VehicleID GetVehicleID() { return vehicle_id; }
458
VehicleID vehicle_id;
462
* Event VehicleWaitingInDepot, indicating a vehicle has arrived a depot and is now waiting there.
464
class AIEventVehicleWaitingInDepot : public AIEvent {
466
static const char *GetClassName() { return "AIEventVehicleWaitingInDepot"; }
469
* @param vehicle_id The vehicle that is waiting in a depot.
471
AIEventVehicleWaitingInDepot(VehicleID vehicle_id) :
472
AIEvent(AI_ET_VEHICLE_WAITING_IN_DEPOT),
473
vehicle_id(vehicle_id)
477
* Convert an AIEvent to the real instance.
478
* @param instance The instance to convert.
479
* @return The converted instance.
481
static AIEventVehicleWaitingInDepot *Convert(AIEvent *instance) { return (AIEventVehicleWaitingInDepot *)instance; }
484
* Get the VehicleID of the vehicle that is waiting in a depot.
485
* @return The VehicleID of the vehicle that is waiting in a depot.
487
VehicleID GetVehicleID() { return vehicle_id; }
490
VehicleID vehicle_id;
494
* Event Vehicle Unprofitable, indicating a vehicle lost money last year.
496
class AIEventVehicleUnprofitable : public AIEvent {
498
static const char *GetClassName() { return "AIEventVehicleUnprofitable"; }
501
* @param vehicle_id The vehicle that was unprofitable.
503
AIEventVehicleUnprofitable(VehicleID vehicle_id) :
504
AIEvent(AI_ET_VEHICLE_UNPROFITABLE),
505
vehicle_id(vehicle_id)
509
* Convert an AIEvent to the real instance.
510
* @param instance The instance to convert.
511
* @return The converted instance.
513
static AIEventVehicleUnprofitable *Convert(AIEvent *instance) { return (AIEventVehicleUnprofitable *)instance; }
516
* Get the VehicleID of the vehicle that lost money.
517
* @return The VehicleID of the vehicle that lost money.
519
VehicleID GetVehicleID() { return vehicle_id; }
522
VehicleID vehicle_id;
526
* Event Industry Open, indicating a new industry has been created.
528
class AIEventIndustryOpen : public AIEvent {
530
static const char *GetClassName() { return "AIEventIndustryOpen"; }
533
* @param industry_id The new industry.
535
AIEventIndustryOpen(IndustryID industry_id) :
536
AIEvent(AI_ET_INDUSTRY_OPEN),
537
industry_id(industry_id)
541
* Convert an AIEvent to the real instance.
542
* @param instance The instance to convert.
543
* @return The converted instance.
545
static AIEventIndustryOpen *Convert(AIEvent *instance) { return (AIEventIndustryOpen *)instance; }
548
* Get the IndustryID of the new industry.
549
* @return The IndustryID of the industry.
551
IndustryID GetIndustryID() { return industry_id; }
554
IndustryID industry_id;
558
* Event Industry Close, indicating an industry is going to be closed.
560
class AIEventIndustryClose : public AIEvent {
562
static const char *GetClassName() { return "AIEventIndustryClose"; }
565
* @param industry_id The new industry.
567
AIEventIndustryClose(IndustryID industry_id) :
568
AIEvent(AI_ET_INDUSTRY_CLOSE),
569
industry_id(industry_id)
573
* Convert an AIEvent to the real instance.
574
* @param instance The instance to convert.
575
* @return The converted instance.
577
static AIEventIndustryClose *Convert(AIEvent *instance) { return (AIEventIndustryClose *)instance; }
580
* Get the IndustryID of the closing industry.
581
* @return The IndustryID of the industry.
583
IndustryID GetIndustryID() { return industry_id; }
586
IndustryID industry_id;
590
* Event Engine Available, indicating a new engine is available.
592
class AIEventEngineAvailable : public AIEvent {
594
static const char *GetClassName() { return "AIEventEngineAvailable"; }
597
* @param engine The engine that is available.
599
AIEventEngineAvailable(EngineID engine) :
600
AIEvent(AI_ET_ENGINE_AVAILABLE),
605
* Convert an AIEvent to the real instance.
606
* @param instance The instance to convert.
607
* @return The converted instance.
609
static AIEventEngineAvailable *Convert(AIEvent *instance) { return (AIEventEngineAvailable *)instance; }
612
* Get the EngineID of the new engine.
613
* @return The EngineID of the new engine.
615
EngineID GetEngineID() { return engine; }
622
* Event Station First Vehicle, indicating a station has been visited by a vehicle for the first time.
624
class AIEventStationFirstVehicle : public AIEvent {
626
static const char *GetClassName() { return "AIEventStationFirstVehicle"; }
629
* @param station The station visited for the first time.
630
* @param vehicle The vehicle visiting the station.
632
AIEventStationFirstVehicle(StationID station, VehicleID vehicle) :
633
AIEvent(AI_ET_STATION_FIRST_VEHICLE),
639
* Convert an AIEvent to the real instance.
640
* @param instance The instance to convert.
641
* @return The converted instance.
643
static AIEventStationFirstVehicle *Convert(AIEvent *instance) { return (AIEventStationFirstVehicle *)instance; }
646
* Get the StationID of the visited station.
647
* @return The StationID of the visited station.
649
StationID GetStationID() { return station; }
652
* Get the VehicleID of the first vehicle.
653
* @return The VehicleID of the first vehicle.
655
VehicleID GetVehicleID() { return vehicle; }
663
* Event Disaster Zeppeliner Crashed, indicating a zeppeliner has crashed on an airport and is blocking the runway.
665
class AIEventDisasterZeppelinerCrashed : public AIEvent {
667
static const char *GetClassName() { return "AIEventDisasterZeppelinerCrashed"; }
670
* @param station The station containing the affected airport
672
AIEventDisasterZeppelinerCrashed(StationID station) :
673
AIEvent(AI_ET_DISASTER_ZEPPELINER_CRASHED),
678
* Convert an AIEvent to the real instance.
679
* @param instance The instance to convert.
680
* @return The converted instance.
682
static AIEventDisasterZeppelinerCrashed *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCrashed *)instance; }
685
* Get the StationID of the station containing the affected airport.
686
* @return The StationID of the station containing the affected airport.
688
StationID GetStationID() { return station; }
695
* Event Disaster Zeppeliner Cleared, indicating a previously crashed zeppeliner has been removed, and the airport is operating again.
697
class AIEventDisasterZeppelinerCleared : public AIEvent {
699
static const char *GetClassName() { return "AIEventDisasterZeppelinerCleared"; }
702
* @param station The station containing the affected airport
704
AIEventDisasterZeppelinerCleared(StationID station) :
705
AIEvent(AI_ET_DISASTER_ZEPPELINER_CLEARED),
710
* Convert an AIEvent to the real instance.
711
* @param instance The instance to convert.
712
* @return The converted instance.
714
static AIEventDisasterZeppelinerCleared *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCleared *)instance; }
717
* Get the StationID of the station containing the affected airport.
718
* @return The StationID of the station containing the affected airport.
720
StationID GetStationID() { return station; }
726
#endif /* AI_EVENT_TYPES_HPP */