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