summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/SequenceActionState.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/SequenceActionState.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/SequenceActionState.java')
-rw-r--r--NET/worlds/scape/SequenceActionState.java91
1 files changed, 91 insertions, 0 deletions
diff --git a/NET/worlds/scape/SequenceActionState.java b/NET/worlds/scape/SequenceActionState.java
new file mode 100644
index 0000000..b7e17ed
--- /dev/null
+++ b/NET/worlds/scape/SequenceActionState.java
@@ -0,0 +1,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) {
+ }
+}