# ai_event_types.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_event_types.hpp 17898 2009-10-28 20:15:46Z frosch $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef AI_EVENT_TYPES_HPP
    00013 #define AI_EVENT_TYPES_HPP
    00014
    00015 #include "ai_object.hpp"
    00016 #include "ai_event.hpp"
    00017 #include "ai_company.hpp"
    00018
    00023 class AIEventVehicleCrashed : public AIEvent {
    00024 public:
    00025   static const char *GetClassName() { return "AIEventVehicleCrashed"; }
    00026
    00030   enum CrashReason {
    00031     CRASH_TRAIN,
    00032     CRASH_RV_LEVEL_CROSSING,
    00033     CRASH_RV_UFO,
    00034     CRASH_PLANE_LANDING,
    00035     CRASH_AIRCRAFT_NO_AIRPORT,
    00036     CRASH_FLOODED,
    00037   };
    00038
    00044   AIEventVehicleCrashed(VehicleID vehicle, TileIndex crash_site, CrashReason crash_reason) :
    00045     AIEvent(AI_ET_VEHICLE_CRASHED),
    00046     crash_site(crash_site),
    00047     vehicle(vehicle),
    00048     crash_reason(crash_reason)
    00049   {}
    00050
    00056   static AIEventVehicleCrashed *Convert(AIEvent *instance) { return (AIEventVehicleCrashed *)instance; }
    00057
    00062   VehicleID GetVehicleID() { return this->vehicle; }
    00063
    00068   TileIndex GetCrashSite() { return this->crash_site; }
    00069
    00074   CrashReason GetCrashReason() { return this->crash_reason; }
    00075
    00076 private:
    00077   TileIndex crash_site;
    00078   VehicleID vehicle;
    00079   CrashReason crash_reason;
    00080 };
    00081
    00085 class AIEventSubsidyOffer : public AIEvent {
    00086 public:
    00087   static const char *GetClassName() { return "AIEventSubsidyOffer"; }
    00088
    00092   AIEventSubsidyOffer(SubsidyID subsidy_id) :
    00093     AIEvent(AI_ET_SUBSIDY_OFFER),
    00094     subsidy_id(subsidy_id)
    00095   {}
    00096
    00102   static AIEventSubsidyOffer *Convert(AIEvent *instance) { return (AIEventSubsidyOffer *)instance; }
    00103
    00108   SubsidyID GetSubsidyID() { return this->subsidy_id; }
    00109
    00110 private:
    00111   SubsidyID subsidy_id;
    00112 };
    00113
    00117 class AIEventSubsidyOfferExpired : public AIEvent {
    00118 public:
    00119   static const char *GetClassName() { return "AIEventSubsidyOfferExpired"; }
    00120
    00124   AIEventSubsidyOfferExpired(SubsidyID subsidy_id) :
    00125     AIEvent(AI_ET_SUBSIDY_OFFER_EXPIRED),
    00126     subsidy_id(subsidy_id)
    00127   {}
    00128
    00134   static AIEventSubsidyOfferExpired *Convert(AIEvent *instance) { return (AIEventSubsidyOfferExpired *)instance; }
    00135
    00140   SubsidyID GetSubsidyID() { return this->subsidy_id; }
    00141
    00142 private:
    00143   SubsidyID subsidy_id;
    00144 };
    00145
    00149 class AIEventSubsidyAwarded : public AIEvent {
    00150 public:
    00151   static const char *GetClassName() { return "AIEventSubsidyAwarded"; }
    00152
    00156   AIEventSubsidyAwarded(SubsidyID subsidy_id) :
    00157     AIEvent(AI_ET_SUBSIDY_AWARDED),
    00158     subsidy_id(subsidy_id)
    00159   {}
    00160
    00166   static AIEventSubsidyAwarded *Convert(AIEvent *instance) { return (AIEventSubsidyAwarded *)instance; }
    00167
    00172   SubsidyID GetSubsidyID() { return this->subsidy_id; }
    00173
    00174 private:
    00175   SubsidyID subsidy_id;
    00176 };
    00177
    00181 class AIEventSubsidyExpired : public AIEvent {
    00182 public:
    00183   static const char *GetClassName() { return "AIEventSubsidyExpired"; }
    00184
    00188   AIEventSubsidyExpired(SubsidyID subsidy_id) :
    00189     AIEvent(AI_ET_SUBSIDY_EXPIRED),
    00190     subsidy_id(subsidy_id)
    00191   {}
    00192
    00198   static AIEventSubsidyExpired *Convert(AIEvent *instance) { return (AIEventSubsidyExpired *)instance; }
    00199
    00204    SubsidyID GetSubsidyID() { return this->subsidy_id; }
    00205
    00206 private:
    00207   SubsidyID subsidy_id;
    00208 };
    00209
    00215 class AIEventEnginePreview : public AIEvent {
    00216 public:
    00217   static const char *GetClassName() { return "AIEventEnginePreview"; }
    00218
    00222   AIEventEnginePreview(EngineID engine) :
    00223     AIEvent(AI_ET_ENGINE_PREVIEW),
    00224     engine(engine)
    00225   {}
    00226
    00232   static AIEventEnginePreview *Convert(AIEvent *instance) { return (AIEventEnginePreview *)instance; }
    00233
    00238   char *GetName();
    00239
    00245   CargoID GetCargoType();
    00246
    00252   int32 GetCapacity();
    00253
    00261   int32 GetMaxSpeed();
    00262
    00267   Money GetPrice();
    00268
    00274   Money GetRunningCost();
    00275
    00276 #ifdef DOXYGEN_SKIP
    00277
    00281   AIVehicle::VehicleType GetVehicleType();
    00282 #else
    00283   int32 GetVehicleType();
    00284 #endif
    00285
    00290   bool AcceptPreview();
    00291
    00292 private:
    00293   EngineID engine;
    00294 };
    00295
    00299 class AIEventCompanyNew : public AIEvent {
    00300 public:
    00301   static const char *GetClassName() { return "AIEventCompanyNew"; }
    00302
    00306   AIEventCompanyNew(Owner owner) :
    00307     AIEvent(AI_ET_COMPANY_NEW),
    00308     owner((AICompany::CompanyID)owner)
    00309   {}
    00310
    00316   static AIEventCompanyNew *Convert(AIEvent *instance) { return (AIEventCompanyNew *)instance; }
    00317
    00322   AICompany::CompanyID GetCompanyID() { return this->owner; }
    00323
    00324 private:
    00325   AICompany::CompanyID owner;
    00326 };
    00327
    00332 class AIEventCompanyInTrouble : public AIEvent {
    00333 public:
    00334   static const char *GetClassName() { return "AIEventCompanyInTrouble"; }
    00335
    00339   AIEventCompanyInTrouble(Owner owner) :
    00340     AIEvent(AI_ET_COMPANY_IN_TROUBLE),
    00341     owner((AICompany::CompanyID)owner)
    00342   {}
    00343
    00349   static AIEventCompanyInTrouble *Convert(AIEvent *instance) { return (AIEventCompanyInTrouble *)instance; }
    00350
    00355   AICompany::CompanyID GetCompanyID() { return this->owner; }
    00356
    00357 private:
    00358   AICompany::CompanyID owner;
    00359 };
    00360
    00364 class AIEventCompanyAskMerger : public AIEvent {
    00365 public:
    00366   static const char *GetClassName() { return "AIEventCompanyAskMerger"; }
    00367
    00372   AIEventCompanyAskMerger(Owner owner, int32 value) :
    00373     AIEvent(AI_ET_COMPANY_MERGER),
    00374     owner((AICompany::CompanyID)owner),
    00375     value(value)
    00376   {}
    00377
    00383   static AIEventCompanyAskMerger *Convert(AIEvent *instance) { return (AIEventCompanyAskMerger *)instance; }
    00384
    00390   AICompany::CompanyID GetCompanyID() { return this->owner; }
    00391
    00396   int32 GetValue() { return this->value; }
    00397
    00402   bool AcceptMerger();
    00403
    00404 private:
    00405   AICompany::CompanyID owner;
    00406   int32 value;
    00407 };
    00408
    00413 class AIEventCompanyMerger : public AIEvent {
    00414 public:
    00415   static const char *GetClassName() { return "AIEventCompanyMerger"; }
    00416
    00421   AIEventCompanyMerger(Owner old_owner, Owner new_owner) :
    00422     AIEvent(AI_ET_COMPANY_MERGER),
    00423     old_owner((AICompany::CompanyID)old_owner),
    00424     new_owner((AICompany::CompanyID)new_owner)
    00425   {}
    00426
    00432   static AIEventCompanyMerger *Convert(AIEvent *instance) { return (AIEventCompanyMerger *)instance; }
    00433
    00441   AICompany::CompanyID GetOldCompanyID() { return this->old_owner; }
    00442
    00447   AICompany::CompanyID GetNewCompanyID() { return this->new_owner; }
    00448
    00449 private:
    00450   AICompany::CompanyID old_owner;
    00451   AICompany::CompanyID new_owner;
    00452 };
    00453
    00457 class AIEventCompanyBankrupt : public AIEvent {
    00458 public:
    00459   static const char *GetClassName() { return "AIEventCompanyBankrupt"; }
    00460
    00464   AIEventCompanyBankrupt(Owner owner) :
    00465     AIEvent(AI_ET_COMPANY_BANKRUPT),
    00466     owner((AICompany::CompanyID)owner)
    00467   {}
    00468
    00474   static AIEventCompanyBankrupt *Convert(AIEvent *instance) { return (AIEventCompanyBankrupt *)instance; }
    00475
    00480   AICompany::CompanyID GetCompanyID() { return this->owner; }
    00481
    00482 private:
    00483   AICompany::CompanyID owner;
    00484 };
    00485
    00489 class AIEventVehicleLost : public AIEvent {
    00490 public:
    00491   static const char *GetClassName() { return "AIEventVehicleLost"; }
    00492
    00496   AIEventVehicleLost(VehicleID vehicle_id) :
    00497     AIEvent(AI_ET_VEHICLE_LOST),
    00498     vehicle_id(vehicle_id)
    00499   {}
    00500
    00506   static AIEventVehicleLost *Convert(AIEvent *instance) { return (AIEventVehicleLost *)instance; }
    00507
    00512   VehicleID GetVehicleID() { return this->vehicle_id; }
    00513
    00514 private:
    00515   VehicleID vehicle_id;
    00516 };
    00517
    00521 class AIEventVehicleWaitingInDepot : public AIEvent {
    00522 public:
    00523   static const char *GetClassName() { return "AIEventVehicleWaitingInDepot"; }
    00524
    00528   AIEventVehicleWaitingInDepot(VehicleID vehicle_id) :
    00529     AIEvent(AI_ET_VEHICLE_WAITING_IN_DEPOT),
    00530     vehicle_id(vehicle_id)
    00531   {}
    00532
    00538   static AIEventVehicleWaitingInDepot *Convert(AIEvent *instance) { return (AIEventVehicleWaitingInDepot *)instance; }
    00539
    00544   VehicleID GetVehicleID() { return this->vehicle_id; }
    00545
    00546 private:
    00547   VehicleID vehicle_id;
    00548 };
    00549
    00553 class AIEventVehicleUnprofitable : public AIEvent {
    00554 public:
    00555   static const char *GetClassName() { return "AIEventVehicleUnprofitable"; }
    00556
    00560   AIEventVehicleUnprofitable(VehicleID vehicle_id) :
    00561     AIEvent(AI_ET_VEHICLE_UNPROFITABLE),
    00562     vehicle_id(vehicle_id)
    00563   {}
    00564
    00570   static AIEventVehicleUnprofitable *Convert(AIEvent *instance) { return (AIEventVehicleUnprofitable *)instance; }
    00571
    00576   VehicleID GetVehicleID() { return this->vehicle_id; }
    00577
    00578 private:
    00579   VehicleID vehicle_id;
    00580 };
    00581
    00585 class AIEventIndustryOpen : public AIEvent {
    00586 public:
    00587   static const char *GetClassName() { return "AIEventIndustryOpen"; }
    00588
    00592   AIEventIndustryOpen(IndustryID industry_id) :
    00593     AIEvent(AI_ET_INDUSTRY_OPEN),
    00594     industry_id(industry_id)
    00595   {}
    00596
    00602   static AIEventIndustryOpen *Convert(AIEvent *instance) { return (AIEventIndustryOpen *)instance; }
    00603
    00608   IndustryID GetIndustryID() { return this->industry_id; }
    00609
    00610 private:
    00611   IndustryID industry_id;
    00612 };
    00613
    00617 class AIEventIndustryClose : public AIEvent {
    00618 public:
    00619   static const char *GetClassName() { return "AIEventIndustryClose"; }
    00620
    00624   AIEventIndustryClose(IndustryID industry_id) :
    00625     AIEvent(AI_ET_INDUSTRY_CLOSE),
    00626     industry_id(industry_id)
    00627   {}
    00628
    00634   static AIEventIndustryClose *Convert(AIEvent *instance) { return (AIEventIndustryClose *)instance; }
    00635
    00640   IndustryID GetIndustryID() { return this->industry_id; }
    00641
    00642 private:
    00643   IndustryID industry_id;
    00644 };
    00645
    00649 class AIEventEngineAvailable : public AIEvent {
    00650 public:
    00651   static const char *GetClassName() { return "AIEventEngineAvailable"; }
    00652
    00656   AIEventEngineAvailable(EngineID engine) :
    00657     AIEvent(AI_ET_ENGINE_AVAILABLE),
    00658     engine(engine)
    00659   {}
    00660
    00666   static AIEventEngineAvailable *Convert(AIEvent *instance) { return (AIEventEngineAvailable *)instance; }
    00667
    00672   EngineID GetEngineID() { return this->engine; }
    00673
    00674 private:
    00675   EngineID engine;
    00676 };
    00677
    00681 class AIEventStationFirstVehicle : public AIEvent {
    00682 public:
    00683   static const char *GetClassName() { return "AIEventStationFirstVehicle"; }
    00684
    00689   AIEventStationFirstVehicle(StationID station, VehicleID vehicle) :
    00690     AIEvent(AI_ET_STATION_FIRST_VEHICLE),
    00691     station(station),
    00692     vehicle(vehicle)
    00693   {}
    00694
    00700   static AIEventStationFirstVehicle *Convert(AIEvent *instance) { return (AIEventStationFirstVehicle *)instance; }
    00701
    00706   StationID GetStationID() { return this->station; }
    00707
    00712   VehicleID GetVehicleID() { return this->vehicle; }
    00713
    00714 private:
    00715   StationID station;
    00716   VehicleID vehicle;
    00717 };
    00718
    00722 class AIEventDisasterZeppelinerCrashed : public AIEvent {
    00723 public:
    00724   static const char *GetClassName() { return "AIEventDisasterZeppelinerCrashed"; }
    00725
    00729   AIEventDisasterZeppelinerCrashed(StationID station) :
    00730     AIEvent(AI_ET_DISASTER_ZEPPELINER_CRASHED),
    00731     station(station)
    00732   {}
    00733
    00739   static AIEventDisasterZeppelinerCrashed *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCrashed *)instance; }
    00740
    00745   StationID GetStationID() { return this->station; }
    00746
    00747 private:
    00748   StationID station;
    00749 };
    00750
    00754 class AIEventDisasterZeppelinerCleared : public AIEvent {
    00755 public:
    00756   static const char *GetClassName() { return "AIEventDisasterZeppelinerCleared"; }
    00757
    00761   AIEventDisasterZeppelinerCleared(StationID station) :
    00762     AIEvent(AI_ET_DISASTER_ZEPPELINER_CLEARED),
    00763     station(station)
    00764   {}
    00765
    00771   static AIEventDisasterZeppelinerCleared *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCleared *)instance; }
    00772
    00777   StationID GetStationID() { return this->station; }
    00778
    00779 private:
    00780   StationID station;
    00781 };
    00782
    00783 #endif /* AI_EVENT_TYPES_HPP */