summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/AdvancingAction.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/AdvancingAction.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/AdvancingAction.java')
-rw-r--r--NET/worlds/scape/AdvancingAction.java114
1 files changed, 114 insertions, 0 deletions
diff --git a/NET/worlds/scape/AdvancingAction.java b/NET/worlds/scape/AdvancingAction.java
new file mode 100644
index 0000000..909b1b2
--- /dev/null
+++ b/NET/worlds/scape/AdvancingAction.java
@@ -0,0 +1,114 @@
+package NET.worlds.scape;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+public class AdvancingAction extends Action {
+ private Vector actions = new Vector();
+ private int nextAction = 0;
+ boolean singleTrigger = true;
+ boolean inProgress = false;
+ private static Object classCookie = new Object();
+
+ @Override
+ public Persister trigger(Event evt, Persister seqID) {
+ if (this.singleTrigger && this.inProgress && seqID == null) {
+ return null;
+ } else {
+ if (this.nextAction >= this.actions.size()) {
+ this.nextAction = 0;
+ }
+
+ Action act = (Action)this.actions.elementAt(this.nextAction);
+ Persister id = null;
+ if (act != null) {
+ id = act.trigger(evt, seqID);
+ this.inProgress = id != null;
+ }
+
+ if (id == null || !this.singleTrigger) {
+ this.nextAction++;
+ }
+
+ return id;
+ }
+ }
+
+ 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();
+ }
+
+ @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 = BooleanPropertyEditor.make(new Property(this, index, "Prevent overlapping actions"), "Overlapping", "One at a time");
+ } else if (mode == 1) {
+ ret = new Boolean(this.singleTrigger);
+ } else if (mode == 2) {
+ this.singleTrigger = (Boolean)value;
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 2, mode, value);
+ }
+
+ return ret;
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(1, classCookie);
+ super.saveState(s);
+ s.saveVector(this.actions);
+ s.saveInt(this.nextAction);
+ s.saveBoolean(this.singleTrigger);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 0:
+ super.restoreState(r);
+ this.actions = r.restoreVector();
+ this.nextAction = r.restoreInt();
+ break;
+ case 1:
+ super.restoreState(r);
+ this.actions = r.restoreVector();
+ this.nextAction = r.restoreInt();
+ this.singleTrigger = r.restoreBoolean();
+ break;
+ default:
+ throw new TooNewException();
+ }
+ }
+}