truelight@9682: /* $Id$ */ truelight@9682: truelight@9682: /** @file ai_event.hpp Everything to handle events from the game */ truelight@9682: truelight@9682: #ifndef AI_EVENT_HPP truelight@9682: #define AI_EVENT_HPP truelight@9682: truelight@9682: #include "ai_object.hpp" truelight@9682: truelight@9682: /** truelight@9682: * A single event that can be triggered by the game. truelight@9682: * You can lookup the type, and than convert it to the real event-class. truelight@9682: * That way you can request more detailed information about the event. truelight@9682: */ truelight@9682: class AIEvent : public AIObject { truelight@9682: public: truelight@9682: /** truelight@9682: * The type of event. Needed to lookup the detailed class. truelight@9682: */ truelight@9682: enum AIEventType { truelight@9682: AI_ET_INVALID = 0, truelight@9682: AI_ET_TEST, truelight@9682: AI_ET_CRASHED_VEHICLE, truelight@9682: }; truelight@9682: truelight@9683: /** truelight@9683: * Constructor of AIEvent, to get the type of event. truelight@9683: */ truelight@9682: AIEvent(AIEvent::AIEventType type) : truelight@9682: type(type) truelight@9682: {} truelight@9682: truelight@9682: /** truelight@9682: * Get the event-type. truelight@9682: */ truelight@9682: AIEventType GetEventType() { return this->type; } truelight@9682: truelight@9682: /** truelight@9682: * The name of the class, needed by several sub-processes. truelight@9682: */ truelight@9682: static const char *GetClassName() { return "AIEvent"; } truelight@9682: truelight@9682: protected: truelight@9682: /** truelight@9682: * The type of this event. truelight@9682: */ truelight@9682: AIEventType type; truelight@9682: }; truelight@9682: truelight@9682: /** truelight@9682: * Class that handles all event related functions. truelight@9682: * @note it is not needed to create an instance of AIEvent to access it, as truelight@9682: * all members are static, and all data is stored AI-wide. truelight@9682: */ truelight@9682: class AIEventController : public AIObject { truelight@9682: public: truelight@9682: /** truelight@9682: * The name of the class, needed by several sub-processes. truelight@9682: */ truelight@9682: static const char *GetClassName() { return "AIEventController"; } truelight@9682: truelight@9682: /** truelight@9682: * Check if there is an event waiting. truelight@9682: * @return true if there is an event on the stack. truelight@9682: */ truelight@9682: static bool IsEventWaiting(); truelight@9682: truelight@9682: /** truelight@9682: * Get the next event. truelight@9682: * @return a class of the event-child issues. truelight@9682: */ truelight@9682: static AIEvent *GetNextEvent(); truelight@9682: truelight@9682: /** truelight@9682: * No longer report an event of this type. truelight@9682: * @param event the event to no longer report. truelight@9682: */ truelight@9682: static void DisableEvent(AIEvent::AIEventType event); truelight@9682: truelight@9682: /** truelight@9682: * Report events of this type. truelight@9682: * @param event the event to report again. truelight@9682: */ truelight@9682: static void EnableEvent(AIEvent::AIEventType event); truelight@9682: truelight@9682: /** truelight@9682: * Disable all events. truelight@9682: */ truelight@9682: static void DisableAllEvents(); truelight@9682: truelight@9682: /** truelight@9682: * Enable all events. truelight@9682: */ truelight@9682: static void EnableAllEvents(); truelight@9682: truelight@9682: /** truelight@9682: * Insert an event to the queue for the player. truelight@9682: */ truelight@9682: static void InsertEvent(AIEvent *event); truelight@9682: truelight@9682: /** truelight@9682: * Give a test event to the system. truelight@9682: */ truelight@9682: static void Test(); truelight@9682: truelight@9682: /** truelight@9682: * Free the event pointer. truelight@9682: * @note DO NOT CALL YOURSELF; leave it to the internal AI programming. truelight@9682: */ truelight@9682: static void FreeEventPointer(); truelight@9682: truelight@9682: private: truelight@9682: /** truelight@9682: * Create the event pointer. truelight@9682: */ truelight@9682: static void CreateEventPointer(); truelight@9682: }; truelight@9682: truelight@9682: #endif /* AI_EVENT_HPP */