-
Notifications
You must be signed in to change notification settings - Fork 1
/
Delays.pde
49 lines (46 loc) · 1.08 KB
/
Delays.pde
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
class DelayWrapper extends BaseWrapper {
String field;
float value;
int frames;
public DelayWrapper(Transform wrapped, int frames, String field, float value) {
super(wrapped);
this.frames = frames;
this.field = field;
this.value = value;
}
public void tick() {
super.tick();
if (frameCount == frames) {
setValue(field, value);
}
}
private void setValue(String field, float value) {
Transform wrapped = unwrap();
try {
Field f = wrapped.getClass().getDeclaredField(field);
f.setFloat(wrapped, value);
} catch (Exception ex) {
println("Unable to fire delay.");
println(ex.getMessage());
}
}
}
class PauseDelay extends BaseWrapper {
int frames;
public PauseDelay(Transform wrapped, int frames) {
super(wrapped);
this.frames = frames;
}
public void tick() {
super.tick();
if (frameCount == frames) {
Transform wrapped = unwrap();
try {
Pausable p = (Pausable)wrapped;
p.toggle();
} catch (Exception ex) {
println(ex.getMessage());
}
}
}
}