/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.Main; /* */ import NET.worlds.console.MainCallback; /* */ import NET.worlds.network.NetUpdate; /* */ import NET.worlds.network.URL; /* */ import java.awt.Color; /* */ import java.io.IOException; /* */ import java.io.PrintStream; /* */ import java.text.MessageFormat; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class Portal /* */ extends Rect /* */ implements BumpHandler, Prerenderable, Postrenderable, Properties, Persister, LoadedURLSelf /* */ { /* */ static final int UNCONNECTED = -1; /* */ static final int INITIAL = 0; /* */ static final int DOWNLOADING = 1; /* */ static final int DONE = 2; /* 186 */ private int _state = -1; /* */ /* */ /* 189 */ private Portal _farSidePortal = null; /* */ /* */ /* 192 */ String _farSidePortalName = null; /* */ /* */ /* 195 */ private boolean _farSideIsPortal = true; /* */ /* 197 */ private boolean _allowDownload = true; /* */ /* */ /* */ /* */ /* */ /* 203 */ String _farSideRoomName = null; /* */ /* */ /* */ /* */ /* */ /* */ /* 210 */ private URL _farSideWorld = null; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 219 */ private Room _farSideRoom = null; /* */ /* 221 */ protected Room getFarSideRoom() { return this._farSideRoom; } /* */ /* */ /* */ /* */ private float _farx; /* */ /* */ /* */ private float _fary; /* */ /* */ /* */ private float _farz; /* */ /* */ /* */ private float _fartheta; /* */ /* */ /* */ private float _userFarx; /* */ /* */ /* */ private float _userFary; /* */ /* */ private float _userFarz; /* */ /* */ private float _userFartheta; /* */ /* */ private boolean frozeFrameEvents; /* */ /* */ public Portal(float w, float h) /* */ { /* 250 */ super(w, h, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Portal(float llx, float lly, float llz, float urx, float ury, float urz) /* */ { /* 261 */ super(llx, lly, llz, urx, ury, urz, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void setFarSideInfo(URL world, String room, String portal) /* */ { /* 275 */ this._farSideWorld = world; /* 276 */ this._farSideRoomName = room; /* 277 */ this._farSidePortalName = portal; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Portal(Point3Temp llc, Point3Temp urc) /* */ { /* 286 */ super(llc, urc, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static Portal findByName(Room r, String portalName) /* */ { /* 296 */ SuperRoot sr = SuperRoot.nameSearch( /* 297 */ r.getDeepOwned(), /* 298 */ portalName); /* 299 */ if ((sr != null) && ((sr instanceof Portal))) /* 300 */ return (Portal)sr; /* 301 */ return null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Portal connectTo(Portal far) /* */ { /* 311 */ assert (this._state == -1); /* 312 */ this._farSideIsPortal = true; /* 313 */ this._farSidePortal = far; /* 314 */ newFarSide(); /* 315 */ return this; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Portal connectTo(URL farworld, String farroom, Point3Temp llc, Point3Temp urc) /* */ { /* 327 */ return connectTo(farworld, farroom, llc.x, llc.y, llc.z, /* 328 */ urc.x, urc.y, urc.z); /* */ } /* */ /* */ /* */ public Portal connectTo(Room r, Point3Temp llc, Point3Temp urc) /* */ { /* 334 */ System.out.println("Warning! Old style Portal.connectTo called!"); /* 335 */ Thread.dumpStack(); /* */ /* 337 */ assert (this._state == -1); /* 338 */ this._farSideWorld = r.getWorld().getSourceURL(); /* 339 */ this._farSideRoomName = r.getName(); /* 340 */ setFarSideRoom(r); /* 341 */ this._farx = (this._userFarx = urc.x); /* 342 */ this._fary = (this._userFary = urc.y); /* 343 */ this._farz = (this._userFarz = llc.z); /* 344 */ this._userFartheta = /* 345 */ ((float)(Math.atan2(llc.y - urc.y, llc.x - urc.x) * 180.0D / 3.141592653589793D)); /* 346 */ this._fartheta = this._userFartheta; /* 347 */ this._state = 2; /* 348 */ this._farSideIsPortal = false; /* */ /* 350 */ setTransform(); /* 351 */ updateVisible(); /* 352 */ return this; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Portal connectTo(URL farworld, String farroom, float llx, float lly, float llz, float urx, float ury, float urz) /* */ { /* 365 */ float theta = (float)(Math.atan2(lly - ury, llx - urx) * 180.0D / 3.141592653589793D); /* 366 */ return connectTo(farworld, farroom, urx, ury, llz, theta); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Portal connectTo(URL farworld, String farroom, float x, float y, float z, float theta) /* */ { /* 384 */ assert (this._state == -1); /* 385 */ this._farSideWorld = farworld; /* 386 */ this._farSideRoomName = farroom; /* 387 */ this._farx = (this._userFarx = x); /* 388 */ this._fary = (this._userFary = y); /* 389 */ this._farz = (this._userFarz = z); /* 390 */ this._fartheta = (this._userFartheta = theta); /* 391 */ this._farSideIsPortal = false; /* 392 */ reset(); /* 393 */ return this; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Portal remotify() /* */ { /* 403 */ RPAction rpa = new RPAction(); /* 404 */ addAction(rpa); /* 405 */ addHandler(new SameRoomSensor(rpa)); /* 406 */ return this; /* */ } /* */ /* */ /* */ /* */ /* */ private void findFarSidePortal(boolean showmessage) /* */ { /* 414 */ if (this._farSideIsPortal) { /* 415 */ if (this._farSidePortalName == null) { /* 416 */ this._state = -1; /* */ } else { /* 418 */ this._farSidePortal = null; /* */ /* 420 */ Vector portals = this._farSideRoom.getOutgoingPortals(); /* 421 */ int len = portals.size(); /* 422 */ for (int i = 0; i < len; i++) { /* 423 */ Portal p = (Portal)portals.elementAt(i); /* 424 */ if (p.getName().equals(this._farSidePortalName)) { /* 425 */ this._farSidePortal = p; /* 426 */ break; /* */ } /* */ } /* */ /* 430 */ if (this._farSidePortal == null) { /* 431 */ if (showmessage) { /* 432 */ Object[] arguments = { new String(getName()), /* 433 */ new String(this._farSideWorld), /* 434 */ new String(this._farSideRoomName), /* 435 */ new String(this._farSidePortalName) }; /* 436 */ Console.println(MessageFormat.format( /* 437 */ Console.message("Portal-doesnt"), arguments)); /* */ } /* 439 */ this._state = -1; /* */ } /* */ } /* */ /* 443 */ if (this._farSidePortal != null) /* 444 */ newFarSide(); /* */ } else { /* 446 */ this._farSidePortal = null; /* 447 */ this._farx = this._userFarx; /* 448 */ this._fary = this._userFary; /* 449 */ this._farz = this._userFarz; /* 450 */ this._fartheta = this._userFartheta; /* 451 */ this._p2pxform = null; /* */ } /* */ } /* */ /* */ /* */ public void reset() /* */ { /* 458 */ reset(true); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void reset(boolean showmessage) /* */ { /* 477 */ setFarSideRoom(null); /* 478 */ if ((this._farSideRoomName != null) && ((this.flags & 0x40000) == 0)) { /* 479 */ if (this._farSideWorld == null) { /* 480 */ Room r = getRoom(); /* 481 */ if (r != null) { /* 482 */ World w = r.getWorld(); /* 483 */ if (w != null) { /* 484 */ setFarSideRoom(w.getRoom(this._farSideRoomName)); /* */ } /* */ } /* 487 */ if (this._farSideRoom != null) { /* 488 */ findFarSidePortal(showmessage); /* */ } else { /* 490 */ this._state = -1; /* 491 */ this._farSidePortal = null; /* 492 */ if (showmessage) { /* 493 */ Object[] arguments = { new String(getName()), /* 494 */ new String(getRoom()), /* 495 */ new String(this._farSideRoomName), /* 496 */ new String(this._farSidePortalName) }; /* 497 */ Console.println(MessageFormat.format( /* 498 */ Console.message("Room-doesnt"), arguments)); /* */ } /* */ } /* */ } /* */ else { /* 503 */ if (this._farSidePortalName == null) /* 504 */ this._farSidePortal = null; /* 505 */ this._state = 0; /* */ } /* */ } /* */ else { /* 509 */ this._state = -1; /* */ } /* 511 */ setTransform(); /* 512 */ updateVisible(); /* */ } /* */ /* */ public void discard() { /* 516 */ Portal far = this._farSidePortal; /* 517 */ setFarSideRoom(null); /* */ /* */ /* 520 */ this._state = 0; /* */ /* 522 */ super.discard(); /* */ /* 524 */ if ((far != null) && (far.getRoom() != null) && (this._farSideWorld != null)) { /* 525 */ far.reset(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private void recomputeFarPosition() /* */ { /* 535 */ setFarSideRoom(this._farSidePortal.getRoom()); /* 536 */ if (this._farSideRoom != null) /* 537 */ this._farSideRoomName = this._farSideRoom.getName(); /* 538 */ this._farSidePortalName = this._farSidePortal.getName(); /* 539 */ Point3Temp farext = Point3Temp.make(1.0F, 0.0F, 1.0F) /* 540 */ .vectorTimes(this._farSidePortal); /* 541 */ Point3Temp farlrc = this._farSidePortal.getPosition(); /* 542 */ if ((this.flags & 0x4) == 0) { /* 543 */ farlrc.x += farext.x; /* 544 */ farlrc.y += farext.y; /* */ } /* */ /* 547 */ this._farx = farlrc.x; /* 548 */ this._fary = farlrc.y; /* 549 */ this._farz = farlrc.z; /* */ /* */ /* */ /* 553 */ this._fartheta = ((-this._farSidePortal.getYaw() + 180.0F) % 360.0F); /* */ /* 555 */ this._farChangeNum = this._farSidePortal._changeNum; /* */ /* 557 */ this._p2pxform = null; /* */ } /* */ /* */ /* */ /* */ /* */ public Portal biconnect(Portal far) /* */ { /* 565 */ connectTo(far); /* 566 */ far.connectTo(this); /* 567 */ return this; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void disconnect() /* */ { /* 576 */ this._farSideWorld = null; /* 577 */ this._farSideRoomName = null; /* 578 */ setFarSideRoom(null); /* 579 */ this._farSidePortal = null; /* 580 */ this._farSideIsPortal = true; /* 581 */ this._farSidePortalName = null; /* 582 */ this._state = -1; /* 583 */ updateVisible(); /* 584 */ discardTransform(); /* */ } /* */ /* */ /* */ public void bidisconnect() /* */ { /* 590 */ this._farSidePortal.disconnect(); /* 591 */ disconnect(); /* */ } /* */ /* */ /* */ public boolean connected() /* */ { /* 597 */ return (this._farSidePortal != null) || ( /* 598 */ (this._farSideRoomName != null) && (!this._farSideIsPortal)); /* */ } /* */ /* */ public boolean active() /* */ { /* 603 */ return this._state == 2; /* */ } /* */ /* */ public boolean unconnected() /* */ { /* 608 */ return this._state == -1; /* */ } /* */ /* */ /* */ /* */ /* */ public boolean remote() /* */ { /* 616 */ return this._farSideWorld != null; /* */ } /* */ /* */ public Portal farSide() /* */ { /* 621 */ return this._farSideIsPortal ? this._farSidePortal : null; /* */ } /* */ /* */ public Room farSideRoom() /* */ { /* 626 */ return this._farSideRoom; /* */ } /* */ /* */ /* */ /* */ /* 632 */ private void setFarSideRoom(Room far) { this._farSideRoom = far; } /* */ /* */ protected void noteAddingTo(SuperRoot s) { /* 635 */ addToRoom(s); /* 636 */ super.noteAddingTo(s); /* */ } /* */ /* */ /* */ /* */ /* */ private void addToRoom(SuperRoot s) /* */ { /* 644 */ if ((s instanceof WObject)) { /* 645 */ Room r = ((WObject)s).getRoom(); /* 646 */ if (r != null) /* 647 */ r.addOutgoingPortal(this); /* */ } /* */ } /* */ /* */ public void detach() { /* 652 */ Room r = getRoom(); /* 653 */ if (r != null) /* 654 */ r.removeOutgoingPortal(this); /* 655 */ super.detach(); /* */ } /* */ /* */ public String farRoom() /* */ { /* 660 */ return this._farSideRoomName; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public URL farWorld() /* */ { /* 669 */ return this._farSideWorld; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Transform p2pXform() /* */ { /* 682 */ return this._p2pxform; /* */ } /* */ /* */ /* */ /* */ /* */ /* 689 */ private Transform _p2pxform = null; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected void addRwChildren(WObject parent) /* */ { /* 700 */ if ((this._farSidePortal != null) && ((this._farSidePortal instanceof TwoWayPortal)) && /* 701 */ (!this._farSidePortal.isActive())) /* */ { /* */ /* */ /* 705 */ Main.register(new MainCallback() { /* */ public void mainCallback() { /* 707 */ Portal.this.detach(); /* 708 */ Main.unregister(this); /* */ } /* */ }); /* */ } /* */ /* 713 */ super.addRwChildren(parent); /* */ /* 715 */ updateVisible(); /* 716 */ setTransform(); /* */ /* */ /* 719 */ getRoom().prependPrerenderHandler(this); /* 720 */ getRoom().prependPostrenderHandler(this); /* */ } /* */ /* */ /* */ protected void markVoid() /* */ { /* 726 */ getRoom().removePrerenderHandler(this); /* 727 */ getRoom().removePostrenderHandler(this); /* */ /* 729 */ super.markVoid(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 738 */ private int _changeNum = 0; /* 739 */ private int _farChangeNum = -1; /* */ /* */ static BumpCalc standardPassthroughBumpCalc; /* */ /* */ /* */ protected void noteTransformChange() /* */ { /* 746 */ this._changeNum += 1; /* 747 */ super.noteTransformChange(); /* 748 */ discardTransform(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void discardTransform() /* */ { /* 772 */ if (this._p2pxform != null) /* */ { /* 774 */ this._p2pxform = null; /* 775 */ if (this._farSidePortal != null) { /* 776 */ this._farSidePortal.discardTransform(); /* */ } /* */ } /* */ } /* */ /* */ static /* */ { /* 753 */ nativeInit(); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 791 */ standardPassthroughBumpCalc = new PassthroughBumpCalc(); /* */ /* */ /* 794 */ standardPassthroughBumpCalc.setName("defaultPassthroughBumpCalc"); /* */ } /* */ /* */ /* */ public BumpCalc getBumpCalc(BumpEventTemp b) /* */ { /* 800 */ if ((this._farSidePortal != null) && /* 801 */ ((b.source instanceof Camera)) && ( /* 802 */ ((this.flags & 0x4) != 0) || /* 803 */ (!this._farSidePortal.active()) || /* 804 */ (this._farSidePortal._p2pxform == null) || /* 805 */ (!this._farSidePortal.getVisible()))) { /* 806 */ return super.getBumpCalc(b); /* */ } /* 808 */ if (this.bumpCalc == null) { /* 809 */ if (this._farSideRoomName == null) { /* 810 */ return standardPassthroughBumpCalc; /* */ } /* 812 */ if ((connected()) && ((this.flags & 0x40000) == 0)) { /* 813 */ if ((this._farSideRoom == null) && /* 814 */ (this._farSideIsPortal) && /* 815 */ (this._farSidePortal != null)) { /* 816 */ setFarSideRoom(this._farSidePortal.getRoom()); /* */ } /* 818 */ if ((this._farSideRoom != null) && (this._farSideRoom.isActive())) { /* 819 */ return standardPassthroughBumpCalc; /* */ } /* */ } /* 822 */ return super.getBumpCalc(b); /* */ } /* */ /* 825 */ return this.bumpCalc; /* */ } /* */ /* */ /* */ /* */ public boolean handle(BumpEventTemp b) /* */ { /* 832 */ if ((this._farSidePortal != null) && /* 833 */ ((b.source instanceof Camera)) && ( /* 834 */ ((this.flags & 0x4) != 0) || /* 835 */ (!this._farSidePortal.active()) || /* 836 */ (this._farSidePortal._p2pxform == null) || /* 837 */ (!this._farSidePortal.getVisible()))) { /* 838 */ return true; /* */ } /* 840 */ portalBumpHandler(b); /* 841 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void portalBumpHandler(BumpEventTemp b) /* */ { /* 851 */ if ((b.target != this) || (this._state != 2)) { /* 852 */ if ((this._state == 1) && (this._farSideWorld != null) && /* 853 */ (!this._farSideWorld.isRemote()) && (!this.frozeFrameEvents)) { /* 854 */ this.frozeFrameEvents = true; /* 855 */ Console.setFreezeFrameEvents(true); /* */ } /* */ /* 858 */ return; /* */ } /* */ /* */ /* 862 */ if ((this._farSideRoom == null) && /* 863 */ (this._farSideIsPortal) && (this._farSidePortal != null)) /* 864 */ setFarSideRoom(this._farSidePortal.getRoom()); /* 865 */ if ((this._farSideRoom == null) || (!this._farSideRoom.isActive())) { /* 866 */ return; /* */ } /* */ /* */ /* 870 */ if (this._p2pxform == null) { /* 871 */ setTransform(); /* 872 */ if (this._p2pxform == null) { /* 873 */ return; /* */ } /* */ } /* */ /* 877 */ b.postBumpRoom = this._farSideRoom; /* */ /* 879 */ Transform t = ((WObject)b.source).getObjectToWorldMatrix(); /* 880 */ b.postBumpPosition.setTransform(t); /* 881 */ t.recycle(); /* 882 */ b.postBumpPosition.moveBy(b.path).post(this._p2pxform); /* */ /* */ /* 885 */ b.postBumpPath = new Point3(b.fullPath).times(1.0F - b.fraction) /* 886 */ .vectorTimes(this._p2pxform); /* */ } /* */ /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 895 */ Object ret = null; /* 896 */ switch (index - offset) { /* */ case 0: /* 898 */ if (mode == 0) { /* 899 */ ret = URLPropertyEditor.make(new Property(this, index, /* 900 */ "Destination World URL (null means this world)") /* 901 */ .allowSetNull(), /* 902 */ "world"); /* 903 */ } else if (mode == 1) { /* 904 */ ret = this._farSideWorld; /* 905 */ } else if (mode == 2) { /* 906 */ this._farSideWorld = ((URL)value); /* */ /* 908 */ reset(); /* 909 */ triggerLoad(); /* */ } /* 911 */ break; /* */ case 1: /* 913 */ if (mode == 0) { /* 914 */ ret = StringPropertyEditor.make(new Property(this, index, /* 915 */ "Destination Room Name").allowSetNull()); /* 916 */ } else if (mode == 1) { /* 917 */ ret = this._farSideRoomName == null ? "" : this._farSideRoomName; /* 918 */ } else if (mode == 2) { /* 919 */ this._farSideRoomName = ((String)value); /* 920 */ if ("".equals(this._farSideRoomName)) /* 921 */ this._farSideRoomName = null; /* 922 */ reset(); /* 923 */ triggerLoad(); /* */ } /* 925 */ break; /* */ case 2: /* 927 */ if (mode == 0) { /* 928 */ ret = BooleanPropertyEditor.make( /* 929 */ new Property(this, index, /* 930 */ "Connect to a portal"), /* 931 */ "Use location and orientation", /* 932 */ "Use portal"); /* */ } /* 934 */ else if (mode == 1) { /* 935 */ ret = new Boolean(this._farSideIsPortal); /* 936 */ } else if (mode == 2) { /* 937 */ boolean tmp = ((Boolean)value).booleanValue(); /* 938 */ this._farSideIsPortal = tmp; /* 939 */ reset(); /* 940 */ triggerLoad(); /* */ } /* 942 */ break; /* */ case 3: /* 944 */ if (mode == 0) { /* 945 */ ret = BooleanPropertyEditor.make( /* 946 */ new Property(this, index, /* 947 */ "Download if world not present"), /* 948 */ "Never download", /* 949 */ "Allow download"); /* */ } /* 951 */ else if (mode == 1) { /* 952 */ ret = new Boolean(this._allowDownload); /* 953 */ } else if (mode == 2) { /* 954 */ boolean tmp = ((Boolean)value).booleanValue(); /* 955 */ this._allowDownload = tmp; /* */ } /* 957 */ break; /* */ case 4: /* 959 */ if (mode == 0) { /* 960 */ ret = new Property(this, index, "Destination Portal Name"); /* 961 */ if (this._farSideIsPortal) { /* 962 */ ret = StringPropertyEditor.make((Property)ret); /* */ } /* 964 */ } else if (mode == 1) { /* 965 */ ret = this._farSidePortalName == null ? "" : this._farSidePortalName; /* 966 */ } else if (mode == 2) { /* 967 */ this._farSidePortalName = ((String)value); /* 968 */ if ("".equals(this._farSidePortalName)) /* 969 */ this._farSidePortalName = null; /* 970 */ reset(); /* 971 */ triggerLoad(); /* */ } /* 973 */ break; /* */ case 5: /* 975 */ if (mode == 0) { /* 976 */ ret = new Property(this, index, "Destination position"); /* 977 */ if (!this._farSideIsPortal) { /* 978 */ ret = Point3PropertyEditor.make((Property)ret); /* */ } /* 980 */ } else if (mode == 1) { /* 981 */ ret = new Point3(this._userFarx, this._userFary, this._userFarz); /* 982 */ } else if (mode == 2) { /* 983 */ Point3 p = (Point3)value; /* 984 */ this._farx = (this._userFarx = p.x); /* 985 */ this._fary = (this._userFary = p.y); /* 986 */ this._farz = (this._userFarz = p.z); /* 987 */ reset(); /* 988 */ triggerLoad(); /* */ } /* 990 */ break; /* */ case 6: /* 992 */ if (mode == 0) { /* 993 */ ret = new Property(this, index, /* 994 */ "Destination orientation (degrees, clockwise from North)"); /* 995 */ if (!this._farSideIsPortal) { /* 996 */ ret = FloatPropertyEditor.make((Property)ret, 0.0F, 360.0F); /* */ } /* 998 */ } else if (mode == 1) { /* 999 */ ret = new Float(this._userFartheta); /* 1000 */ } else if (mode == 2) { /* 1001 */ this._fartheta = (this._userFartheta = ((Float)value).floatValue()); /* 1002 */ reset(); /* 1003 */ triggerLoad(); /* */ } /* 1005 */ break; /* */ case 7: /* 1007 */ if (mode == 0) { /* 1008 */ ret = BooleanPropertyEditor.make( /* 1009 */ new Property(this, index, /* 1010 */ "Mirrored"), /* 1011 */ "Normal", /* 1012 */ "Mirrored"); /* */ } /* 1014 */ else if (mode == 1) { /* 1015 */ ret = new Boolean((this.flags & 0x4) != 0); /* 1016 */ } else if (mode == 2) { /* 1017 */ if (((Boolean)value).booleanValue()) { /* 1018 */ this.flags |= 0x4; /* */ } else /* 1020 */ this.flags &= 0xFFFFFFFB; /* 1021 */ reset(); /* 1022 */ triggerLoad(); /* */ } /* 1024 */ break; /* */ default: /* 1026 */ ret = super.properties(index, offset + 8, mode, value); /* */ } /* 1028 */ return ret; /* */ } /* */ /* */ /* */ private void newFarSide() /* */ { /* 1034 */ this._farSidePortalName = this._farSidePortal.getName(); /* 1035 */ if ((this._state == -1) && ((this.flags & 0x40000) == 0)) { /* 1036 */ this._state = 2; /* */ } /* 1038 */ recomputeFarPosition(); /* 1039 */ setTransform(); /* 1040 */ updateVisible(); /* */ } /* */ /* 1043 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 1047 */ Portal tmp = null; /* 1048 */ if ((this._farSideWorld != null) || ( /* 1049 */ (this._farSidePortal != null) && ((!this._farSidePortal.isActive()) || /* 1050 */ ((this._farSidePortal instanceof NonPersister))))) /* */ { /* 1052 */ tmp = this._farSidePortal; /* 1053 */ this._farSidePortal = null; /* */ } /* 1055 */ s.saveVersion(9, classCookie); /* 1056 */ super.saveState(s); /* 1057 */ s.saveBoolean(this._farSideIsPortal); /* 1058 */ s.saveBoolean(this._allowDownload); /* 1059 */ s.saveString(this._farSidePortalName); /* 1060 */ s.saveMaybeNull(this._farSidePortal); /* 1061 */ URL.save(s, this._farSideWorld); /* 1062 */ s.saveString(this._farSideRoomName); /* 1063 */ s.saveFloat(this._userFarx); /* 1064 */ s.saveFloat(this._userFary); /* 1065 */ s.saveFloat(this._userFarz); /* 1066 */ s.saveFloat(this._userFartheta); /* 1067 */ if (tmp != null) { /* 1068 */ this._farSidePortal = tmp; /* */ } /* */ } /* */ /* */ /* */ /* */ public void superRestoreState(Restorer r) /* */ throws IOException, TooNewException /* */ { /* 1077 */ restoreWObjectState(r); /* 1078 */ setMaterial(new Material(Color.black)); /* */ } /* */ /* */ public void restoreState(Restorer r) /* */ throws IOException, TooNewException /* */ { /* 1084 */ float x = 0.0F;float y = 0.0F;float z = 0.0F; /* 1085 */ int vers = r.restoreVersion(classCookie); /* 1086 */ switch (vers) { /* */ case 0: /* */ case 1: /* */ case 2: /* */ case 3: /* */ case 4: /* */ case 5: /* */ case 6: /* */ case 7: /* 1095 */ r.setOldFlag(); /* 1096 */ superRestoreState(r); /* */ /* 1098 */ if (vers < 6) { /* 1099 */ if (vers == 0) /* 1100 */ r.restoreInt(); /* 1101 */ x = r.restoreFloat(); /* 1102 */ y = r.restoreFloat(); /* 1103 */ z = r.restoreFloat(); /* 1104 */ scale(x, 1.0F, z); /* */ } /* */ /* 1107 */ if (r.restoreBoolean()) { /* 1108 */ this.flags |= 0x4; /* */ } /* 1110 */ if (vers >= 4) /* 1111 */ this._farSidePortalName = r.restoreString(); /* 1112 */ this._farSidePortal = ((Portal)r.restoreMaybeNull()); /* */ /* 1114 */ if (vers == 1) { /* 1115 */ String n = r.restoreString(); /* 1116 */ if (!"".equals(n)) /* 1117 */ setName(n); /* 1118 */ } else if (vers >= 3) { /* 1119 */ if (vers >= 7) { /* 1120 */ this._farSideWorld = URL.restore(r); /* */ } else /* 1122 */ this._farSideWorld = URL.restore(r, ".world"); /* 1123 */ this._farSideRoomName = r.restoreString(); /* 1124 */ this._farx = r.restoreFloat(); /* 1125 */ this._fary = r.restoreFloat(); /* 1126 */ this._farz = r.restoreFloat(); /* 1127 */ this._fartheta = r.restoreFloat(); /* */ /* 1129 */ Material initialCover = Material.restore(r); /* 1130 */ Material downloadCover = Material.restore(r); /* 1131 */ if (initialCover != null) { /* 1132 */ setMaterial(initialCover); /* */ /* 1134 */ if ((downloadCover != null) && ( /* 1135 */ (initialCover.textureName == null) || /* */ /* 1137 */ (!initialCover.textureName.equals(downloadCover.textureName)))) { /* 1138 */ System.out.println( /* 1139 */ "Both initial and download covers, " + /* 1140 */ initialCover.textureName + " and " + /* 1141 */ downloadCover.textureName + ", in " + /* 1142 */ getName() + " -- using initial."); /* */ } /* */ } else { /* 1145 */ setMaterial(downloadCover); /* */ } /* */ /* 1148 */ if (vers >= 5) /* 1149 */ this._farSideIsPortal = r.restoreBoolean(); /* */ } /* 1151 */ break; /* */ case 8: /* */ case 9: /* 1154 */ super.restoreState(r); /* 1155 */ this._farSideIsPortal = r.restoreBoolean(); /* 1156 */ if (vers >= 9) /* 1157 */ this._allowDownload = r.restoreBoolean(); /* 1158 */ this._farSidePortalName = r.restoreString(); /* 1159 */ this._farSidePortal = ((Portal)r.restoreMaybeNull()); /* 1160 */ this._farSideWorld = URL.restore(r); /* 1161 */ this._farSideRoomName = r.restoreString(); /* 1162 */ this._farx = r.restoreFloat(); /* 1163 */ this._fary = r.restoreFloat(); /* 1164 */ this._farz = r.restoreFloat(); /* 1165 */ this._fartheta = r.restoreFloat(); /* 1166 */ break; /* */ default: /* 1168 */ throw new TooNewException(); /* */ } /* */ /* 1171 */ if ((vers <= 4) && (this._farSideRoomName != null) && (this._farSidePortal == null) && /* 1172 */ (this._farSidePortalName == null)) /* */ { /* 1174 */ this._farSideIsPortal = false; /* */ } /* */ /* 1177 */ this._userFarx = this._farx; /* 1178 */ this._userFary = this._fary; /* 1179 */ this._userFarz = this._farz; /* 1180 */ this._userFartheta = this._fartheta; /* */ } /* */ /* */ public void postRestore(int version) /* */ { /* 1185 */ super.postRestore(version); /* 1186 */ if (getOwner() == null) /* 1187 */ return; /* 1188 */ addToRoom(getOwner()); /* */ /* 1190 */ if (this._farSidePortal == null) { /* 1191 */ reset(); /* */ } else /* 1193 */ newFarSide(); /* */ } /* */ /* */ public String toString() { /* */ String to; /* */ String to; /* 1199 */ if (this._state == -1) { /* 1200 */ to = "(not connected)"; /* */ } else { String to; /* 1202 */ if (this._farSideWorld != null) { /* 1203 */ to = this._farSideWorld.toString(); /* */ } else /* 1205 */ to = ""; /* 1206 */ if (this._farSideRoom != null) /* 1207 */ to = to + "#" + this._farSideRoomName; /* 1208 */ if (this._farSidePortalName != null) /* 1209 */ to = to + "#" + this._farSidePortalName; /* */ } /* 1211 */ return super.toString() + "[Connected To " + to + "]"; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Portal triggerLoad() /* */ { /* 1220 */ if ((this._farSideWorld != null) && (this._farSideRoomName != null)) /* */ { /* 1222 */ if ((this._farSidePortal != null) && (!this._farSidePortal.isActive())) { /* 1223 */ reset(); /* */ } /* 1225 */ if (this._state == 0) { /* 1226 */ this._state = 1; /* 1227 */ World.load(this._farSideWorld, this); /* */ } /* */ } /* 1230 */ return this; /* */ } /* */ /* */ public void loadedURLSelf(URLSelf o, URL url, String err) /* */ { /* 1235 */ if (this.frozeFrameEvents) { /* 1236 */ this.frozeFrameEvents = false; /* 1237 */ Console.setFreezeFrameEvents(false); /* */ } /* */ /* */ /* */ /* 1242 */ if (this._state != 1) { /* 1243 */ return; /* */ } /* 1245 */ if ((err != null) || (!(o instanceof World))) /* */ { /* 1247 */ if (err == null) /* */ { /* 1249 */ err = "doesn't contain a World"; /* 1250 */ o.decRef(); /* */ } /* */ /* 1253 */ String readable = TeleportAction.getReadableNameOfWorld(url); /* 1254 */ this._state = -1; /* */ /* 1256 */ if ((this._allowDownload) && (!World.isProscribed(url, false))) { /* 1257 */ Object[] arguments = { new String(readable) }; /* 1258 */ Console.println(MessageFormat.format( /* 1259 */ Console.message("Dont-have-world"), arguments)); /* */ /* 1261 */ String packageName = TeleportAction.getPackageNameOfWorld(url); /* */ /* */ /* */ /* 1265 */ if (packageName != null) { /* 1266 */ NetUpdate.loadWorld(packageName, false); /* */ } /* */ } /* */ } else { /* 1270 */ World w = (World)o; /* 1271 */ setFarSideRoom(w.getRoom(this._farSideRoomName)); /* 1272 */ if (this._farSideRoom != null) { /* 1273 */ this._state = 2; /* 1274 */ findFarSidePortal(true); /* */ } else { /* 1276 */ Object[] arguments = { new String(this._farSideRoomName), /* 1277 */ new String(this._farSideWorld) }; /* 1278 */ Console.println(MessageFormat.format( /* 1279 */ Console.message("Cant-find-remote"), arguments)); /* 1280 */ this._state = -1; /* */ } /* */ } /* */ /* 1284 */ updateVisible(); /* */ } /* */ /* */ public Portal() {} /* */ /* */ public static native void nativeInit(); /* */ /* */ protected native void updateVisible(); /* */ /* */ native void setTransform(); /* */ /* */ public native void prerender(Camera paramCamera); /* */ /* */ public native void postrender(Camera paramCamera); /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Portal.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */