-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccodoc.h
66 lines (48 loc) · 1.3 KB
/
ccodoc.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
#pragma once
#include "time.h"
#include <stdbool.h>
typedef struct timer action_t;
typedef void (*event_listener_t)(void*);
struct event {
void* listener;
event_listener_t listen;
};
enum water_flow_state {
holding_water,
releasing_water,
};
// kakehi(筧)
struct kakehi {
enum water_flow_state state;
bool disabled;
action_t holding_water;
unsigned int release_water_amount;
action_t releasing_water;
};
// tsutsu(筒)
struct tsutsu {
enum water_flow_state state;
unsigned int water_amount;
unsigned int water_capacity;
action_t releasing_water;
struct event on_got_drip;
struct event on_bumped;
};
// hachi(鉢)
struct hachi {
enum water_flow_state state;
action_t releasing_water;
};
// ccodoc(鹿威し)
struct ccodoc {
struct kakehi kakehi;
struct tsutsu tsutsu;
struct hachi hachi;
};
extern void tick_ccodoc(struct ccodoc* ccodoc, struct duration delta);
extern float get_tsutsu_water_amount_ratio(const struct tsutsu* tsutsu);
extern void tick_action(action_t* action, struct duration delta);
extern void reset_action(action_t* action);
extern float get_action_progress_ratio(const action_t* action);
extern bool action_has_finished(const action_t* action);
extern void notify_listener(const struct event* event);