/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.BBAnimateDroneCommand; /* */ import NET.worlds.console.BlackBox; /* */ import NET.worlds.console.Console; /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.network.ObjID; /* */ import NET.worlds.network.URL; /* */ import NET.worlds.network.WorldServer; /* */ import java.io.IOException; /* */ import java.net.MalformedURLException; /* */ import java.util.Enumeration; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class PosableDrone /* */ extends Drone /* */ implements FrameHandler /* */ { /* 71 */ static boolean droneLoaderStarted = false; /* */ /* */ /* */ /* */ /* */ /* 77 */ static { threadDroneLoads = IniFile.gamma().getIniInt("ThreadDroneLoading", 0) == 1; } /* 78 */ static PosableDroneLoader droneLoader = new PosableDroneLoader(); /* */ /* */ /* 81 */ private PosableShape pendingShape = null; /* */ /* */ public void SetPendingShape(PosableShape ps) { /* 84 */ this.pendingShape = ps; /* */ } /* */ /* */ public boolean handle(FrameEvent evt) { /* 88 */ if (this.pendingShape != null) /* */ { /* 90 */ PosableShape ps = getInternalPosableShape(); /* 91 */ if (ps != null) { /* 92 */ ps.detach(); /* */ } /* */ /* */ /* 96 */ add(this.pendingShape); /* */ /* */ /* */ /* 100 */ this.pendingShape = null; /* */ } /* */ /* 103 */ return super.handle(evt); /* */ } /* */ /* */ /* */ /* */ /* */ public PosableDrone(ObjID objID, WorldServer serv, URL url) /* */ { /* 111 */ super(objID, serv); /* 112 */ makeFigure(url); /* */ } /* */ /* */ public PosableDrone(ObjID objID, WorldServer serv) { /* 116 */ super(objID, serv); /* 117 */ loadInit(); /* */ } /* */ /* */ /* */ public PosableDrone() {} /* */ /* */ public void loadInit() /* */ { /* 125 */ makeFigure(PosableShape.getDefaultURL()); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public synchronized URL getPosableShapeURL() /* */ { /* 134 */ PosableShape ps = getInternalPosableShape(); /* 135 */ if (ps == null) { /* 136 */ return null; /* */ } /* 138 */ return ps.getURL(); /* */ } /* */ /* */ /* */ /* */ /* */ public Drone setAvatarNow(URL url) /* */ { /* 146 */ if ((!shouldBeMuted()) && ((url.endsWith(".rwx")) || (url.endsWith(".rwg")))) /* */ { /* 148 */ if (shouldBeForcedHuman()) { /* 149 */ url = PosableShape.getHuman(url); /* */ } /* */ /* 152 */ url = PosableShape.getPermitted(url, getWorld()); /* */ /* 154 */ PosableShape ps = getInternalPosableShape(); /* */ /* 156 */ if (ps != null) { /* 157 */ if (url.equals(ps.getURL())) { /* 158 */ return this; /* */ } /* 160 */ ps.detach(); /* */ } /* 162 */ makeFigure(url); /* 163 */ return this; /* */ } /* 165 */ return super.setAvatarNow(url); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void makeFigure(URL url) /* */ { /* 185 */ boolean isPilot = false; /* 186 */ if ((Console.getActive() != null) && /* 187 */ (Console.getActive().getPilot() != null) && /* 188 */ (Console.getActive().getPilot().hasContents())) { /* 189 */ isPilot = Console.getActive().getPilot().contentsContain(this); /* */ } /* */ /* */ /* */ /* 194 */ if (!isPilot) { /* 195 */ isPilot = isPilotDrone(url); /* */ } /* 197 */ boolean loadAsynchronously = false; /* */ /* */ /* */ /* */ /* */ /* */ /* */ try /* */ { /* 206 */ if (!PosableDroneLoader.avatarExistsLocally(url)) { /* 207 */ loadAsynchronously = true; /* */ } else { /* 209 */ loadAsynchronously = (!isPilot) && /* 210 */ (!url.toString().equals(PosableShape.getDefaultURL().toString())); /* */ } /* */ } catch (MalformedURLException e) { /* 213 */ loadAsynchronously = false; /* */ } /* */ /* 216 */ if ((loadAsynchronously) && (threadDroneLoads)) { /* 217 */ if (!droneLoaderStarted) { /* 218 */ droneLoaderStarted = true; /* 219 */ Thread t = new Thread(droneLoader, "DroneLoaderDaemon"); /* 220 */ t.setDaemon(true); /* 221 */ t.setPriority(1); /* 222 */ t.start(); /* */ } /* */ /* 225 */ droneLoader.load(this, url); /* */ } else { /* */ PosableShape ps; /* */ PosableShape ps; /* 229 */ if (VehicleShape.isVehicle(url)) { /* 230 */ ps = new VehicleShape(url); /* */ } else /* 232 */ ps = new PosableShape(url); /* 233 */ ps.setVisible(true); /* 234 */ ps.setBumpable(false); /* */ /* 236 */ if (!isPilotDrone(url)) { /* 237 */ ps.enableLOD(true); /* */ } /* 239 */ add(ps); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public PosableShape getInternalPosableShape() /* */ { /* 248 */ for (Enumeration e = getContents(); e.hasMoreElements();) { /* 249 */ Object o = e.nextElement(); /* 250 */ if ((o instanceof PosableShape)) /* 251 */ return (PosableShape)o; /* */ } /* 253 */ return null; /* */ } /* */ /* */ public boolean isPilotDrone(URL url) { /* 257 */ if ((Console.getActive() != null) && /* 258 */ (Console.getActive().pendingPilot.equals(url.toString()))) /* */ { /* 260 */ return true; /* */ } /* */ /* */ /* 264 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ public float animate(String action) /* */ { /* 272 */ super.animate(action); /* */ /* 274 */ BlackBox.getInstance().submitEvent( /* 275 */ new BBAnimateDroneCommand(getName(), action)); /* */ /* 277 */ PosableShape ps = getInternalPosableShape(); /* 278 */ if (ps != null) { /* 279 */ return ps.animate(action); /* */ } /* 281 */ return 0.0F; /* */ } /* */ /* */ public Vector getAnimationList() { /* 285 */ PosableShape ps = getInternalPosableShape(); /* 286 */ if (ps != null) /* 287 */ return ps.getAnimationList(); /* 288 */ return super.getAnimationList(); /* */ } /* */ /* */ /* */ /* 293 */ private static Object classCookie = new Object(); /* */ public static boolean threadDroneLoads; /* */ /* 296 */ public void saveState(Saver s) throws IOException { s.saveVersion(2, classCookie); /* 297 */ super.saveState(s); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException { /* 301 */ int vers = r.restoreVersion(classCookie); /* 302 */ switch (vers) { /* */ case 0: /* */ case 1: /* 305 */ if (vers == 0) { /* 306 */ restoreStateDrone(r); /* */ } else /* 308 */ super.restoreState(r); /* 309 */ r.setOldFlag(); /* 310 */ makeFigure(URL.make("avatar:" + r.restoreString() + ".rwx")); /* 311 */ break; /* */ /* */ case 2: /* 314 */ super.restoreState(r); /* 315 */ break; /* */ /* */ default: /* 318 */ throw new TooNewException(); /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\PosableDrone.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */