/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.DefaultConsole; /* */ import NET.worlds.core.Timer; /* */ import NET.worlds.core.TimerCallback; /* */ import NET.worlds.network.URL; /* */ import java.io.PrintStream; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class AnimatedAction /* */ implements AnimatedActionCallback, TimerCallback /* */ { /* */ static final int noAction = 0; /* */ static final int addToInventory = 1; /* */ static final int removeObject = 2; /* */ static final int animateObject = 3; /* */ static final int moveObjectTo = 4; /* */ static final int playSound = 5; /* */ static final int obtainConsent = 0; /* */ static final int zoomOut = 1; /* */ static final int moveToObject = 2; /* */ static final int preAnimateAction = 3; /* */ static final int actOnObject1 = 4; /* */ static final int simulAnimateAction = 5; /* */ static final int postAnimateAction = 6; /* */ static final int actOnObject2 = 7; /* */ static final int zoomBack = 8; /* 51 */ static String[] actions = { /* 52 */ "noAction", /* 53 */ "addToInventory", /* 54 */ "removeObject", /* 55 */ "animateObject", /* 56 */ "moveObjectTo", /* 57 */ "playSound" }; /* */ String actionName; /* */ Vector avatarNames; /* */ Vector targetObjects; /* */ /* 62 */ AnimatedAction() { this.avatarNames = new Vector(); /* 63 */ this.targetObjects = new Vector(); /* */ } /* */ /* */ public static int getAction(String action) /* */ { /* 68 */ for (int i = 0; i < actions.length; i++) /* */ { /* 70 */ if (action.equals(actions[i])) { /* 71 */ return i; /* */ } /* */ } /* 74 */ return 0; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 99 */ Shape _targetShape = null; /* */ /* */ /* */ boolean consentRequired; /* */ /* */ /* */ Point2 targetRelPosition; /* */ /* */ /* */ Point2 targetPosition; /* */ /* */ /* */ double targetRelYaw; /* */ /* */ /* */ float targetYaw; /* */ /* */ /* */ int preAnimationAction; /* */ /* */ /* */ String preAnimationParameter; /* */ /* */ /* */ String actionName1; /* */ /* */ /* */ int simultaneousAction; /* */ /* */ /* */ String simultaneousParameter; /* */ /* */ /* */ int postAnimationAction; /* */ /* */ /* */ String postAnimationParameter; /* */ /* */ String actionName2; /* */ /* */ int _oldMode; /* */ /* */ int _oldSpeed; /* */ /* */ private int _state; /* */ /* */ private HoloPilot _pilot; /* */ /* */ private float _waitTime; /* */ /* */ /* */ void setTargetShape(Shape s) /* */ { /* 152 */ this._targetShape = s; /* */ /* 154 */ Point3Temp objVec = Point3Temp.make(this.targetRelPosition.x, /* 155 */ this.targetRelPosition.y, 0.0F); /* */ /* 157 */ this.targetYaw = this._targetShape.getObjectToWorldMatrix().getYaw(); /* 158 */ Transform t = new Transform(); /* 159 */ t.yaw(-this.targetYaw); /* 160 */ objVec.vectorTimes(t); /* 161 */ t.recycle(); /* */ /* 163 */ Point3Temp shapePos = this._targetShape.getWorldPosition(); /* */ /* 165 */ objVec.plus(shapePos); /* */ /* 167 */ this.targetPosition = new Point2(objVec.x, objVec.y); /* */ } /* */ /* */ public void execute(HoloPilot pilot) /* */ { /* 172 */ if (this._targetShape == null) /* */ { /* 174 */ System.out.println("No target shape for action " + this.actionName); /* 175 */ return; /* */ } /* */ /* 178 */ this._targetShape.setBumpable(false); /* */ /* 180 */ this._pilot = pilot; /* */ /* */ /* */ /* */ /* 185 */ this._state = 0; /* 186 */ stateChanged(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void motionComplete(int completionCode) /* */ { /* 195 */ this._state += 1; /* 196 */ stateChanged(); /* */ } /* */ /* */ public void timerDone() /* */ { /* 201 */ motionComplete(0); /* */ } /* */ /* */ private void stateChanged() /* */ { /* 206 */ switch (this._state) /* */ { /* */ /* */ case 0: /* 210 */ motionComplete(0); /* 211 */ break; /* */ /* */ /* */ /* */ case 1: /* 216 */ Console c = Console.getActive(); /* 217 */ if ((c instanceof DefaultConsole)) /* */ { /* 219 */ Pilot p = Pilot.getActive(); /* 220 */ this._oldMode = p.getOutsideCameraMode(); /* 221 */ this._oldSpeed = p.getOutsideCameraSpeed(); /* 222 */ p.setOutsideCameraMode(8, /* 223 */ 1); /* */ } /* */ /* 226 */ motionComplete(0); /* 227 */ break; /* */ /* */ /* */ /* */ /* */ case 2: /* 233 */ double newYaw = this.targetYaw + this.targetRelYaw; /* 234 */ this._pilot.addCallback(this); /* */ /* */ /* 237 */ this._pilot.walkTo(new Point2(this.targetPosition.x, /* 238 */ this.targetPosition.y), (float)newYaw); /* 239 */ break; /* */ /* */ /* */ /* */ case 3: /* 244 */ this._pilot.removeSmoothDriver(); /* 245 */ this._pilot.returnHandsOffDriver(); /* 246 */ doAction(this.preAnimationAction, this.preAnimationParameter); /* 247 */ motionComplete(0); /* 248 */ break; /* */ case 4: /* */ case 7: /* */ String actionName; /* */ /* */ String actionName; /* */ /* 255 */ if (this._state == 4) { /* 256 */ actionName = this.actionName1; /* */ } else { /* 258 */ actionName = this.actionName2; /* */ } /* 260 */ this._waitTime = this._pilot.animate(actionName); /* 261 */ motionComplete(0); /* 262 */ break; /* */ /* */ /* */ /* */ case 5: /* 267 */ doAction(this.simultaneousAction, this.simultaneousParameter + /* 268 */ "|sender|" + this.actionName1); /* */ /* */ /* */ /* 272 */ Timer tm = new Timer(this._waitTime, this); /* 273 */ tm.start(); /* 274 */ break; /* */ /* */ /* */ /* */ /* */ case 6: /* 280 */ doAction(this.postAnimationAction, this.postAnimationParameter); /* 281 */ motionComplete(0); /* 282 */ break; /* */ /* */ /* */ /* */ /* */ case 8: /* 288 */ Console c = Console.getActive(); /* 289 */ if ((c instanceof DefaultConsole)) /* */ { /* 291 */ Pilot p = Pilot.getActive(); /* 292 */ p.setOutsideCameraMode(this._oldMode, this._oldSpeed); /* */ } /* 294 */ this._pilot.removeHandsOffDriver(); /* 295 */ this._pilot.returnSmoothDriver(); /* 296 */ AnimatedActionManager.get().actionCompleted(this); /* 297 */ motionComplete(0); /* */ } /* */ /* */ } /* */ /* */ /* */ /* */ /* */ public void abort() /* */ { /* 307 */ this._state = 8; /* 308 */ stateChanged(); /* */ } /* */ /* */ private void doAction(int action, String parameter) /* */ { /* 313 */ switch (action) /* */ { /* */ case 0: /* */ break; /* */ /* */ /* */ /* */ case 1: /* */ break; /* */ /* */ /* */ /* */ case 2: /* */ break; /* */ /* */ /* */ /* */ /* */ case 5: /* 332 */ Sound s = new Sound(URL.make(parameter)); /* 333 */ this._pilot.add(s); /* 334 */ s.trigger(null, null); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ case 3: /* 343 */ Drone targetDrone = null; /* */ /* 345 */ if (this._targetShape != null) /* */ { /* 347 */ if ((this._targetShape instanceof PosableShape)) /* */ { /* 349 */ SuperRoot owner = this._targetShape.getOwner(); /* 350 */ if ((owner instanceof Drone)) /* */ { /* 352 */ targetDrone = (Drone)owner; /* */ } /* */ } /* */ } /* */ /* 357 */ if (targetDrone != null) /* */ { /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 371 */ Pilot.sendText(targetDrone.getLongID(), /* 372 */ "&|+action2>" + parameter); /* */ } /* */ /* 375 */ if ((this._targetShape instanceof PosableShape)) /* */ { /* */ /* 378 */ String actionName = null; /* 379 */ int idx = parameter.indexOf("|sender|"); /* 380 */ if (idx != -1) { /* 381 */ actionName = parameter.substring(0, idx); /* */ } else { /* 383 */ actionName = parameter; /* */ } /* 385 */ ((PosableShape)this._targetShape).animate(actionName); /* */ } /* */ /* 388 */ break; /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\AnimatedAction.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */