diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/SequenceAction.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/SequenceAction.java')
| -rw-r--r-- | NET/worlds/scape/SequenceAction.java | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/NET/worlds/scape/SequenceAction.java b/NET/worlds/scape/SequenceAction.java new file mode 100644 index 0000000..e206861 --- /dev/null +++ b/NET/worlds/scape/SequenceAction.java @@ -0,0 +1,135 @@ +package NET.worlds.scape; + +import java.io.IOException; +import java.util.Enumeration; +import java.util.Vector; + +public class SequenceAction extends Action { + protected int loopCount = 1; + protected boolean loopInfinite = false; + Vector actions = new Vector(); + SequenceActionState currentSeq; + private static Object classCookie = new Object(); + + @Override + public Persister trigger(Event evt, Persister seqID) { + if (seqID != this.currentSeq) { + return null; + } else { + if (seqID == null) { + this.currentSeq = new SequenceActionState(this); + } + + if (!this.currentSeq.run(evt)) { + this.currentSeq = null; + } + + return this.currentSeq; + } + } + + public void addComponent(Action act) { + this.actions.addElement(act); + } + + public void insertComponent(Action act, int index) { + this.actions.insertElementAt(act, index); + } + + public boolean removeComponent(Action act) { + return this.actions.removeElement(act); + } + + public Enumeration getComponents() { + return this.actions.elements(); + } + + public int getLoopCount() { + return this.loopCount; + } + + public void setLoopCount(int c) { + this.loopCount = c; + } + + @Override + public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException { + Object ret = null; + switch (index - offset) { + case 0: + if (mode == 0) { + VectorProperty vp = new VectorProperty(this, index, "Components"); + vp.allowSorting(false); + ret = ObjectPropertyAdder.make(vp, this.getRoot(), "NET.worlds.scape.Action"); + } else if (mode == 1) { + ret = this.actions.clone(); + } else if (mode == 4) { + this.actions.removeElement(value); + } else if (mode == 3) { + this.actions.addElement((Action)value); + } + break; + case 1: + if (mode == 0) { + ret = IntegerPropertyEditor.make(new Property(this, index, "Loop Count")); + } else if (mode == 1) { + ret = new Integer(this.loopCount); + } else if (mode == 2) { + this.loopCount = (Integer)value; + } + break; + case 2: + if (mode == 0) { + ret = BooleanPropertyEditor.make(new Property(this, index, "Loop Infinite"), "False", "True"); + } else if (mode == 1) { + ret = new Boolean(this.loopInfinite); + } else if (mode == 2) { + this.loopInfinite = (Boolean)value; + } + break; + default: + ret = super.properties(index, offset + 3, mode, value); + } + + return ret; + } + + @Override + public void saveState(Saver s) throws IOException { + s.saveVersion(2, classCookie); + super.saveState(s); + s.saveBoolean(this.loopInfinite); + s.saveVector(this.actions); + s.saveInt(this.loopCount); + } + + @Override + public void restoreState(Restorer r) throws IOException, TooNewException { + switch (r.restoreVersion(classCookie)) { + case 0: + r.setOldFlag(); + super.restoreState(r); + this.actions = r.restoreVector(); + this.loopCount = r.restoreInt(); + this.loopInfinite = this.loopCount < 0; + this.loopCount = Math.abs(this.loopCount); + r.restoreBoolean(); + break; + case 1: + super.restoreState(r); + this.actions = r.restoreVector(); + this.loopCount = r.restoreInt(); + this.loopInfinite = this.loopCount < 0; + this.loopCount = Math.abs(this.loopCount); + break; + case 2: + super.restoreState(r); + this.loopInfinite = r.restoreBoolean(); + this.actions = r.restoreVector(); + this.loopCount = r.restoreInt(); + break; + default: + throw new TooNewException(); + } + } +} |