# ai_event_types.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_event_types.hpp 15520 2009-02-19 09:01:34Z yexo $ */
    00002
    00005 #ifndef AI_EVENT_TYPES_HPP
    00006 #define AI_EVENT_TYPES_HPP
    00007
    00008 #include "ai_object.hpp"
    00009 #include "ai_event.hpp"
    00010 #include "ai_town.hpp"
    00011 #include "ai_industry.hpp"
    00012 #include "ai_engine.hpp"
    00013 #include "ai_subsidy.hpp"
    00014
    00019 class AIEventVehicleCrashed : public AIEvent {
    00020 public:
    00021   static const char *GetClassName() { return "AIEventVehicleCrashed"; }
    00022
    00026   enum CrashReason {
    00027     CRASH_TRAIN,
    00028     CRASH_RV_LEVEL_CROSSING,
    00029     CRASH_RV_UFO,
    00030     CRASH_PLANE_LANDING,
    00031     CRASH_AIRCRAFT_NO_AIRPORT,
    00032     CRASH_FLOODED,
    00033   };
    00034
    00039   AIEventVehicleCrashed(VehicleID vehicle, TileIndex crash_site, CrashReason crash_reason) :
    00040     AIEvent(AI_ET_VEHICLE_CRASHED),
    00041     crash_site(crash_site),
    00042     vehicle(vehicle),
    00043     crash_reason(crash_reason)
    00044   {}
    00045
    00051   static AIEventVehicleCrashed *Convert(AIEvent *instance) { return (AIEventVehicleCrashed *)instance; }
    00052
    00057   VehicleID GetVehicleID() { return vehicle; }
    00058
    00063   TileIndex GetCrashSite() { return crash_site; }
    00064
    00069   CrashReason GetCrashReason() { return crash_reason; }
    00070
    00071 private:
    00072   TileIndex crash_site;
    00073   VehicleID vehicle;
    00074   CrashReason crash_reason;
    00075 };
    00076
    00080 class AIEventSubsidyOffer : public AIEvent {
    00081 public:
    00082   static const char *GetClassName() { return "AIEventSubsidyOffer"; }
    00083
    00087   AIEventSubsidyOffer(SubsidyID subsidy_id) :
    00088     AIEvent(AI_ET_SUBSIDY_OFFER),
    00089     subsidy_id(subsidy_id)
    00090   {}
    00091
    00097   static AIEventSubsidyOffer *Convert(AIEvent *instance) { return (AIEventSubsidyOffer *)instance; }
    00098
    00103   SubsidyID GetSubsidyID() { return subsidy_id; }
    00104
    00105 private:
    00106   SubsidyID subsidy_id;
    00107 };
    00108
    00112 class AIEventSubsidyOfferExpired : public AIEvent {
    00113 public:
    00114   static const char *GetClassName() { return "AIEventSubsidyOfferExpired"; }
    00115
    00119   AIEventSubsidyOfferExpired(SubsidyID subsidy_id) :
    00120     AIEvent(AI_ET_SUBSIDY_OFFER_EXPIRED),
    00121     subsidy_id(subsidy_id)
    00122   {}
    00123
    00129   static AIEventSubsidyOfferExpired *Convert(AIEvent *instance) { return (AIEventSubsidyOfferExpired *)instance; }
    00130
    00135   SubsidyID GetSubsidyID() { return subsidy_id; }
    00136
    00137 private:
    00138   SubsidyID subsidy_id;
    00139 };
    00140
    00144 class AIEventSubsidyAwarded : public AIEvent {
    00145 public:
    00146   static const char *GetClassName() { return "AIEventSubsidyAwarded"; }
    00147
    00151   AIEventSubsidyAwarded(SubsidyID subsidy_id) :
    00152     AIEvent(AI_ET_SUBSIDY_AWARDED),
    00153     subsidy_id(subsidy_id)
    00154   {}
    00155
    00161   static AIEventSubsidyAwarded *Convert(AIEvent *instance) { return (AIEventSubsidyAwarded *)instance; }
    00162
    00167   SubsidyID GetSubsidyID() { return subsidy_id; }
    00168
    00169 private:
    00170   SubsidyID subsidy_id;
    00171 };
    00172
    00176 class AIEventSubsidyExpired : public AIEvent {
    00177 public:
    00178   static const char *GetClassName() { return "AIEventSubsidyExpired"; }
    00179
    00183   AIEventSubsidyExpired(SubsidyID subsidy_id) :
    00184     AIEvent(AI_ET_SUBSIDY_EXPIRED),
    00185     subsidy_id(subsidy_id)
    00186   {}
    00187
    00193   static AIEventSubsidyExpired *Convert(AIEvent *instance) { return (AIEventSubsidyExpired *)instance; }
    00194
    00199    SubsidyID GetSubsidyID() { return subsidy_id; }
    00200
    00201 private:
    00202   SubsidyID subsidy_id;
    00203 };
    00204
    00210 class AIEventEnginePreview : public AIEvent {
    00211 public:
    00212   static const char *GetClassName() { return "AIEventEnginePreview"; }
    00213
    00217   AIEventEnginePreview(EngineID engine) :
    00218     AIEvent(AI_ET_ENGINE_PREVIEW),
    00219     engine(engine)
    00220   {}
    00221
    00227   static AIEventEnginePreview *Convert(AIEvent *instance) { return (AIEventEnginePreview *)instance; }
    00228
    00233   char *GetName();
    00234
    00240   CargoID GetCargoType();
    00241
    00247   int32 GetCapacity();
    00248
    00256   int32 GetMaxSpeed();
    00257
    00262   Money GetPrice();
    00263
    00269   Money GetRunningCost();
    00270
    00275   AIVehicle::VehicleType GetVehicleType();
    00276
    00281   bool AcceptPreview();
    00282
    00283 private:
    00284   EngineID engine;
    00285 };
    00286
    00290 class AIEventCompanyNew : public AIEvent {
    00291 public:
    00292   static const char *GetClassName() { return "AIEventCompanyNew"; }
    00293
    00297   AIEventCompanyNew(Owner owner) :
    00298     AIEvent(AI_ET_COMPANY_NEW),
    00299     owner((AICompany::CompanyID)(byte)owner)
    00300   {}
    00301
    00307   static AIEventCompanyNew *Convert(AIEvent *instance) { return (AIEventCompanyNew *)instance; }
    00308
    00313   AICompany::CompanyID GetCompanyID() { return owner; }
    00314
    00315 private:
    00316   AICompany::CompanyID owner;
    00317 };
    00318
    00323 class AIEventCompanyInTrouble : public AIEvent {
    00324 public:
    00325   static const char *GetClassName() { return "AIEventCompanyInTrouble"; }
    00326
    00330   AIEventCompanyInTrouble(Owner owner) :
    00331     AIEvent(AI_ET_COMPANY_IN_TROUBLE),
    00332     owner((AICompany::CompanyID)(byte)owner)
    00333   {}
    00334
    00340   static AIEventCompanyInTrouble *Convert(AIEvent *instance) { return (AIEventCompanyInTrouble *)instance; }
    00341
    00346   AICompany::CompanyID GetCompanyID() { return owner; }
    00347
    00348 private:
    00349   AICompany::CompanyID owner;
    00350 };
    00351
    00356 class AIEventCompanyMerger : public AIEvent {
    00357 public:
    00358   static const char *GetClassName() { return "AIEventCompanyMerger"; }
    00359
    00364   AIEventCompanyMerger(Owner old_owner, Owner new_owner) :
    00365     AIEvent(AI_ET_COMPANY_MERGER),
    00366     old_owner((AICompany::CompanyID)(byte)old_owner),
    00367     new_owner((AICompany::CompanyID)(byte)new_owner)
    00368   {}
    00369
    00375   static AIEventCompanyMerger *Convert(AIEvent *instance) { return (AIEventCompanyMerger *)instance; }
    00376
    00384   AICompany::CompanyID GetOldCompanyID() { return old_owner; }
    00385
    00390   AICompany::CompanyID GetNewCompanyID() { return new_owner; }
    00391
    00392 private:
    00393   AICompany::CompanyID old_owner;
    00394   AICompany::CompanyID new_owner;
    00395 };
    00396
    00400 class AIEventCompanyBankrupt : public AIEvent {
    00401 public:
    00402   static const char *GetClassName() { return "AIEventCompanyBankrupt"; }
    00403
    00407   AIEventCompanyBankrupt(Owner owner) :
    00408     AIEvent(AI_ET_COMPANY_BANKRUPT),
    00409     owner((AICompany::CompanyID)(byte)owner)
    00410   {}
    00411
    00417   static AIEventCompanyBankrupt *Convert(AIEvent *instance) { return (AIEventCompanyBankrupt *)instance; }
    00418
    00423   AICompany::CompanyID GetCompanyID() { return owner; }
    00424
    00425 private:
    00426   AICompany::CompanyID owner;
    00427 };
    00428
    00432 class AIEventVehicleLost : public AIEvent {
    00433 public:
    00434   static const char *GetClassName() { return "AIEventVehicleLost"; }
    00435
    00439   AIEventVehicleLost(VehicleID vehicle_id) :
    00440     AIEvent(AI_ET_VEHICLE_LOST),
    00441     vehicle_id(vehicle_id)
    00442   {}
    00443
    00449   static AIEventVehicleLost *Convert(AIEvent *instance) { return (AIEventVehicleLost *)instance; }
    00450
    00455   VehicleID GetVehicleID() { return vehicle_id; }
    00456
    00457 private:
    00458   VehicleID vehicle_id;
    00459 };
    00460
    00464 class AIEventVehicleWaitingInDepot : public AIEvent {
    00465 public:
    00466   static const char *GetClassName() { return "AIEventVehicleWaitingInDepot"; }
    00467
    00471   AIEventVehicleWaitingInDepot(VehicleID vehicle_id) :
    00472     AIEvent(AI_ET_VEHICLE_WAITING_IN_DEPOT),
    00473     vehicle_id(vehicle_id)
    00474   {}
    00475
    00481   static AIEventVehicleWaitingInDepot *Convert(AIEvent *instance) { return (AIEventVehicleWaitingInDepot *)instance; }
    00482
    00487   VehicleID GetVehicleID() { return vehicle_id; }
    00488
    00489 private:
    00490   VehicleID vehicle_id;
    00491 };
    00492
    00496 class AIEventVehicleUnprofitable : public AIEvent {
    00497 public:
    00498   static const char *GetClassName() { return "AIEventVehicleUnprofitable"; }
    00499
    00503   AIEventVehicleUnprofitable(VehicleID vehicle_id) :
    00504     AIEvent(AI_ET_VEHICLE_UNPROFITABLE),
    00505     vehicle_id(vehicle_id)
    00506   {}
    00507
    00513   static AIEventVehicleUnprofitable *Convert(AIEvent *instance) { return (AIEventVehicleUnprofitable *)instance; }
    00514
    00519   VehicleID GetVehicleID() { return vehicle_id; }
    00520
    00521 private:
    00522   VehicleID vehicle_id;
    00523 };
    00524
    00528 class AIEventIndustryOpen : public AIEvent {
    00529 public:
    00530   static const char *GetClassName() { return "AIEventIndustryOpen"; }
    00531
    00535   AIEventIndustryOpen(IndustryID industry_id) :
    00536     AIEvent(AI_ET_INDUSTRY_OPEN),
    00537     industry_id(industry_id)
    00538   {}
    00539
    00545   static AIEventIndustryOpen *Convert(AIEvent *instance) { return (AIEventIndustryOpen *)instance; }
    00546
    00551   IndustryID GetIndustryID() { return industry_id; }
    00552
    00553 private:
    00554   IndustryID industry_id;
    00555 };
    00556
    00560 class AIEventIndustryClose : public AIEvent {
    00561 public:
    00562   static const char *GetClassName() { return "AIEventIndustryClose"; }
    00563
    00567   AIEventIndustryClose(IndustryID industry_id) :
    00568     AIEvent(AI_ET_INDUSTRY_CLOSE),
    00569     industry_id(industry_id)
    00570   {}
    00571
    00577   static AIEventIndustryClose *Convert(AIEvent *instance) { return (AIEventIndustryClose *)instance; }
    00578
    00583   IndustryID GetIndustryID() { return industry_id; }
    00584
    00585 private:
    00586   IndustryID industry_id;
    00587 };
    00588
    00592 class AIEventEngineAvailable : public AIEvent {
    00593 public:
    00594   static const char *GetClassName() { return "AIEventEngineAvailable"; }
    00595
    00599   AIEventEngineAvailable(EngineID engine) :
    00600     AIEvent(AI_ET_ENGINE_AVAILABLE),
    00601     engine(engine)
    00602   {}
    00603
    00609   static AIEventEngineAvailable *Convert(AIEvent *instance) { return (AIEventEngineAvailable *)instance; }
    00610
    00615   EngineID GetEngineID() { return engine; }
    00616
    00617 private:
    00618   EngineID engine;
    00619 };
    00620
    00624 class AIEventStationFirstVehicle : public AIEvent {
    00625 public:
    00626   static const char *GetClassName() { return "AIEventStationFirstVehicle"; }
    00627
    00632   AIEventStationFirstVehicle(StationID station, VehicleID vehicle) :
    00633     AIEvent(AI_ET_STATION_FIRST_VEHICLE),
    00634     station(station),
    00635     vehicle(vehicle)
    00636   {}
    00637
    00643   static AIEventStationFirstVehicle *Convert(AIEvent *instance) { return (AIEventStationFirstVehicle *)instance; }
    00644
    00649   StationID GetStationID() { return station; }
    00650
    00655   VehicleID GetVehicleID() { return vehicle; }
    00656
    00657 private:
    00658   StationID station;
    00659   VehicleID vehicle;
    00660 };
    00661
    00665 class AIEventDisasterZeppelinerCrashed : public AIEvent {
    00666 public:
    00667   static const char *GetClassName() { return "AIEventDisasterZeppelinerCrashed"; }
    00668
    00672   AIEventDisasterZeppelinerCrashed(StationID station) :
    00673     AIEvent(AI_ET_DISASTER_ZEPPELINER_CRASHED),
    00674     station(station)
    00675   {}
    00676
    00682   static AIEventDisasterZeppelinerCrashed *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCrashed *)instance; }
    00683
    00688   StationID GetStationID() { return station; }
    00689
    00690 private:
    00691   StationID station;
    00692 };
    00693
    00697 class AIEventDisasterZeppelinerCleared : public AIEvent {
    00698 public:
    00699   static const char *GetClassName() { return "AIEventDisasterZeppelinerCleared"; }
    00700
    00704   AIEventDisasterZeppelinerCleared(StationID station) :
    00705     AIEvent(AI_ET_DISASTER_ZEPPELINER_CLEARED),
    00706     station(station)
    00707   {}
    00708
    00714   static AIEventDisasterZeppelinerCleared *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCleared *)instance; }
    00715
    00720   StationID GetStationID() { return station; }
    00721
    00722 private:
    00723   StationID station;
    00724 };
    00725
    00726 #endif /* AI_EVENT_TYPES_HPP */