/* */ package NET.worlds.scape; /* */ /* */ import java.io.IOException; /* */ import java.io.PrintStream; /* */ import java.util.Enumeration; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class Sensor /* */ extends SuperRoot /* */ { /* 70 */ protected Vector actions = new Vector(); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void addAction(Action o) /* */ { /* 82 */ this.actions.addElement(o); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void deleteAction(Action o) /* */ { /* 93 */ this.actions.removeElement(o); /* */ } /* */ /* */ /* */ /* */ public void deleteActions() /* */ { /* 100 */ while (this.actions.size() > 0) { /* 101 */ deleteAction((Action)this.actions.elementAt(0)); /* */ } /* */ } /* */ /* */ /* */ public Enumeration getActions() /* */ { /* 108 */ return this.actions.elements(); /* */ } /* */ /* */ /* */ /* */ public int countActions() /* */ { /* 115 */ return this.actions.size(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void trigger(Event event) /* */ { /* 126 */ RunningActionHandler.trigger(this.actions, getWorld(), event); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 136 */ Object ret = null; /* 137 */ switch (index - offset) { /* */ case 0: /* 139 */ if (mode == 0) { /* 140 */ ret = ObjectPropertyAdder.make(new VectorProperty(this, index, /* 141 */ "Targets"), getRoot(), "NET.worlds.scape.Action"); /* 142 */ } else if (mode == 1) { /* 143 */ ret = this.actions.clone(); /* 144 */ } else if (mode == 4) { /* 145 */ deleteAction((Action)value); /* 146 */ } else if (mode == 3) /* 147 */ addAction((Action)value); /* 148 */ break; /* */ default: /* 150 */ ret = super.properties(index, offset + 1, mode, value); /* */ } /* 152 */ return ret; /* */ } /* */ /* */ /* 156 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException { /* 159 */ s.saveVersion(2, classCookie); /* 160 */ super.saveState(s); /* 161 */ s.saveVector(this.actions); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException { /* 165 */ restoreStateVers(r); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ protected int restoreStateVers(Restorer r) /* */ throws IOException, TooNewException /* */ { /* 175 */ int vers = r.restoreVersion(classCookie); /* */ /* 177 */ switch (vers) { /* */ case 1: /* */ case 2: /* 180 */ super.restoreState(r); /* */ case 0: /* 182 */ this.actions = r.restoreVectorActions(); /* 183 */ break; /* */ default: /* 185 */ throw new TooNewException(); /* */ } /* */ /* 188 */ return vers; /* */ } /* */ /* */ public void postRestore(int version) { /* 192 */ super.postRestore(version); /* 193 */ for (Enumeration en = getActions(); en.hasMoreElements();) { /* 194 */ Action a = (Action)en.nextElement(); /* 195 */ if ((getOwner() != null) && (a.getOwner() == null)) { /* 196 */ System.out.println("Reparenting orphan action " + a.getName()); /* 197 */ WObject w = (WObject)getOwner(); /* 198 */ w.addAction(a); /* */ } /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Sensor.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */