1 #pragma once 2 #ifndef CATA_SRC_TIMED_EVENT_H 3 #define CATA_SRC_TIMED_EVENT_H 4 5 #include <list> 6 7 #include "calendar.h" 8 #include "point.h" 9 10 enum class timed_event_type : int { 11 NONE, 12 HELP, 13 WANTED, 14 ROBOT_ATTACK, 15 SPAWN_WYRMS, 16 AMIGARA, 17 ROOTS_DIE, 18 TEMPLE_OPEN, 19 TEMPLE_FLOOD, 20 TEMPLE_SPAWN, 21 DIM, 22 ARTIFACT_LIGHT, 23 NUM_TIMED_EVENT_TYPES 24 }; 25 26 struct timed_event { 27 timed_event_type type = timed_event_type::NONE; 28 /** On which turn event should be happening. */ 29 time_point when = calendar::turn_zero; 30 /** Which faction is responsible for handling this event. */ 31 int faction_id = -1; 32 /** Where the event happens, in global submap coordinates */ 33 tripoint map_point = tripoint_min; 34 35 timed_event( timed_event_type e_t, const time_point &w, int f_id, tripoint p ); 36 37 // When the time runs out 38 void actualize(); 39 // Every turn 40 void per_turn(); 41 }; 42 43 class timed_event_manager 44 { 45 private: 46 std::list<timed_event> events; 47 48 public: 49 /** 50 * Add an entry to the event queue. Parameters are basically passed 51 * through to @ref timed_event::timed_event. 52 */ 53 void add( timed_event_type type, const time_point &when, int faction_id = -1 ); 54 /** 55 * Add an entry to the event queue. Parameters are basically passed 56 * through to @ref timed_event::timed_event. 57 */ 58 void add( timed_event_type type, const time_point &when, int faction_id, const tripoint &where ); 59 /// @returns Whether at least one element of the given type is queued. 60 bool queued( timed_event_type type ) const; 61 /// @returns One of the queued events of the given type, or `nullptr` 62 /// if no event of that type is queued. 63 timed_event *get( timed_event_type type ); 64 /// Process all queued events, potentially altering the game state and 65 /// modifying the event queue. 66 void process(); 67 }; 68 69 timed_event_manager &get_timed_events(); 70 71 #endif // CATA_SRC_TIMED_EVENT_H 72