blob: b7e17ed134f341d55a8f728ed60bf80f69f50b66 (
plain) (
blame)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package NET.worlds.scape;
import java.io.IOException;
import java.util.Vector;
class SequenceActionState implements Persister {
int currentLoop;
boolean loopInfinite;
Vector actions;
Persister seqID;
int currentAct;
private static Object classCookie = new Object();
SequenceActionState() {
}
SequenceActionState(SequenceAction sa) {
this.currentLoop = sa.loopCount;
this.loopInfinite = sa.loopInfinite;
this.actions = (Vector)sa.actions.clone();
}
boolean run(Event evt) {
if (this.currentLoop <= 0 && !this.loopInfinite) {
return false;
} else {
while (this.currentAct < this.actions.size()) {
Action act = (Action)this.actions.elementAt(this.currentAct);
if ((this.seqID = act.trigger(evt, this.seqID)) != null) {
return true;
}
this.currentAct++;
}
this.currentAct = 0;
if (this.currentLoop > 0) {
this.currentLoop--;
}
return true;
}
}
@Override
public String toString() {
String stateString = "Action #" + this.currentAct + " of loop " + this.currentLoop + ", status " + this.seqID;
if (!this.loopInfinite) {
stateString = stateString + " NOT";
}
return stateString + " Infinite";
}
@Override
public void saveState(Saver s) throws IOException {
s.saveVersion(1, classCookie);
s.saveBoolean(this.loopInfinite);
s.saveInt(this.currentLoop);
s.saveInt(this.currentAct);
s.saveVector(this.actions);
s.saveMaybeNull(this.seqID);
}
@Override
public void restoreState(Restorer r) throws IOException, TooNewException {
switch (r.restoreVersion(classCookie)) {
case 0:
this.currentLoop = r.restoreInt();
this.loopInfinite = this.currentLoop < 0;
this.currentLoop = Math.abs(this.currentLoop);
this.currentAct = r.restoreInt();
this.actions = r.restoreVector();
this.seqID = r.restoreMaybeNull();
break;
case 1:
this.loopInfinite = r.restoreBoolean();
this.currentLoop = r.restoreInt();
this.currentAct = r.restoreInt();
this.actions = r.restoreVector();
this.seqID = r.restoreMaybeNull();
break;
default:
throw new TooNewException();
}
}
@Override
public void postRestore(int version) {
}
}
|