(svn r12431) [NoAI] -Add: added AIEventSubsidiaryOffer, which keeps you informed about new Subsidiaries
/* $Id$ */
/** @file ai_event_types.hpp The detailed types of all events */
#ifndef AI_EVENT_TYPES_HPP
#define AI_EVENT_TYPES_HPP
#include "ai_object.hpp"
#include "ai_event.hpp"
#include "ai_town.hpp"
#include "ai_industry.hpp"
/**
* A simple test event, to see if the event system is working. Triggered via
* AIEventController::Test();
*/
class AIEventTest : public AIEvent {
public:
static const char *GetClassName() { return "AIEventTest"; }
/**
* @param test A test value.
*/
AIEventTest(uint test) :
AIEvent(AI_ET_TEST),
test(test)
{}
/**
* Convert an AIEvent to the real instance.
*/
static AIEventTest *Convert(AIEvent *instance) { return (AIEventTest *)instance; }
/**
* Return the test value.
*/
uint GetTest() { return this->test; }
private:
uint test;
};
/**
* A vehicle crashed, and because of that this event is triggered.
* It contains both the crash site as the vehicle crashed. It has a nice
* helper that creates a new vehicle in a depot with the same type
* and orders as the crashed one. In case the vehicle type isn't available
* anymore, it will find the next best.
*/
class AIEventVehicleCrash : public AIEvent {
public:
static const char *GetClassName() { return "AIEventVehicleCrash"; }
/**
* @param vehicle The vehicle that crashed.
* @param crash_site Where the vehicle crashed.
*/
AIEventVehicleCrash(VehicleID vehicle, TileIndex crash_site) :
AIEvent(AI_ET_CRASHED_VEHICLE),
crash_site(crash_site),
vehicle(vehicle)
{}
/**
* Convert an AIEvent to the real instance.
*/
static AIEventVehicleCrash *Convert(AIEvent *instance) { return (AIEventVehicleCrash *)instance; }
/**
* Get the VehicleID of the crashed vehicle.
*/
VehicleID GetVehicleID() { return vehicle; }
/**
* Find the tile the vehicle crashed.
*/
TileIndex GetCrashSite() { return crash_site; }
/**
* Clone the crashed vehicle and send it on its way again.
* @param depot the depot to build the vehicle in.
* @note This function isn't implemented yet.
*/
bool CloneCrashedVehicle(TileIndex depot);
private:
TileIndex crash_site;
VehicleID vehicle;
};
/**
* A subsidiary is offered. You can get the type of cargo the subsidiary is
* for, if it is between towns or industry, and from where to where (which
* is either in TownID or IndustryID).
*/
class AIEventSubsidiaryOffer : public AIEvent {
public:
static const char *GetClassName() { return "AIEventSubsidiaryOffer"; }
/**
* @param cargo The cargo for the subsidiary.
* @param from_town True if 'from' is a town, else it is an industry.
* @param from Either TownID or IndustryID to move the cargo from.
* @param to_town True if 'to' is a town, else it is an industry.
* @param to Either TownID or IndustryID to move the cargo to.
*/
AIEventSubsidiaryOffer(CargoID cargo, bool from_town, uint32 from, bool to_town, uint32 to) :
AIEvent(AI_ET_SUBSIDIARY_OFFER),
cargo(cargo),
from_town(from_town),
from(from),
to_town(to_town),
to(to)
{}
/**
* Convert an AIEvent to the real instance.
*/
static AIEventSubsidiaryOffer *Convert(AIEvent *instance) { return (AIEventSubsidiaryOffer *)instance; }
/**
* Get the CargoID of the subsidiary.
*/
CargoID GetCargoID() { return cargo; }
/**
* Get the TownID from where you need to move the cargo.
* @return Either the TownID, or AITown::IsValidTown() returns false.
*/
TownID GetFromTownID() { return from_town ? from : -1; }
/**
* Get the TownID to where you need to move the cargo.
* @return Either the TownID, or AITown::IsValidTown() returns false.
*/
TownID GetToTownID() { return to_town ? to : -1; }
/**
* Get the IndustryID from where you need to move the cargo.
* @return Either the IndustryID, or AIIndustry::IsValidIndustry() returns false.
*/
IndustryID GetFromIndustryID() { return from_town ? -1 : from; }
/**
* Get the IndustryID to where you need to move the cargo.
* @return Either the IndustryID, or AIIndustry::IsValidIndustry() returns false.
*/
IndustryID GetToIndustryID() { return to_town ? -1 : to; }
private:
CargoID cargo;
bool from_town;
uint32 from;
bool to_town;
uint32 to;
};
#endif /* AI_EVENT_TYPES_HPP */