diff options
Diffstat (limited to 'NET/worlds/scape/DPAction.java')
| -rw-r--r-- | NET/worlds/scape/DPAction.java | 386 |
1 files changed, 386 insertions, 0 deletions
diff --git a/NET/worlds/scape/DPAction.java b/NET/worlds/scape/DPAction.java new file mode 100644 index 0000000..64ee529 --- /dev/null +++ b/NET/worlds/scape/DPAction.java @@ -0,0 +1,386 @@ +/* */ package NET.worlds.scape; +/* */ +/* */ import NET.worlds.core.Std; +/* */ import java.io.IOException; +/* */ import java.util.Enumeration; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class DPAction +/* */ extends Action +/* */ { +/* */ private static final int INFINITY = 60000; +/* 63 */ protected int loadDist = 2; +/* 64 */ protected int unloadDist = 4; +/* */ +/* */ +/* 67 */ protected DPState state = null; +/* */ +/* */ +/* */ +/* */ +/* */ +/* 73 */ public int getLoadDist() { return this.loadDist; } +/* 74 */ public int getUnloadDist() { return this.unloadDist; } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void setLoadDist(int v) +/* */ { +/* 86 */ assert (v > 0); +/* */ +/* 88 */ if (v <= 0) +/* 89 */ return; +/* 90 */ this.loadDist = v; +/* 91 */ if (this.unloadDist <= this.loadDist) { +/* 92 */ this.unloadDist = (v + 1); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void setUnloadDist(int v) +/* */ { +/* 106 */ assert (v > 1); +/* */ +/* 108 */ if (v <= this.loadDist) { +/* 109 */ this.unloadDist = (this.loadDist + 1); +/* */ } else { +/* 111 */ this.unloadDist = v; +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public Persister trigger(Event e, Persister seqID) +/* */ { +/* 120 */ if (this.state == null) { +/* 121 */ return null; +/* */ } +/* 123 */ if (e != null) { +/* 124 */ this.state.setDist(0, e.time); +/* */ } else { +/* 126 */ this.state.setDist(0, Std.getFastTime()); +/* */ } +/* 128 */ return null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void handleDist(int dist, int time) +/* */ { +/* 152 */ assert (this.loadDist < this.unloadDist); +/* */ +/* 154 */ if (!(getOwner() instanceof Portal)) { +/* 155 */ return; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* 161 */ if (dist <= this.loadDist) +/* */ { +/* 163 */ ((Portal)getOwner()).triggerLoad(); +/* 164 */ if (((Portal)getOwner()).active()) { +/* 165 */ informOtherSide(dist + 1, time); +/* */ } else +/* 167 */ new DPLoadTracker(this, dist + 1, time); +/* 168 */ } else if (dist > this.unloadDist) +/* */ { +/* 170 */ ((Portal)getOwner()).reset(); +/* 171 */ } else if (((Portal)getOwner()).active()) { +/* 172 */ informOtherSide(dist + 1, time); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ void informOtherSide(int distance, int triggerTime) +/* */ { +/* 189 */ DPState s = null; +/* 190 */ Portal p = ((Portal)getOwner()).farSide(); +/* 191 */ Enumeration<Action> e = p.getActions(); +/* 192 */ while (e.hasMoreElements()) { +/* 193 */ Object a = e.nextElement(); +/* 194 */ if ((a instanceof DPAction)) { +/* 195 */ s = ((DPAction)a).getState(); +/* 196 */ assert (s != null); +/* */ } +/* */ } +/* */ +/* */ +/* 201 */ if (s != null) +/* */ { +/* */ +/* 204 */ s.setDist(distance, triggerTime); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected void noteAddingTo(SuperRoot owner) +/* */ { +/* 217 */ super.noteAddingTo(owner); +/* */ +/* */ +/* 220 */ if (this.state != null) { +/* 221 */ return; +/* */ } +/* */ +/* 224 */ if (!(owner instanceof Portal)) { +/* 225 */ return; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 235 */ World w = owner.getWorld(); +/* 236 */ if (w != null) { +/* 237 */ this.state = findState(w); +/* */ } +/* */ +/* */ +/* 241 */ if (this.state == null) { +/* 242 */ this.state = new DPState(60000, this); +/* */ } else { +/* 244 */ this.state.addConnection(this); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected DPState findState(SuperRoot root) +/* */ { +/* 255 */ DPState rVal = null; +/* */ +/* 257 */ Enumeration<Object> e = root.getDeepOwned(); +/* 258 */ while ((e.hasMoreElements()) && (rVal == null)) { +/* 259 */ SuperRoot sr = (SuperRoot)e.nextElement(); +/* 260 */ if ((sr instanceof DPAction)) { +/* 261 */ rVal = ((DPAction)sr).getState(); +/* */ } +/* */ } +/* 264 */ return rVal; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public DPState getState() +/* */ { +/* 273 */ return this.state; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void detach() +/* */ { +/* 282 */ if (this.state != null) { +/* 283 */ this.state.dropConnection(this); +/* 284 */ this.state = null; +/* */ } +/* */ +/* 287 */ super.detach(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public Object properties(int index, int offset, int mode, Object value) +/* */ throws NoSuchPropertyException +/* */ { +/* 297 */ Object ret = null; +/* 298 */ switch (index - offset) { +/* */ case 0: +/* 300 */ if (mode == 0) { +/* 301 */ ret = IntegerPropertyEditor.make( +/* 302 */ new Property(this, index, "Load Distance")); +/* 303 */ } else if (mode == 1) { +/* 304 */ ret = new Integer(this.loadDist); +/* 305 */ } else if (mode == 2) +/* 306 */ setLoadDist(((Integer)value).intValue()); +/* 307 */ break; +/* */ case 1: +/* 309 */ if (mode == 0) { +/* 310 */ ret = IntegerPropertyEditor.make( +/* 311 */ new Property(this, index, "Unload Distance")); +/* 312 */ } else if (mode == 1) { +/* 313 */ ret = new Integer(this.unloadDist); +/* 314 */ } else if (mode == 2) +/* 315 */ setUnloadDist(((Integer)value).intValue()); +/* 316 */ break; +/* */ case 2: +/* 318 */ if (mode == 0) { +/* 319 */ ret = new Property(this, index, "Cell State"); +/* 320 */ } else if (mode == 1) +/* 321 */ ret = this.state; +/* 322 */ break; +/* */ default: +/* 324 */ ret = super.properties(index, offset + 3, mode, value); +/* */ } +/* 326 */ return ret; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* 333 */ private static Object classCookie = new Object(); +/* */ +/* */ public void saveState(Saver s) throws IOException +/* */ { +/* 337 */ s.saveVersion(2, classCookie); +/* 338 */ super.saveState(s); +/* 339 */ s.saveInt(this.loadDist); +/* 340 */ s.saveInt(this.unloadDist); +/* 341 */ s.saveMaybeNull(this.state); +/* */ } +/* */ +/* */ public void restoreState(Restorer r) throws IOException, TooNewException +/* */ { +/* 346 */ switch (r.restoreVersion(classCookie)) { +/* */ case 0: +/* 348 */ super.restoreState(r); +/* 349 */ this.loadDist = r.restoreInt(); +/* 350 */ this.unloadDist = r.restoreInt(); +/* 351 */ this.state = ((DPState)r.restore()); +/* 352 */ r.restoreInt(); +/* 353 */ break; +/* */ case 1: +/* 355 */ super.restoreState(r); +/* 356 */ this.loadDist = r.restoreInt(); +/* 357 */ this.unloadDist = r.restoreInt(); +/* 358 */ this.state = ((DPState)r.restore()); +/* 359 */ break; +/* */ case 2: +/* 361 */ super.restoreState(r); +/* 362 */ this.loadDist = r.restoreInt(); +/* 363 */ this.unloadDist = r.restoreInt(); +/* 364 */ this.state = ((DPState)r.restoreMaybeNull()); +/* 365 */ break; +/* */ default: +/* 367 */ throw new TooNewException(); +/* */ } +/* */ +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public String toString() +/* */ { +/* 377 */ return +/* 378 */ super.toString() + "[" + getOwner().getWorld().getName() + "|" + getOwner().getName() + "]"; +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\DPAction.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |