forked from avose/ChromoCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_event.h
73 lines (56 loc) · 1.83 KB
/
game_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
71
72
73
#ifndef GAME_EVENT_H
#define GAME_EVENT_H
#include "vector.h"
#include "types.h"
#include "gem.h"
#include "enemy.h"
#include "tower.h"
// Game event types
#define GAME_EVENT_NONE 0
#define GAME_EVENT_TOWER_INSTALL_GEM 1
#define GAME_EVENT_TOWER_REMOVE_GEM 2
#define GAME_EVENT_TOWER_SWAP_GEM 3
#define GAME_EVENT_CREATE_GEM 4
#define GAME_EVENT_MIX_GEMS 5
#define GAME_EVENT_NEXT_WAVE 6
// Event queue node/queue
typedef struct str_game_eventq_node_t {
struct str_game_eventq_node_t *last;
struct str_game_eventq_node_t *next;
u32b_t type; // Type of event (can use to pull out of union below)
u32b_t flags; // Event flags (unique use for each event type)
u64b_t time; // Time (in game ticks) this event occurred
union {
// Struct for tower install, remove, swap gem events.
struct {
vector3_t tpos;
u32b_t ndx;
} tower_install_gem;
// Struct for gem creation events.
struct {
gem_t gem;
u32b_t ndx;
} create_gem;
// Struct for gem mixing events.
struct {
u32b_t ndx1;
u32b_t ndx2;
} mix_gems;
};
} game_eventq_node_t, game_eventq_t;
////////////////////////////////////////////////////////////
// Interface
////////////////////////////////////////////////////////////
#ifndef GAME_EVENT_C
// Consumers
extern game_eventq_t* game_event_get (game_eventq_t *node);
extern void game_event_remove(game_eventq_t *node);
// Producers
extern void game_event_tower_install_gem(tower_t *tower, u32b_t ndx);
extern void game_event_tower_remove_gem (tower_t *tower);
extern void game_event_tower_swap_gem (tower_t *tower, u32b_t ndx);
extern void game_event_create_gem(gem_t *gem);
extern void game_event_mix_gems (u32b_t ndx1, u32b_t ndx2);
extern void game_event_next_wave();
#endif
#endif