summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/ParallelAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/ParallelAction.java')
-rw-r--r--NET/worlds/scape/ParallelAction.java226
1 files changed, 226 insertions, 0 deletions
diff --git a/NET/worlds/scape/ParallelAction.java b/NET/worlds/scape/ParallelAction.java
new file mode 100644
index 0000000..74ecc83
--- /dev/null
+++ b/NET/worlds/scape/ParallelAction.java
@@ -0,0 +1,226 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import java.io.IOException;
+/* */ import java.util.Enumeration;
+/* */ import java.util.Vector;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class ParallelAction
+/* */ extends Action
+/* */ implements RunningActionCallback
+/* */ {
+/* */ protected static final int NONE = 0;
+/* */ protected static final int FIRST = 1;
+/* */ protected static final int ALL = -1;
+/* 40 */ protected Vector<Action> actions = new Vector();
+/* */
+/* */
+/* 43 */ protected int waitState = -1;
+/* */
+/* */
+/* 46 */ protected int waitingFor = 0;
+/* */
+/* */
+/* 49 */ protected Object currentRun = null;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public Persister trigger(Event evt, Persister seqID)
+/* */ {
+/* 66 */ if (seqID == null) {
+/* 67 */ if (this.waitingFor == 0) {
+/* 68 */ this.currentRun = new Object();
+/* 69 */ if (this.waitState == -1) {
+/* 70 */ this.waitingFor = this.actions.size();
+/* 71 */ seqID = this;
+/* 72 */ } else if (this.waitState == 1) {
+/* 73 */ this.waitingFor = 1;
+/* 74 */ seqID = this;
+/* */ } else {
+/* 76 */ this.waitingFor = 0;
+/* 77 */ seqID = null;
+/* */ }
+/* 79 */ RunningActionHandler.trigger(this.actions, getWorld(), evt,
+/* 80 */ this, this.currentRun);
+/* */ }
+/* */ }
+/* 83 */ else if (this.waitingFor == 0) {
+/* 84 */ seqID = null;
+/* */ }
+/* 86 */ return seqID;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void actionDone(Action a, Event e, Object o)
+/* */ {
+/* 101 */ if ((this.waitingFor > 0) && (o == this.currentRun)) {
+/* 102 */ this.waitingFor -= 1;
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 110 */ public void setWaitForAll() { this.waitState = -1; }
+/* 111 */ public void setWaitForFirst() { this.waitState = 1; }
+/* 112 */ public void setWaitForNone() { this.waitState = 0; }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void addComponent(Action act)
+/* */ {
+/* 121 */ assert (act != null);
+/* 122 */ this.actions.addElement(act);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void insertComponent(Action act, int index)
+/* */ {
+/* 131 */ assert (act != null);
+/* 132 */ this.actions.insertElementAt(act, index);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public boolean removeComponent(Action act)
+/* */ {
+/* 141 */ assert (act != null);
+/* 142 */ return this.actions.removeElement(act);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public Enumeration<Action> getComponents()
+/* */ {
+/* 150 */ return this.actions.elements();
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public Object properties(int index, int offset, int mode, Object value)
+/* */ throws NoSuchPropertyException
+/* */ {
+/* 160 */ Object ret = null;
+/* 161 */ switch (index - offset) {
+/* */ case 0:
+/* 163 */ if (mode == 0) {
+/* 164 */ ret = ObjectPropertyAdder.make(
+/* 165 */ new VectorProperty(this, index, "Components"),
+/* 166 */ getRoot(), "NET.worlds.scape.Action");
+/* 167 */ } else if (mode == 1) {
+/* 168 */ ret = this.actions.clone();
+/* 169 */ } else if (mode == 4) {
+/* 170 */ this.actions.removeElement(value);
+/* 171 */ } else if (mode == 3)
+/* 172 */ this.actions.addElement((Action)value);
+/* 173 */ break;
+/* */ case 1:
+/* 175 */ if (mode == 0) {
+/* 176 */ String[] names = { "None", "First", "All" };
+/* 177 */ int[] values = { 0, 1, -1 };
+/* 178 */ ret = EnumPropertyEditor.make(
+/* 179 */ new Property(this, index, "Wait for"),
+/* 180 */ names, values);
+/* 181 */ } else if (mode == 1) {
+/* 182 */ ret = new Integer(this.waitState);
+/* 183 */ } else if (mode == 2) {
+/* 184 */ this.waitState = ((Integer)value).intValue(); }
+/* 185 */ break;
+/* */ default:
+/* 187 */ ret = super.properties(index, offset + 2, mode, value);
+/* */ }
+/* 189 */ return ret;
+/* */ }
+/* */
+/* */
+/* */
+/* 194 */ private static Object classCookie = new Object();
+/* */
+/* */ public void saveState(Saver s) throws IOException
+/* */ {
+/* 198 */ s.saveVersion(2, classCookie);
+/* 199 */ super.saveState(s);
+/* 200 */ s.saveVector(this.actions);
+/* 201 */ s.saveInt(this.waitState);
+/* */ }
+/* */
+/* */ public void restoreState(Restorer r) throws IOException, TooNewException
+/* */ {
+/* 206 */ switch (r.restoreVersion(classCookie)) {
+/* */ case 2:
+/* 208 */ super.restoreState(r);
+/* 209 */ this.actions = r.restoreVectorActions();
+/* 210 */ this.waitState = r.restoreInt();
+/* 211 */ break;
+/* */ case 1:
+/* 213 */ super.restoreState(r);
+/* 214 */ this.actions = r.restoreVectorActions();
+/* 215 */ break;
+/* */ default:
+/* 217 */ throw new TooNewException();
+/* */ }
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\ParallelAction.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file