ai_event_types.hpp

Go to the documentation of this file.
00001 /* $Id: ai_event_types.hpp 21987 2011-02-05 20:41:13Z 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_event.hpp"
00016 #include "ai_company.hpp"
00017 
00022 class AIEventVehicleCrashed : public AIEvent {
00023 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:
00088   static const char *GetClassName() { return "AIEventSubsidyOffer"; }
00089 
00093   AIEventSubsidyOffer(SubsidyID subsidy_id) :
00094     AIEvent(AI_ET_SUBSIDY_OFFER),
00095     subsidy_id(subsidy_id)
00096   {}
00097 
00103   static AIEventSubsidyOffer *Convert(AIEvent *instance) { return (AIEventSubsidyOffer *)instance; }
00104 
00109   SubsidyID GetSubsidyID() { return this->subsidy_id; }
00110 
00111 private:
00112   SubsidyID subsidy_id;
00113 };
00114 
00118 class AIEventSubsidyOfferExpired : public AIEvent {
00119 public:
00121   static const char *GetClassName() { return "AIEventSubsidyOfferExpired"; }
00122 
00126   AIEventSubsidyOfferExpired(SubsidyID subsidy_id) :
00127     AIEvent(AI_ET_SUBSIDY_OFFER_EXPIRED),
00128     subsidy_id(subsidy_id)
00129   {}
00130 
00136   static AIEventSubsidyOfferExpired *Convert(AIEvent *instance) { return (AIEventSubsidyOfferExpired *)instance; }
00137 
00142   SubsidyID GetSubsidyID() { return this->subsidy_id; }
00143 
00144 private:
00145   SubsidyID subsidy_id;
00146 };
00147 
00151 class AIEventSubsidyAwarded : public AIEvent {
00152 public:
00154   static const char *GetClassName() { return "AIEventSubsidyAwarded"; }
00155 
00159   AIEventSubsidyAwarded(SubsidyID subsidy_id) :
00160     AIEvent(AI_ET_SUBSIDY_AWARDED),
00161     subsidy_id(subsidy_id)
00162   {}
00163 
00169   static AIEventSubsidyAwarded *Convert(AIEvent *instance) { return (AIEventSubsidyAwarded *)instance; }
00170 
00175   SubsidyID GetSubsidyID() { return this->subsidy_id; }
00176 
00177 private:
00178   SubsidyID subsidy_id;
00179 };
00180 
00184 class AIEventSubsidyExpired : public AIEvent {
00185 public:
00187   static const char *GetClassName() { return "AIEventSubsidyExpired"; }
00188 
00192   AIEventSubsidyExpired(SubsidyID subsidy_id) :
00193     AIEvent(AI_ET_SUBSIDY_EXPIRED),
00194     subsidy_id(subsidy_id)
00195   {}
00196 
00202   static AIEventSubsidyExpired *Convert(AIEvent *instance) { return (AIEventSubsidyExpired *)instance; }
00203 
00208    SubsidyID GetSubsidyID() { return this->subsidy_id; }
00209 
00210 private:
00211   SubsidyID subsidy_id;
00212 };
00213 
00219 class AIEventEnginePreview : public AIEvent {
00220 public:
00222   static const char *GetClassName() { return "AIEventEnginePreview"; }
00223 
00227   AIEventEnginePreview(EngineID engine) :
00228     AIEvent(AI_ET_ENGINE_PREVIEW),
00229     engine(engine)
00230   {}
00231 
00237   static AIEventEnginePreview *Convert(AIEvent *instance) { return (AIEventEnginePreview *)instance; }
00238 
00243   char *GetName();
00244 
00250   CargoID GetCargoType();
00251 
00257   int32 GetCapacity();
00258 
00266   int32 GetMaxSpeed();
00267 
00272   Money GetPrice();
00273 
00279   Money GetRunningCost();
00280 
00281 #ifdef DOXYGEN_SKIP
00282 
00286   AIVehicle::VehicleType GetVehicleType();
00287 #else
00288   int32 GetVehicleType();
00289 #endif
00290 
00295   bool AcceptPreview();
00296 
00297 private:
00298   EngineID engine;
00299   bool IsEngineValid() const;
00300 };
00301 
00305 class AIEventCompanyNew : public AIEvent {
00306 public:
00308   static const char *GetClassName() { return "AIEventCompanyNew"; }
00309 
00313   AIEventCompanyNew(Owner owner) :
00314     AIEvent(AI_ET_COMPANY_NEW),
00315     owner((AICompany::CompanyID)owner)
00316   {}
00317 
00323   static AIEventCompanyNew *Convert(AIEvent *instance) { return (AIEventCompanyNew *)instance; }
00324 
00329   AICompany::CompanyID GetCompanyID() { return this->owner; }
00330 
00331 private:
00332   AICompany::CompanyID owner;
00333 };
00334 
00339 class AIEventCompanyInTrouble : public AIEvent {
00340 public:
00342   static const char *GetClassName() { return "AIEventCompanyInTrouble"; }
00343 
00347   AIEventCompanyInTrouble(Owner owner) :
00348     AIEvent(AI_ET_COMPANY_IN_TROUBLE),
00349     owner((AICompany::CompanyID)owner)
00350   {}
00351 
00357   static AIEventCompanyInTrouble *Convert(AIEvent *instance) { return (AIEventCompanyInTrouble *)instance; }
00358 
00363   AICompany::CompanyID GetCompanyID() { return this->owner; }
00364 
00365 private:
00366   AICompany::CompanyID owner;
00367 };
00368 
00372 class AIEventCompanyAskMerger : public AIEvent {
00373 public:
00375   static const char *GetClassName() { return "AIEventCompanyAskMerger"; }
00376 
00381   AIEventCompanyAskMerger(Owner owner, int32 value) :
00382     AIEvent(AI_ET_COMPANY_ASK_MERGER),
00383     owner((AICompany::CompanyID)owner),
00384     value(value)
00385   {}
00386 
00392   static AIEventCompanyAskMerger *Convert(AIEvent *instance) { return (AIEventCompanyAskMerger *)instance; }
00393 
00399   AICompany::CompanyID GetCompanyID() { return this->owner; }
00400 
00405   int32 GetValue() { return this->value; }
00406 
00411   bool AcceptMerger();
00412 
00413 private:
00414   AICompany::CompanyID owner;
00415   int32 value;
00416 };
00417 
00422 class AIEventCompanyMerger : public AIEvent {
00423 public:
00425   static const char *GetClassName() { return "AIEventCompanyMerger"; }
00426 
00431   AIEventCompanyMerger(Owner old_owner, Owner new_owner) :
00432     AIEvent(AI_ET_COMPANY_MERGER),
00433     old_owner((AICompany::CompanyID)old_owner),
00434     new_owner((AICompany::CompanyID)new_owner)
00435   {}
00436 
00442   static AIEventCompanyMerger *Convert(AIEvent *instance) { return (AIEventCompanyMerger *)instance; }
00443 
00451   AICompany::CompanyID GetOldCompanyID() { return this->old_owner; }
00452 
00457   AICompany::CompanyID GetNewCompanyID() { return this->new_owner; }
00458 
00459 private:
00460   AICompany::CompanyID old_owner;
00461   AICompany::CompanyID new_owner;
00462 };
00463 
00467 class AIEventCompanyBankrupt : public AIEvent {
00468 public:
00470   static const char *GetClassName() { return "AIEventCompanyBankrupt"; }
00471 
00475   AIEventCompanyBankrupt(Owner owner) :
00476     AIEvent(AI_ET_COMPANY_BANKRUPT),
00477     owner((AICompany::CompanyID)owner)
00478   {}
00479 
00485   static AIEventCompanyBankrupt *Convert(AIEvent *instance) { return (AIEventCompanyBankrupt *)instance; }
00486 
00491   AICompany::CompanyID GetCompanyID() { return this->owner; }
00492 
00493 private:
00494   AICompany::CompanyID owner;
00495 };
00496 
00500 class AIEventVehicleLost : public AIEvent {
00501 public:
00503   static const char *GetClassName() { return "AIEventVehicleLost"; }
00504 
00508   AIEventVehicleLost(VehicleID vehicle_id) :
00509     AIEvent(AI_ET_VEHICLE_LOST),
00510     vehicle_id(vehicle_id)
00511   {}
00512 
00518   static AIEventVehicleLost *Convert(AIEvent *instance) { return (AIEventVehicleLost *)instance; }
00519 
00524   VehicleID GetVehicleID() { return this->vehicle_id; }
00525 
00526 private:
00527   VehicleID vehicle_id;
00528 };
00529 
00533 class AIEventVehicleWaitingInDepot : public AIEvent {
00534 public:
00536   static const char *GetClassName() { return "AIEventVehicleWaitingInDepot"; }
00537 
00541   AIEventVehicleWaitingInDepot(VehicleID vehicle_id) :
00542     AIEvent(AI_ET_VEHICLE_WAITING_IN_DEPOT),
00543     vehicle_id(vehicle_id)
00544   {}
00545 
00551   static AIEventVehicleWaitingInDepot *Convert(AIEvent *instance) { return (AIEventVehicleWaitingInDepot *)instance; }
00552 
00557   VehicleID GetVehicleID() { return this->vehicle_id; }
00558 
00559 private:
00560   VehicleID vehicle_id;
00561 };
00562 
00566 class AIEventVehicleUnprofitable : public AIEvent {
00567 public:
00569   static const char *GetClassName() { return "AIEventVehicleUnprofitable"; }
00570 
00574   AIEventVehicleUnprofitable(VehicleID vehicle_id) :
00575     AIEvent(AI_ET_VEHICLE_UNPROFITABLE),
00576     vehicle_id(vehicle_id)
00577   {}
00578 
00584   static AIEventVehicleUnprofitable *Convert(AIEvent *instance) { return (AIEventVehicleUnprofitable *)instance; }
00585 
00590   VehicleID GetVehicleID() { return this->vehicle_id; }
00591 
00592 private:
00593   VehicleID vehicle_id;
00594 };
00595 
00599 class AIEventIndustryOpen : public AIEvent {
00600 public:
00602   static const char *GetClassName() { return "AIEventIndustryOpen"; }
00603 
00607   AIEventIndustryOpen(IndustryID industry_id) :
00608     AIEvent(AI_ET_INDUSTRY_OPEN),
00609     industry_id(industry_id)
00610   {}
00611 
00617   static AIEventIndustryOpen *Convert(AIEvent *instance) { return (AIEventIndustryOpen *)instance; }
00618 
00623   IndustryID GetIndustryID() { return this->industry_id; }
00624 
00625 private:
00626   IndustryID industry_id;
00627 };
00628 
00632 class AIEventIndustryClose : public AIEvent {
00633 public:
00635   static const char *GetClassName() { return "AIEventIndustryClose"; }
00636 
00640   AIEventIndustryClose(IndustryID industry_id) :
00641     AIEvent(AI_ET_INDUSTRY_CLOSE),
00642     industry_id(industry_id)
00643   {}
00644 
00650   static AIEventIndustryClose *Convert(AIEvent *instance) { return (AIEventIndustryClose *)instance; }
00651 
00656   IndustryID GetIndustryID() { return this->industry_id; }
00657 
00658 private:
00659   IndustryID industry_id;
00660 };
00661 
00665 class AIEventEngineAvailable : public AIEvent {
00666 public:
00668   static const char *GetClassName() { return "AIEventEngineAvailable"; }
00669 
00673   AIEventEngineAvailable(EngineID engine) :
00674     AIEvent(AI_ET_ENGINE_AVAILABLE),
00675     engine(engine)
00676   {}
00677 
00683   static AIEventEngineAvailable *Convert(AIEvent *instance) { return (AIEventEngineAvailable *)instance; }
00684 
00689   EngineID GetEngineID() { return this->engine; }
00690 
00691 private:
00692   EngineID engine;
00693 };
00694 
00698 class AIEventStationFirstVehicle : public AIEvent {
00699 public:
00701   static const char *GetClassName() { return "AIEventStationFirstVehicle"; }
00702 
00707   AIEventStationFirstVehicle(StationID station, VehicleID vehicle) :
00708     AIEvent(AI_ET_STATION_FIRST_VEHICLE),
00709     station(station),
00710     vehicle(vehicle)
00711   {}
00712 
00718   static AIEventStationFirstVehicle *Convert(AIEvent *instance) { return (AIEventStationFirstVehicle *)instance; }
00719 
00724   StationID GetStationID() { return this->station; }
00725 
00730   VehicleID GetVehicleID() { return this->vehicle; }
00731 
00732 private:
00733   StationID station;
00734   VehicleID vehicle;
00735 };
00736 
00740 class AIEventDisasterZeppelinerCrashed : public AIEvent {
00741 public:
00743   static const char *GetClassName() { return "AIEventDisasterZeppelinerCrashed"; }
00744 
00748   AIEventDisasterZeppelinerCrashed(StationID station) :
00749     AIEvent(AI_ET_DISASTER_ZEPPELINER_CRASHED),
00750     station(station)
00751   {}
00752 
00758   static AIEventDisasterZeppelinerCrashed *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCrashed *)instance; }
00759 
00764   StationID GetStationID() { return this->station; }
00765 
00766 private:
00767   StationID station;
00768 };
00769 
00773 class AIEventDisasterZeppelinerCleared : public AIEvent {
00774 public:
00776   static const char *GetClassName() { return "AIEventDisasterZeppelinerCleared"; }
00777 
00781   AIEventDisasterZeppelinerCleared(StationID station) :
00782     AIEvent(AI_ET_DISASTER_ZEPPELINER_CLEARED),
00783     station(station)
00784   {}
00785 
00791   static AIEventDisasterZeppelinerCleared *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCleared *)instance; }
00792 
00797   StationID GetStationID() { return this->station; }
00798 
00799 private:
00800   StationID station;
00801 };
00802 
00806 class AIEventTownFounded : public AIEvent {
00807 public:
00809   static const char *GetClassName() { return "AIEventTownFounded"; }
00810 
00814   AIEventTownFounded(TownID town) :
00815     AIEvent(AI_ET_TOWN_FOUNDED),
00816     town(town)
00817   {}
00818 
00824   static AIEventTownFounded *Convert(AIEvent *instance) { return (AIEventTownFounded *)instance; }
00825 
00830   TownID GetTownID() { return this->town; }
00831 
00832 private:
00833   TownID town;
00834 };
00835 
00836 #endif /* AI_EVENT_TYPES_HPP */

Generated on Fri Mar 4 21:36:56 2011 for OpenTTD by  doxygen 1.6.1