summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/RunningActionHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/RunningActionHandler.java')
-rw-r--r--NET/worlds/scape/RunningActionHandler.java238
1 files changed, 238 insertions, 0 deletions
diff --git a/NET/worlds/scape/RunningActionHandler.java b/NET/worlds/scape/RunningActionHandler.java
new file mode 100644
index 0000000..7ef5391
--- /dev/null
+++ b/NET/worlds/scape/RunningActionHandler.java
@@ -0,0 +1,238 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.console.Console;
+/* */ import java.io.IOException;
+/* */ import java.text.MessageFormat;
+/* */ import java.util.Vector;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class RunningActionHandler
+/* */ extends SuperRoot
+/* */ implements FrameHandler, NonPersister
+/* */ {
+/* */ private Action action;
+/* */ private Persister seqID;
+/* */ private RunningActionCallback callback;
+/* */ private Object callbackCookie;
+/* */
+/* */ public static void trigger(Action act, World w, Event event)
+/* */ {
+/* 40 */ trigger(act, w, event, null, null);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public static void trigger(Action act, World w, Event event, RunningActionCallback callb, Object o)
+/* */ {
+/* 59 */ if (act.isActive())
+/* */ {
+/* 61 */ Persister seqID = null;
+/* 62 */ if ((seqID = act.trigger(event, seqID)) != null)
+/* */ {
+/* */
+/* */
+/* 66 */ new RunningActionHandler(w, act, seqID, callb, o);
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */
+/* */ public static void trigger(Vector<Action> v, World w, Event event)
+/* */ {
+/* 74 */ trigger(v, w, event, null, null);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public static void trigger(Vector<Action> v, World w, Event event, RunningActionCallback callb, Object o)
+/* */ {
+/* 85 */ Vector<Action> acts = (Vector)v.clone();
+/* */
+/* 87 */ int sz = acts.size();
+/* 88 */ for (int i = 0; i < sz; i++)
+/* */ {
+/* 90 */ Action act = (Action)acts.elementAt(i);
+/* 91 */ if (v.contains(act)) {
+/* 92 */ trigger(act, w, event, callb, o);
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ RunningActionHandler() {}
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ private RunningActionHandler(World world, Action a, Persister seqID, RunningActionCallback callb, Object o)
+/* */ {
+/* 114 */ this.action = a;
+/* 115 */ this.seqID = seqID;
+/* 116 */ this.callback = callb;
+/* 117 */ this.callbackCookie = o;
+/* 118 */ world.addHandler(this);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public boolean handle(FrameEvent e)
+/* */ {
+/* 131 */ if ((!this.action.isActive()) || ((this.seqID = this.action.trigger(e, this.seqID)) == null)) {
+/* 132 */ if (this.callback != null)
+/* 133 */ this.callback.actionDone(this.action, e, this.callbackCookie);
+/* 134 */ getWorld().removeHandler(this);
+/* */ }
+/* 136 */ return true;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public Object properties(int index, int offset, int mode, Object value)
+/* */ throws NoSuchPropertyException
+/* */ {
+/* 145 */ Object ret = null;
+/* 146 */ switch (index - offset) {
+/* */ case 0:
+/* 148 */ if (mode == 0) {
+/* 149 */ ret = new Property(this, index, "Action");
+/* 150 */ } else if (mode == 1)
+/* 151 */ ret = this.action;
+/* 152 */ break;
+/* */ case 1:
+/* 154 */ if (mode == 0) {
+/* 155 */ ret = new Property(this, index, "Sequence ID Object");
+/* 156 */ } else if (mode == 1)
+/* 157 */ ret = this.seqID;
+/* 158 */ break;
+/* */ default:
+/* 160 */ ret = super.properties(index, offset + 2, mode, value);
+/* */ }
+/* 162 */ return ret;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 169 */ private static Object classCookie = new Object();
+/* */
+/* */ public void saveState(Saver s) throws IOException
+/* */ {
+/* 173 */ Console.println(Console.message("Save-running"));
+/* 174 */ s.saveVersion(3, classCookie);
+/* 175 */ super.saveState(s);
+/* 176 */ s.save(this.action);
+/* 177 */ s.saveMaybeNull(this.seqID);
+/* 178 */ s.saveMaybeNull((Persister)this.callback);
+/* */ }
+/* */
+/* */ public void restoreState(Restorer r) throws IOException, TooNewException
+/* */ {
+/* 183 */ switch (r.restoreVersion(classCookie)) {
+/* */ case 3:
+/* 185 */ super.restoreState(r);
+/* 186 */ this.action = ((Action)r.restore());
+/* 187 */ this.seqID = r.restoreMaybeNull();
+/* 188 */ this.callback = ((RunningActionCallback)r.restoreMaybeNull());
+/* 189 */ break;
+/* */ case 2:
+/* 191 */ super.restoreState(r);
+/* 192 */ this.action = ((Action)r.restore());
+/* 193 */ this.seqID = r.restoreMaybeNull();
+/* 194 */ this.callback = null;
+/* 195 */ break;
+/* */ case 1:
+/* 197 */ super.restoreState(r);
+/* 198 */ this.action = ((Action)r.restore());
+/* 199 */ this.callback = null;
+/* 200 */ break;
+/* */ case 0:
+/* 202 */ super.restoreState(r);
+/* 203 */ r.restore();
+/* 204 */ this.action = ((Action)r.restoreMaybeNull());
+/* 205 */ this.callback = null;
+/* 206 */ break;
+/* */ default:
+/* 208 */ throw new TooNewException();
+/* */ }
+/* */ }
+/* */
+/* */ public void postRestore(int version)
+/* */ {
+/* 214 */ super.postRestore(version);
+/* 215 */ Object[] arguments = { new String(getName()) };
+/* 216 */ Console.println(MessageFormat.format(
+/* 217 */ Console.message("Discarding-old"), arguments));
+/* 218 */ SuperRoot owner = getOwner();
+/* 219 */ if ((owner instanceof WObject)) {
+/* 220 */ ((WObject)owner).removeHandler(this);
+/* 221 */ } else if ((owner instanceof World)) {
+/* 222 */ ((World)owner).removeHandler(this);
+/* */ } else {
+/* 224 */ Console.println(MessageFormat.format(
+/* 225 */ Console.message("Unable-discard"), arguments));
+/* */ }
+/* */ }
+/* */
+/* */ public String toString() {
+/* 230 */ return super.toString() + ":" + this.action.getName() + "[" + this.seqID + "]";
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\RunningActionHandler.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file