(svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
/* $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"
/**
* A simple test event, to see if the event system is working. Triggered via
* AIEventController::Test();
*/
class AIEventTest : public AIEvent {
public:
/**
* The name of the class, needed by several sub-processes.
*/
static const char *GetClassName() { return "AIEventTest"; }
/**
* Constructor for this event class.
*/
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:
/**
* The name of the class, needed by several sub-processes.
*/
static const char *GetClassName() { return "AIEventVehicleCrash"; }
/**
* Constructor for this event class.
*/
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.
*/
bool CloneCrashedVehicle(TileIndex depot);
private:
TileIndex crash_site;
VehicleID vehicle;
};
#endif /* AI_EVENT_TYPES_HPP */