summaryrefslogtreecommitdiff
path: root/src/touch.c
blob: a8f1a61a4da20c4cebe881c74fdb057185dfea35 (plain)
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
NAME(touch);
PARENT(trigger);

INIT {
	super("init");
	super("target");
}

IMPL(enter) {
	if (!this->leave) {
		auto v = g_group(this->target);
		repeat(i, v->size) entity_method(VecEntityP_get(v, i), "enter");
		VecEntityP_free(v);
	}
	if (!this->air)
		this->animation = 4;
}

IMPL(leave) {
	if (this->leave) {
		auto v = g_group(this->target);
		repeat(i, v->size) entity_method(VecEntityP_get(v, i), "enter");
		VecEntityP_free(v);
	}
	this->animation = 0;
}

UPDATE {
	super("update");
	if (this->air)
		this->animation = (this->animation + 1) % 8;
}