summaryrefslogtreecommitdiff
path: root/src/trigger.c
blob: 41dc4a0147a4fb93001de5684cff1b35a456a18e (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
NAME(trigger);
PARENT(tile);

INIT {
	super("init");
	this->on = propertyb("on");
	this->multi = propertyb("multi");
	this->leave = propertyb("leave");
	this->do_x = propertyb("flip x") || propertyb("x");
	this->do_y = propertyb("flip y") || propertyb("y");
}

IMPL(target) {
	this->target = propertyi("target") + 1;
}

IMPL(enter) {}
IMPL(leave) {}

UPDATE {
	if (!this->visible)
		return;
	if (place_meeting(v2_zero(), "player", false)) {
		if (!this->air) {
			method("enter");
			this->air = true;
			if (!this->leave && !this->multi)
				method("deinit");
		}
	} else {
		if (this->air) {
			method("leave");
			this->air = false;
			if (!this->multi)
				method("deinit");
			if (!this->multi)
				method("deinit");
		}
	}
}

DRAW {
	if (this->animation > 4)
		return;
	super("draw");
}