/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.Main; /* */ import NET.worlds.core.Std; /* */ import NET.worlds.network.Galaxy; /* */ import NET.worlds.network.NetworkRoom; /* */ import NET.worlds.network.URL; /* */ import java.awt.Color; /* */ import java.io.IOException; /* */ import java.io.PrintStream; /* */ import java.util.Enumeration; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class Room /* */ extends WObject /* */ implements TeleportStatus /* */ { /* */ public WObject highlightTarget; /* */ private int sceneID; /* */ /* */ public Room(World world, String name) /* */ { /* 203 */ setName(name); /* */ /* 205 */ this.environment = new RoomEnvironment(); /* 206 */ this.infiniteBackground = new RoomEnvironment(); /* 207 */ super.add(this.environment); /* 208 */ super.add(this.infiniteBackground); /* */ /* 210 */ if (world != null) { /* 211 */ world.addRoom(this); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ static /* */ { /* 222 */ nativeInit(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void getChildren(DeepEnumeration d) /* */ { /* 238 */ if (this.infiniteBackground != null) /* 239 */ d.addChildElement(this.infiniteBackground); /* 240 */ if (this.environment != null) /* 241 */ d.addChildElement(this.environment); /* 242 */ super.getChildren(d); /* */ } /* */ /* */ /* */ public void setName(String newName) /* */ { /* 248 */ String oldName = getName(); /* 249 */ super.setName(newName); /* 250 */ World world = getWorld(); /* 251 */ if (world != null) /* 252 */ world.renameRoom(oldName, getName(), this); /* 253 */ if (oldName.equals(newName)) /* 254 */ return; /* 255 */ synchronized (this) /* */ { /* 257 */ if (this._netRoom != null) { /* 258 */ this._netRoom.setName(newName); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ synchronized void register() /* */ { /* 267 */ assert (this._netRoom == null); /* 268 */ this._netRoom = new NetworkRoom(this); /* */ } /* */ /* */ /* */ /* */ /* */ public void detach() /* */ { /* 276 */ if (hasClump()) { /* 277 */ System.out.println("Detaching clumped room " + getName()); /* 278 */ markVoid(); /* */ } /* */ /* */ /* */ /* */ /* */ /* 285 */ assert (this._netRoom != null); /* 286 */ boolean subscribed = Pilot.getActive().removeSubscribedRoom(this); /* 287 */ if (subscribed) { /* 288 */ this._netRoom.unsubscribe(); /* */ } /* */ /* */ /* 292 */ synchronized (this) { /* 293 */ this._netRoom.detach(); /* 294 */ this._netRoom = null; /* */ } /* */ /* */ /* 298 */ getWorld().removeRoom(this); /* */ /* 300 */ super.detach(); /* */ } /* */ /* */ public void discard() /* */ { /* 305 */ this.environment.discard(); /* 306 */ this.infiniteBackground.discard(); /* */ /* 308 */ super.discard(); /* */ /* 310 */ this.frameHandlers.removeAllElements(); /* 311 */ this.frameHandlerWObjects.removeAllElements(); /* 312 */ this.outgoingPortals.removeAllElements(); /* 313 */ this.aFilters.removeAllElements(); /* 314 */ this.prerenderHandlers.removeAllElements(); /* 315 */ this.postrenderHandlers.removeAllElements(); /* */ } /* */ /* */ /* */ int getSceneID() /* */ { /* 321 */ return this.sceneID; /* */ } /* */ /* 324 */ public Point3 defaultPosition = new Point3(100.0F, 100.0F, 120.0F); /* 325 */ public Point3 defaultOrientationAxis = new Point3(0.0F, 0.0F, -1.0F); /* 326 */ public float defaultOrientation = 0.0F; /* */ /* */ public Point3Temp getDefaultPosition() { /* 329 */ return Point3Temp.make(this.defaultPosition); /* */ } /* */ /* */ public Point3Temp getDefaultOrientationAxis() { /* 333 */ return Point3Temp.make(this.defaultOrientationAxis); /* */ } /* */ /* */ public float getDefaultOrientation() { /* 337 */ return this.defaultOrientation; /* */ } /* */ /* 340 */ String teleportChain = "home:avatargallery/avatar.world#AVATARgallery@65.0,145.0,150.0,89.0"; /* */ /* 342 */ int roomLoadTime = 0; /* 343 */ int teleportInterval = -1; /* 344 */ boolean teleported = false; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private RoomEnvironment environment; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public RoomEnvironment getEnvironment() /* */ { /* 362 */ return this.environment; /* */ } /* */ /* */ /* */ /* */ /* */ /* 369 */ private Vector outgoingPortals = new Vector(); /* */ /* */ /* */ /* */ /* */ public Vector getOutgoingPortals() /* */ { /* 376 */ return this.outgoingPortals; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void addOutgoingPortal(Portal p) /* */ { /* 386 */ if (this.outgoingPortals.contains(p)) { /* 387 */ return; /* */ } /* 389 */ this.outgoingPortals.addElement(p); /* */ /* 391 */ for (int index = 0; index < this.aFilters.size(); index++) { /* 392 */ ((AudibilityFilter)this.aFilters.elementAt(index)).moveEmitter(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void removeOutgoingPortal(Portal p) /* */ { /* 402 */ this.outgoingPortals.removeElement(p); /* */ /* 404 */ Vector v = getAFilters(); /* 405 */ for (int v_index = 0; v_index < v.size(); v_index++) { /* 406 */ ((AudibilityFilter)v.elementAt(v_index)).moveEmitter(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 417 */ private Vector aFilters = new Vector(); /* */ /* */ /* */ /* */ /* */ /* */ public Vector getAFilters() /* */ { /* 425 */ return this.aFilters; /* */ } /* */ /* */ /* */ /* */ public void addAFilter(AudibilityFilter p) /* */ { /* 432 */ this.aFilters.addElement(p); /* */ } /* */ /* */ /* */ /* */ public void removeAFilter(AudibilityFilter a) /* */ { /* 439 */ this.aFilters.removeElement(a); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void move(Room from, Room to) /* */ { /* 449 */ Vector v = from.getAFilters(); /* 450 */ for (int index = 0; index < v.size(); index++) { /* 451 */ ((AudibilityFilter)v.elementAt(index)).updateListenerState(); /* */ } /* 453 */ v = to.getAFilters(); /* 454 */ for (int index = 0; index < v.size(); index++) { /* 455 */ ((AudibilityFilter)v.elementAt(index)).updateListenerState(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void setLightPosition(float x, float y, float z) /* */ { /* 480 */ if (this.lightid != 0) /* 481 */ setLightPosition(this.lightid, x, y, z); /* 482 */ if (this.lightid2 != 0) { /* 483 */ setLightPosition(this.lightid2, -x, -y, -z); /* */ } /* */ } /* */ /* */ /* */ /* */ private void setLightColor(float red, float green, float blue) /* */ { /* 491 */ if (this.lightid != 0) /* 492 */ setLightColor(this.lightid, red, green, blue); /* 493 */ if (this.lightid2 != 0) /* 494 */ setLightColor(this.lightid2, red / 2.0F, green / 2.0F, blue / 2.0F); /* */ } /* */ /* 497 */ private Point3 lightPosition = new Point3(-1.0F, 1.0F, -1.0F); /* 498 */ private Color lightColor = new Color(255, 255, 255); /* 499 */ private int lightid = 0; /* 500 */ private int lightid2 = 0; /* */ /* */ private int renderStamp; /* */ /* */ public void setLightPosition(Point3Temp p) /* */ { /* 506 */ this.lightPosition.set(p.x, p.y, p.z); /* 507 */ setLightPosition(p.x, p.y, p.z); /* 508 */ RoomEnvironment re = getEnvironment(); /* 509 */ if (re != null) /* 510 */ re.setLightPosition(p.x, p.y, p.z); /* 511 */ re = getInfiniteBackground(); /* 512 */ if (re != null) { /* 513 */ re.setLightPosition(p.x, p.y, p.z); /* */ } /* */ } /* */ /* */ /* */ public void setLightColor(Color c) /* */ { /* 520 */ this.lightColor = new Color(c.getRGB()); /* */ /* 522 */ float r = c.getRed() / 256.0F; /* 523 */ float g = c.getGreen() / 256.0F; /* 524 */ float b = c.getBlue() / 256.0F; /* */ /* 526 */ setLightColor(r, g, b); /* 527 */ RoomEnvironment re = getEnvironment(); /* 528 */ if (re != null) /* 529 */ re.setLightColor(r, g, b); /* 530 */ re = getInfiniteBackground(); /* 531 */ if (re != null) /* 532 */ re.setLightColor(r, g, b); /* */ } /* */ /* */ public Point3Temp getLightPosition() { /* 536 */ return Point3Temp.make(this.lightPosition); /* */ } /* */ /* */ public Color getLightColor() { /* 540 */ return new Color(this.lightColor.getRGB()); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void noteRef() /* */ { /* 553 */ this.renderStamp = Std.getRealTime(); /* */ /* 555 */ World w = getWorld(); /* 556 */ if (w != null) /* 557 */ w.incRef(); /* */ } /* */ /* 560 */ private static int timeoutAge = 15000; /* */ /* */ /* */ /* */ /* */ public void discardIfOld() /* */ { /* 567 */ if (hasClump()) { /* 568 */ int age = Std.getFastTime() - this.renderStamp; /* 569 */ if (age > timeoutAge) { /* 570 */ markVoid(); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* 580 */ private Vector frameHandlers = new Vector(); /* 581 */ private Vector frameHandlerWObjects = new Vector(); /* */ /* */ private Color skyColor; /* */ /* */ private Color groundColor; /* */ /* */ public void generateFrameEvents(FrameEvent f) /* */ { /* 589 */ noteRef(); /* */ /* 591 */ if (Main.profile != 0) { /* 592 */ for (int i = 0; i < this.frameHandlers.size(); i++) { /* 593 */ FrameHandler fh = (FrameHandler)this.frameHandlers.elementAt(i); /* 594 */ WObject fhw = (WObject)this.frameHandlerWObjects.elementAt(i); /* 595 */ int start = Std.getRealTime(); /* 596 */ long startBytes = Runtime.getRuntime().freeMemory(); /* */ /* 598 */ f.retargetAndDeliver(fh, fhw); /* */ /* 600 */ int dur = Std.getRealTime() - start; /* 601 */ long used = startBytes - Runtime.getRuntime().freeMemory(); /* 602 */ if (dur > Main.profile) { /* 603 */ if ((fh instanceof SuperRoot)) { /* 604 */ System.out.println("Took " + dur + "ms and " + used + /* 605 */ " bytes to call frameHandler " + /* 606 */ ((SuperRoot)fh).getName() + " of " + /* 607 */ fhw.getName()); /* */ } else /* 609 */ System.out.println("Took " + dur + "ms and " + used + /* 610 */ " bytes to call frameHandler " + fh + " of " + /* 611 */ fhw.getName()); /* */ } /* */ } /* */ } else { /* 615 */ for (int i = 0; i < this.frameHandlers.size(); i++) { /* 616 */ f.retargetAndDeliver((FrameHandler)this.frameHandlers.elementAt(i), /* 617 */ (WObject)this.frameHandlerWObjects.elementAt(i)); /* */ } /* */ } /* 620 */ if ((this.teleportChain != null) && (this.teleportInterval != -1) && (!this.teleported) && /* 621 */ (Std.getSynchronizedTime() % this.teleportInterval == 0)) { /* 622 */ this.teleported = true; /* */ /* 624 */ TeleportAction.teleport(this.teleportChain, this); /* */ } /* */ } /* */ /* */ public void teleportStatus(String err, String dest) { /* 629 */ if (err != null) { /* 630 */ this.teleported = false; /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private int findFrameHandler(FrameHandler h, WObject o) /* */ { /* 640 */ int next = 0; /* */ for (;;) { /* 642 */ next = this.frameHandlers.indexOf(h, next); /* 643 */ if (next == -1) /* 644 */ return -1; /* 645 */ if (this.frameHandlerWObjects.elementAt(next) == o) /* 646 */ return next; /* 647 */ next++; /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ void addFrameHandler(FrameHandler h, WObject o) /* */ { /* 656 */ int i = findFrameHandler(h, o); /* 657 */ if (i < 0) { /* 658 */ this.frameHandlers.addElement(h); /* 659 */ this.frameHandlerWObjects.addElement(o); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ void removeFrameHandler(FrameHandler h, WObject o) /* */ { /* 668 */ int i = findFrameHandler(h, o); /* 669 */ if (i >= 0) { /* 670 */ this.frameHandlers.removeElementAt(i); /* 671 */ this.frameHandlerWObjects.removeElementAt(i); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected void markVoid() /* */ { /* 686 */ this.infiniteBackground.markVoid(); /* 687 */ this.environment.markVoid(); /* */ /* 689 */ super.markVoid(); /* */ /* 691 */ destroyScene(); /* 692 */ this.lightid = 0; /* 693 */ this.lightid2 = 0; /* */ } /* */ /* */ /* */ /* */ /* */ protected void noteTransformChange() /* */ { /* 701 */ super.noteTransformChange(); /* */ /* 703 */ getInfiniteBackground().setTransform(this); /* 704 */ getEnvironment().setTransform(this); /* */ /* */ /* 707 */ int i = this.outgoingPortals.size(); /* 708 */ do { ((Portal)this.outgoingPortals.elementAt(i)).discardTransform();i--; /* 707 */ } while (i >= 0); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void setSkyColor(Color c) /* */ { /* 726 */ this.skyColor = c; /* */ } /* */ /* */ /* */ /* */ public Color getSkyColor() /* */ { /* 733 */ return this.skyColor; /* */ } /* */ /* */ /* */ /* */ /* */ public void setGroundColor(Color c) /* */ { /* 741 */ this.groundColor = c; /* */ } /* */ /* */ /* */ /* */ public Color getGroundColor() /* */ { /* 748 */ return this.groundColor; /* */ } /* */ /* */ /* */ /* */ /* */ /* 755 */ private Vector prerenderHandlers = new Vector(); /* */ /* */ /* */ /* */ /* */ /* */ /* 762 */ private Vector postrenderHandlers = new Vector(); /* */ /* 764 */ private static int isRendering = 4; /* 765 */ private static int isVIPOnly = 262144; /* 766 */ private static int isVIPViewOnly = 524288; /* */ private NetworkRoom _netRoom; /* */ /* 769 */ public boolean getVIPOnly() { return (this.flags & isVIPOnly) != 0; } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void prerender(Camera cam, float x, float y, float z, float d) /* */ { /* 793 */ this.flags |= isRendering; /* */ /* 795 */ this.infiniteBackground.prerender(); /* 796 */ this.environment.prerender(); /* */ /* 798 */ Pilot.addVisibleRoom(this, x, y, z, d); /* */ /* 800 */ int end = this.prerenderHandlers.size(); /* 801 */ for (int i = 0; i < end; i++) { /* 802 */ Prerenderable p = (Prerenderable)this.prerenderHandlers.elementAt(i); /* 803 */ p.prerender(cam); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public void addPrerenderHandler(Prerenderable o) /* */ { /* 812 */ assert ((this.flags & isRendering) == 0); /* */ /* */ /* */ /* */ /* */ /* 818 */ if (!this.prerenderHandlers.contains(o)) { /* 819 */ this.prerenderHandlers.addElement(o); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void prependPrerenderHandler(Prerenderable o) /* */ { /* 833 */ assert ((this.flags & isRendering) == 0); /* 834 */ if (!this.prerenderHandlers.contains(o)) { /* 835 */ this.prerenderHandlers.insertElementAt(o, 0); /* */ } /* */ } /* */ /* */ /* */ /* */ public void removePrerenderHandler(Prerenderable o) /* */ { /* 843 */ assert ((this.flags & isRendering) == 0); /* 844 */ this.prerenderHandlers.removeElement(o); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void postrender(Camera cam, float x, float y, float z, float d) /* */ { /* 855 */ Pilot.addVisibleRoom(this, x, y, z, d); /* */ /* 857 */ int i = this.postrenderHandlers.size(); /* 858 */ do { Postrenderable p = (Postrenderable)this.postrenderHandlers.elementAt(i); /* 859 */ p.postrender(cam);i--; /* 857 */ } while (i >= 0); /* */ /* */ /* */ /* */ /* 862 */ this.flags &= (isRendering ^ 0xFFFFFFFF); /* */ } /* */ /* */ /* */ /* */ /* */ public void addPostrenderHandler(Postrenderable o) /* */ { /* 870 */ assert ((this.flags & isRendering) == 0); /* 871 */ if (!this.postrenderHandlers.contains(o)) { /* 872 */ this.postrenderHandlers.addElement(o); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void prependPostrenderHandler(Postrenderable o) /* */ { /* 886 */ assert ((this.flags & isRendering) == 0); /* 887 */ if (!this.postrenderHandlers.contains(o)) { /* 888 */ this.postrenderHandlers.insertElementAt(o, 0); /* */ } /* */ } /* */ /* */ /* */ /* */ public void removePostrenderHandler(Postrenderable o) /* */ { /* 896 */ assert ((this.flags & isRendering) == 0); /* 897 */ this.postrenderHandlers.removeElement(o); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void detectBump(BumpEventTemp b) /* */ { /* 906 */ if (this.environment.getBumpable()) /* 907 */ this.environment.detectBump(b); /* 908 */ super.detectBump(b); /* */ } /* */ /* */ /* */ /* */ /* */ public BoundBoxTemp getBoundBox() /* */ { /* 916 */ return BoundBoxTemp.make(Point3Temp.make(), Point3Temp.make()); /* */ } /* */ /* */ /* */ /* */ /* */ public World getWorld() /* */ { /* 924 */ return (World)getOwner(); /* */ } /* */ /* */ public Room getRoom() /* */ { /* 929 */ return this; /* */ } /* */ /* */ public Room getRoomFromClump() /* */ { /* 934 */ return this; /* */ } /* */ /* */ public Room getRoomNotFromClump() /* */ { /* 939 */ return this; /* */ } /* */ /* */ /* */ /* */ public Galaxy getGalaxy() /* */ { /* 946 */ World w = getWorld(); /* 947 */ if (w == null) /* 948 */ return null; /* 949 */ return w.getConsole().getGalaxy(); /* */ } /* */ /* */ /* */ /* */ public String getURL() /* */ { /* 956 */ return getWorld().getSourceURL().getAbsolute() + "#" + getName(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean registerShare(WObject w) /* */ { /* 982 */ w.notifyRegister(1); /* 983 */ return true; /* */ } /* */ /* */ private void processPendingRegistrations() { /* 987 */ notifyRegister(1); /* */ } /* */ /* */ /* */ /* */ public NetworkRoom getNetworkRoom() /* */ { /* 994 */ return this._netRoom; /* */ } /* */ /* */ /* */ void subscribe(RoomSubscribeInfo info) /* */ { /* 1000 */ assert (this._netRoom != null); /* 1001 */ this._netRoom.subscribe(info); /* */ } /* */ /* */ void subscribeDist(RoomSubscribeInfo info) { /* 1005 */ assert (this._netRoom != null); /* 1006 */ this._netRoom.subscribeDist(info); /* */ } /* */ /* */ /* */ /* */ /* */ void unsubscribe() /* */ { /* 1014 */ if (this._netRoom != null) { /* 1015 */ this._netRoom.unsubscribe(); /* */ /* */ } /* */ else /* */ { /* */ /* 1021 */ System.out.println(this + ": unsubscribing from bad room?"); /* 1022 */ new Exception().printStackTrace(System.out); /* */ } /* */ } /* */ /* 1026 */ private static String[] skyOptions = { "Blue Sky" }; /* 1027 */ private static String[] groundOptions = { "Green Ground" }; /* */ /* 1029 */ private boolean allowTeleport = true; /* */ /* */ public boolean getAllowTeleport() { /* 1032 */ return this.allowTeleport; /* */ } /* */ /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 1041 */ Object ret = null; /* 1042 */ switch (index - offset) { /* */ case 0: /* 1044 */ if (mode == 0) { /* 1045 */ ret = new Property(this, index, "Environment"); /* 1046 */ } else if (mode == 1) /* 1047 */ ret = this.environment; /* 1048 */ break; /* */ case 1: /* 1050 */ if (mode == 0) { /* 1051 */ ret = new Property(this, index, "Infinite Background"); /* 1052 */ } else if (mode == 1) /* 1053 */ ret = this.infiniteBackground; /* 1054 */ break; /* */ case 2: /* 1056 */ if (mode == 0) { /* 1057 */ ret = ColorPropertyEditor.make(new Property(this, index, /* 1058 */ "Sky Color").allowSetNull()); /* 1059 */ if (getSkyColor() == null) { /* 1060 */ ret = MaybeNullPropertyEditor.make((Property)ret, /* 1061 */ Color.blue); /* */ } /* 1063 */ } else if (mode == 1) { /* 1064 */ ret = getSkyColor(); /* 1065 */ } else if (mode == 2) { /* 1066 */ setSkyColor((Color)value); } /* 1067 */ break; /* */ case 3: /* 1069 */ if (mode == 0) { /* 1070 */ ret = ColorPropertyEditor.make(new Property(this, index, /* 1071 */ "Ground Color").allowSetNull()); /* 1072 */ if (getGroundColor() == null) { /* 1073 */ ret = MaybeNullPropertyEditor.make((Property)ret, /* 1074 */ Color.green); /* */ } /* 1076 */ } else if (mode == 1) { /* 1077 */ ret = getGroundColor(); /* 1078 */ } else if (mode == 2) { /* 1079 */ setGroundColor((Color)value); } /* 1080 */ break; /* */ case 4: /* 1082 */ if (mode == 0) { /* 1083 */ ret = Point3PropertyEditor.make(new Property(this, index, /* 1084 */ "Default Position")); /* 1085 */ } else if (mode == 1) { /* 1086 */ ret = new Point3(getDefaultPosition()); /* 1087 */ } else if (mode == 2) /* 1088 */ this.defaultPosition = ((Point3)value); /* 1089 */ break; /* */ case 5: /* 1091 */ if (mode == 0) { /* 1092 */ ret = Point3PropertyEditor.make(new Property(this, index, /* 1093 */ "Default Orientation Axis")); /* 1094 */ } else if (mode == 1) { /* 1095 */ ret = new Point3(getDefaultOrientationAxis()); /* 1096 */ } else if (mode == 2) /* 1097 */ this.defaultOrientationAxis = ((Point3)value); /* 1098 */ break; /* */ case 6: /* 1100 */ if (mode == 0) { /* 1101 */ ret = FloatPropertyEditor.make(new Property(this, index, /* 1102 */ "Default Orientation Angle")); /* 1103 */ } else if (mode == 1) { /* 1104 */ ret = new Float(getDefaultOrientation()); /* 1105 */ } else if (mode == 2) /* 1106 */ this.defaultOrientation = ((Float)value).floatValue(); /* 1107 */ break; /* */ case 7: /* 1109 */ if (mode == 0) { /* 1110 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 1111 */ "VIP only"), "No", "Yes"); /* 1112 */ } else if (mode == 1) { /* 1113 */ ret = new Boolean((this.flags & isVIPOnly) != 0); /* 1114 */ } else if (mode == 2) { /* 1115 */ if (((Boolean)value).booleanValue()) { /* 1116 */ this.flags |= isVIPOnly; /* */ } else /* 1118 */ this.flags &= (isVIPOnly ^ 0xFFFFFFFF); /* */ } /* 1120 */ break; /* */ case 8: /* 1122 */ if (mode == 0) { /* 1123 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 1124 */ "Visible to VIP only"), "No", "Yes"); /* 1125 */ } else if (mode == 1) { /* 1126 */ ret = new Boolean((this.flags & isVIPViewOnly) != 0); /* 1127 */ } else if (mode == 2) { /* 1128 */ if (((Boolean)value).booleanValue()) { /* 1129 */ this.flags |= isVIPViewOnly; /* */ } else /* 1131 */ this.flags &= (isVIPViewOnly ^ 0xFFFFFFFF); /* */ } /* 1133 */ break; /* */ case 9: /* 1135 */ if (mode == 0) { /* 1136 */ ret = Point3PropertyEditor.make(new Property(this, index, /* 1137 */ "Light Source Direction")); /* 1138 */ } else if (mode == 1) { /* 1139 */ ret = this.lightPosition; /* 1140 */ } else if (mode == 2) /* 1141 */ setLightPosition((Point3)value); /* 1142 */ break; /* */ case 10: /* 1144 */ if (mode == 0) { /* 1145 */ ret = ColorPropertyEditor.make(new Property(this, index, /* 1146 */ "Light Color")); /* 1147 */ } else if (mode == 1) { /* 1148 */ ret = this.lightColor; /* 1149 */ } else if (mode == 2) /* 1150 */ setLightColor((Color)value); /* 1151 */ break; /* */ case 11: /* 1153 */ if (mode == 0) { /* 1154 */ ret = IntegerPropertyEditor.make(new Property(this, index, /* 1155 */ "Time To Auto-Teleport (seconds, -1 = never)")); /* 1156 */ } else if (mode == 1) { /* 1157 */ ret = new Integer(this.teleportInterval); /* 1158 */ } else if (mode == 2) /* 1159 */ this.teleportInterval = ((Integer)value).intValue(); /* 1160 */ break; /* */ case 12: /* 1162 */ if (mode == 0) { /* 1163 */ ret = StringPropertyEditor.make(new Property(this, index, /* 1164 */ "Auto-Teleport destination")); /* 1165 */ } else if (mode == 1) { /* 1166 */ ret = this.teleportChain; /* 1167 */ } else if (mode == 2) /* 1168 */ this.teleportChain = new String((String)value); /* 1169 */ break; /* */ case 13: /* 1171 */ if (mode == 0) { /* 1172 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 1173 */ "Allow Teleporting"), "No", "Yes"); /* 1174 */ } else if (mode == 1) { /* 1175 */ ret = new Boolean(this.allowTeleport); /* 1176 */ } else if (mode == 2) /* 1177 */ this.allowTeleport = ((Boolean)value).booleanValue(); /* 1178 */ break; /* */ default: /* 1180 */ ret = super.properties(index, offset + 14, mode, value); /* */ } /* 1182 */ return ret; /* */ } /* */ /* 1185 */ private static Object classCookie = new Object(); /* */ private RoomEnvironment infiniteBackground; /* */ /* */ public void saveState(Saver s) throws IOException { /* 1189 */ s.saveVersion(7, classCookie); /* 1190 */ super.saveState(s); /* 1191 */ if (this.skyColor != null) { /* 1192 */ s.saveBoolean(true); /* 1193 */ s.saveInt(this.skyColor.getRGB()); /* */ } else { /* 1195 */ s.saveBoolean(false); } /* 1196 */ if (this.groundColor != null) { /* 1197 */ s.saveBoolean(true); /* 1198 */ s.saveInt(this.groundColor.getRGB()); /* */ } else { /* 1200 */ s.saveBoolean(false); } /* 1201 */ s.save(this.defaultPosition); /* 1202 */ s.save(this.defaultOrientationAxis); /* 1203 */ s.saveFloat(this.defaultOrientation); /* 1204 */ s.save(this.lightPosition); /* 1205 */ s.saveInt(this.lightColor.getRGB()); /* */ /* 1207 */ s.save(this.environment); /* 1208 */ s.save(this.infiniteBackground); /* */ /* 1210 */ s.saveString(this.teleportChain); /* 1211 */ s.saveInt(this.teleportInterval); /* */ /* 1213 */ s.saveBoolean(this.allowTeleport); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 1218 */ switch (r.restoreVersion(classCookie)) { /* */ case 0: /* 1220 */ r.setOldFlag(); /* 1221 */ super.restoreState(r); /* 1222 */ setName(r.restoreString()); /* */ /* 1224 */ r.restore(); /* 1225 */ if (r.restoreBoolean()) /* 1226 */ this.skyColor = new Color(r.restoreInt()); /* 1227 */ if (r.restoreBoolean()) /* 1228 */ this.groundColor = new Color(r.restoreInt()); /* 1229 */ r.restoreMaybeNull(); /* 1230 */ this.defaultPosition = ((Point3)r.restore()); /* 1231 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1232 */ this.defaultOrientation = r.restoreFloat(); /* */ /* 1234 */ r.restoreVector(); /* */ /* 1236 */ this.environment = ((RoomEnvironment)r.restore()); /* 1237 */ this.infiniteBackground = new RoomEnvironment(); /* 1238 */ break; /* */ case 1: /* 1240 */ r.setOldFlag(); /* 1241 */ super.restoreState(r); /* */ /* 1243 */ r.restore(); /* 1244 */ if (r.restoreBoolean()) /* 1245 */ this.skyColor = new Color(r.restoreInt()); /* 1246 */ if (r.restoreBoolean()) /* 1247 */ this.groundColor = new Color(r.restoreInt()); /* 1248 */ r.restoreMaybeNull(); /* 1249 */ this.defaultPosition = ((Point3)r.restore()); /* 1250 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1251 */ this.defaultOrientation = r.restoreFloat(); /* */ /* 1253 */ this.environment = ((RoomEnvironment)r.restore()); /* 1254 */ this.infiniteBackground = new RoomEnvironment(); /* 1255 */ break; /* */ case 2: /* 1257 */ r.setOldFlag(); /* 1258 */ super.restoreState(r); /* */ /* 1260 */ if (r.restoreBoolean()) /* 1261 */ this.skyColor = new Color(r.restoreInt()); /* 1262 */ if (r.restoreBoolean()) /* 1263 */ this.groundColor = new Color(r.restoreInt()); /* 1264 */ r.restoreMaybeNull(); /* 1265 */ this.defaultPosition = ((Point3)r.restore()); /* 1266 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1267 */ this.defaultOrientation = r.restoreFloat(); /* */ /* 1269 */ this.environment = ((RoomEnvironment)r.restore()); /* 1270 */ this.infiniteBackground = new RoomEnvironment(); /* 1271 */ break; /* */ case 3: /* 1273 */ r.setOldFlag(); /* 1274 */ super.restoreState(r); /* */ /* 1276 */ if (r.restoreBoolean()) /* 1277 */ this.skyColor = new Color(r.restoreInt()); /* 1278 */ if (r.restoreBoolean()) /* 1279 */ this.groundColor = new Color(r.restoreInt()); /* 1280 */ r.restoreMaybeNull(); /* 1281 */ this.defaultPosition = ((Point3)r.restore()); /* 1282 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1283 */ this.defaultOrientation = r.restoreFloat(); /* */ /* 1285 */ this.environment = ((RoomEnvironment)r.restore()); /* 1286 */ this.infiniteBackground = ((RoomEnvironment)r.restore()); /* 1287 */ break; /* */ case 4: /* 1289 */ r.setOldFlag(); /* 1290 */ super.restoreState(r); /* */ /* 1292 */ if (r.restoreBoolean()) /* 1293 */ this.skyColor = new Color(r.restoreInt()); /* 1294 */ if (r.restoreBoolean()) /* 1295 */ this.groundColor = new Color(r.restoreInt()); /* 1296 */ this.defaultPosition = ((Point3)r.restore()); /* 1297 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1298 */ this.defaultOrientation = r.restoreFloat(); /* */ /* 1300 */ this.environment = ((RoomEnvironment)r.restore()); /* 1301 */ this.infiniteBackground = ((RoomEnvironment)r.restore()); /* 1302 */ break; /* */ case 5: /* 1304 */ super.restoreState(r); /* */ /* 1306 */ if (r.restoreBoolean()) /* 1307 */ this.skyColor = new Color(r.restoreInt()); /* 1308 */ if (r.restoreBoolean()) /* 1309 */ this.groundColor = new Color(r.restoreInt()); /* 1310 */ this.defaultPosition = ((Point3)r.restore()); /* 1311 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1312 */ this.defaultOrientation = r.restoreFloat(); /* 1313 */ setLightPosition((Point3)r.restore()); /* 1314 */ setLightColor(new Color(r.restoreInt())); /* */ /* 1316 */ this.environment = ((RoomEnvironment)r.restore()); /* 1317 */ this.infiniteBackground = ((RoomEnvironment)r.restore()); /* 1318 */ break; /* */ case 6: /* 1320 */ super.restoreState(r); /* */ /* 1322 */ if (r.restoreBoolean()) /* 1323 */ this.skyColor = new Color(r.restoreInt()); /* 1324 */ if (r.restoreBoolean()) /* 1325 */ this.groundColor = new Color(r.restoreInt()); /* 1326 */ this.defaultPosition = ((Point3)r.restore()); /* 1327 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1328 */ this.defaultOrientation = r.restoreFloat(); /* 1329 */ setLightPosition((Point3)r.restore()); /* 1330 */ setLightColor(new Color(r.restoreInt())); /* */ /* 1332 */ this.environment = ((RoomEnvironment)r.restore()); /* 1333 */ this.infiniteBackground = ((RoomEnvironment)r.restore()); /* */ /* 1335 */ this.teleportChain = r.restoreString(); /* 1336 */ this.teleportInterval = r.restoreInt(); /* 1337 */ this.roomLoadTime = (Std.getFastTime() / 1000); /* */ /* 1339 */ break; /* */ case 7: /* 1341 */ super.restoreState(r); /* */ /* 1343 */ if (r.restoreBoolean()) /* 1344 */ this.skyColor = new Color(r.restoreInt()); /* 1345 */ if (r.restoreBoolean()) /* 1346 */ this.groundColor = new Color(r.restoreInt()); /* 1347 */ this.defaultPosition = ((Point3)r.restore()); /* 1348 */ this.defaultOrientationAxis = ((Point3)r.restore()); /* 1349 */ this.defaultOrientation = r.restoreFloat(); /* 1350 */ setLightPosition((Point3)r.restore()); /* 1351 */ setLightColor(new Color(r.restoreInt())); /* */ /* 1353 */ this.environment = ((RoomEnvironment)r.restore()); /* 1354 */ this.infiniteBackground = ((RoomEnvironment)r.restore()); /* */ /* 1356 */ this.teleportChain = r.restoreString(); /* 1357 */ this.teleportInterval = r.restoreInt(); /* 1358 */ this.roomLoadTime = (Std.getFastTime() / 1000); /* 1359 */ this.allowTeleport = r.restoreBoolean(); /* 1360 */ break; /* */ default: /* 1362 */ throw new TooNewException(); /* */ } /* */ /* 1365 */ super.add(this.environment); /* 1366 */ super.add(this.infiniteBackground); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void aboutToDraw() /* */ { /* 1375 */ if ((!hasClump()) && ((getOwner() instanceof World))) { /* 1376 */ recursiveAddRwChildren(null); /* */ } /* */ } /* */ /* */ protected void addRwChildren(WObject parent) { /* 1381 */ assert (parent == null); /* */ /* 1383 */ createClump(); /* 1384 */ createScene(); /* */ /* 1386 */ newRwChildHelper(); /* */ /* 1388 */ float red = this.lightColor.getRed() / 256.0F; /* 1389 */ float green = this.lightColor.getGreen() / 256.0F; /* 1390 */ float blue = this.lightColor.getBlue() / 256.0F; /* */ /* 1392 */ this.lightid = addLight(this.sceneID, this.lightPosition.x, this.lightPosition.y, /* 1393 */ this.lightPosition.z, red, green, blue); /* */ /* 1395 */ this.lightid2 = addLight(this.sceneID, -this.lightPosition.x, -this.lightPosition.y, /* 1396 */ -this.lightPosition.z, red * 0.5F, green * 0.5F, blue * 0.5F); /* */ } /* */ /* */ public void recursiveAddRwChildren(WObject parent) /* */ { /* 1401 */ super.recursiveAddRwChildren(parent); /* 1402 */ this.environment.recursiveAddRwChildren(this); /* 1403 */ this.infiniteBackground.recursiveAddRwChildren(this); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public final float floorHeight(float x, float y) /* */ { /* 1412 */ return floorHeight(x, y, 120.0F); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public float floorHeight(float x, float y, float z) /* */ { /* 1430 */ Transform inverse = getObjectToWorldMatrix().invert(); /* 1431 */ Point3Temp p = Point3Temp.make(x, y, z).times(inverse); /* 1432 */ inverse.recycle(); /* 1433 */ x = p.x; /* 1434 */ y = p.y; /* 1435 */ z = p.z; /* */ /* */ /* */ /* */ /* */ /* */ /* 1442 */ float height = 0.0F; /* 1443 */ boolean patchFound = false; /* 1444 */ for (Enumeration e = getContents(); e.hasMoreElements();) { /* 1445 */ Object o = e.nextElement(); /* 1446 */ if (((o instanceof FloorPatch)) && /* 1447 */ (((FloorPatch)o).inPatch(x, y))) { /* 1448 */ float patchHeight = ((FloorPatch)o).floorHeight(x, y); /* */ /* */ /* 1451 */ if ((patchHeight <= z) && ( /* 1452 */ (patchHeight > height) || (!patchFound))) { /* 1453 */ patchFound = true; /* 1454 */ height = ((FloorPatch)o).floorHeight(x, y); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* 1461 */ return height; /* */ } /* */ /* */ /* */ /* */ public Point3 surfaceNormal(float x, float y, float z) /* */ { /* 1468 */ Point3 normal = new Point3(0.0F, 0.0F, 1.0F); /* */ /* 1470 */ FloorPatch patch = null; /* */ /* 1472 */ float height = 0.0F; /* 1473 */ boolean patchFound = false; /* 1474 */ for (Enumeration e = getContents(); e.hasMoreElements();) { /* 1475 */ Object o = e.nextElement(); /* 1476 */ if (((o instanceof FloorPatch)) && /* 1477 */ (((FloorPatch)o).inPatch(x, y))) { /* 1478 */ float patchHeight = ((FloorPatch)o).floorHeight(x, y); /* */ /* */ /* 1481 */ if ((patchHeight <= z) && ( /* 1482 */ (patchHeight > height) || (!patchFound))) { /* 1483 */ patchFound = true; /* 1484 */ height = ((FloorPatch)o).floorHeight(x, y); /* 1485 */ patch = (FloorPatch)o; /* */ } /* */ } /* */ } /* */ /* */ /* 1491 */ if (patch != null) { /* 1492 */ normal = patch.surfaceNormal(x, y); /* */ } /* */ /* 1495 */ normal.vectorTimes(getObjectToWorldMatrix()); /* */ /* 1497 */ return normal; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public RoomEnvironment getInfiniteBackground() /* */ { /* 1508 */ return this.infiniteBackground; /* */ } /* */ /* */ public String toString() /* */ { /* 1513 */ return getWorld() + "#" + getName(); /* */ } /* */ /* */ public Room() {} /* */ /* */ public static native void nativeInit(); /* */ /* */ protected final void noteAddingTo(SuperRoot s) {} /* */ /* */ static native int addLight(int paramInt, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, float paramFloat5, float paramFloat6); /* */ /* */ static native void setLightPosition(int paramInt, float paramFloat1, float paramFloat2, float paramFloat3); /* */ /* */ static native void setLightColor(int paramInt, float paramFloat1, float paramFloat2, float paramFloat3); /* */ /* */ native void createScene(); /* */ /* */ native void destroyScene(); /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Room.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */