summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/AnimatedAction.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/AnimatedAction.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/AnimatedAction.java')
-rw-r--r--NET/worlds/scape/AnimatedAction.java203
1 files changed, 203 insertions, 0 deletions
diff --git a/NET/worlds/scape/AnimatedAction.java b/NET/worlds/scape/AnimatedAction.java
new file mode 100644
index 0000000..95e6d23
--- /dev/null
+++ b/NET/worlds/scape/AnimatedAction.java
@@ -0,0 +1,203 @@
+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.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;
+ static String[] actions = new String[]{"noAction", "addToInventory", "removeObject", "animateObject", "moveObjectTo", "playSound"};
+ String actionName;
+ Vector avatarNames;
+ Vector targetObjects;
+ 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;
+
+ AnimatedAction() {
+ this.avatarNames = new Vector();
+ this.targetObjects = new Vector();
+ }
+
+ public static int getAction(String action) {
+ for (int i = 0; i < actions.length; i++) {
+ if (action.equals(actions[i])) {
+ return i;
+ }
+ }
+
+ return 0;
+ }
+
+ void setTargetShape(Shape s) {
+ this._targetShape = s;
+ Point3Temp objVec = Point3Temp.make(this.targetRelPosition.x, this.targetRelPosition.y, 0.0F);
+ this.targetYaw = this._targetShape.getObjectToWorldMatrix().getYaw();
+ Transform t = new Transform();
+ t.yaw(-this.targetYaw);
+ objVec.vectorTimes(t);
+ t.recycle();
+ Point3Temp shapePos = this._targetShape.getWorldPosition();
+ objVec.plus(shapePos);
+ this.targetPosition = new Point2(objVec.x, objVec.y);
+ }
+
+ public void execute(HoloPilot pilot) {
+ if (this._targetShape == null) {
+ System.out.println("No target shape for action " + this.actionName);
+ } else {
+ this._targetShape.setBumpable(false);
+ this._pilot = pilot;
+ this._state = 0;
+ this.stateChanged();
+ }
+ }
+
+ @Override
+ public void motionComplete(int completionCode) {
+ this._state++;
+ this.stateChanged();
+ }
+
+ @Override
+ public void timerDone() {
+ this.motionComplete(0);
+ }
+
+ private void stateChanged() {
+ switch (this._state) {
+ case 0:
+ this.motionComplete(0);
+ break;
+ case 1:
+ Console c = Console.getActive();
+ if (c instanceof DefaultConsole) {
+ Pilot p = Pilot.getActive();
+ this._oldMode = p.getOutsideCameraMode();
+ this._oldSpeed = p.getOutsideCameraSpeed();
+ p.setOutsideCameraMode(8, 1);
+ }
+
+ this.motionComplete(0);
+ break;
+ case 2:
+ double newYaw = this.targetYaw + this.targetRelYaw;
+ this._pilot.addCallback(this);
+ this._pilot.walkTo(new Point2(this.targetPosition.x, this.targetPosition.y), (float)newYaw);
+ break;
+ case 3:
+ this._pilot.removeSmoothDriver();
+ this._pilot.returnHandsOffDriver();
+ this.doAction(this.preAnimationAction, this.preAnimationParameter);
+ this.motionComplete(0);
+ break;
+ case 4:
+ case 7:
+ String actionName;
+ if (this._state == 4) {
+ actionName = this.actionName1;
+ } else {
+ actionName = this.actionName2;
+ }
+
+ this._waitTime = this._pilot.animate(actionName);
+ this.motionComplete(0);
+ break;
+ case 5:
+ this.doAction(this.simultaneousAction, this.simultaneousParameter + "|sender|" + this.actionName1);
+ Timer tm = new Timer(this._waitTime, this);
+ tm.start();
+ break;
+ case 6:
+ this.doAction(this.postAnimationAction, this.postAnimationParameter);
+ this.motionComplete(0);
+ break;
+ case 8:
+ Console c = Console.getActive();
+ if (c instanceof DefaultConsole) {
+ Pilot p = Pilot.getActive();
+ p.setOutsideCameraMode(this._oldMode, this._oldSpeed);
+ }
+
+ this._pilot.removeHandsOffDriver();
+ this._pilot.returnSmoothDriver();
+ AnimatedActionManager.get().actionCompleted(this);
+ this.motionComplete(0);
+ }
+ }
+
+ public void abort() {
+ this._state = 8;
+ this.stateChanged();
+ }
+
+ private void doAction(int action, String parameter) {
+ switch (action) {
+ case 5:
+ Sound s = new Sound(URL.make(parameter));
+ this._pilot.add(s);
+ s.trigger(null, null);
+ case 3:
+ Drone targetDrone = null;
+ if (this._targetShape != null && this._targetShape instanceof PosableShape) {
+ SuperRoot owner = this._targetShape.getOwner();
+ if (owner instanceof Drone) {
+ targetDrone = (Drone)owner;
+ }
+ }
+
+ if (targetDrone != null) {
+ Pilot.sendText(targetDrone.getLongID(), "&|+action2>" + parameter);
+ }
+
+ if (this._targetShape instanceof PosableShape) {
+ String actionName = null;
+ int idx = parameter.indexOf("|sender|");
+ if (idx != -1) {
+ actionName = parameter.substring(0, idx);
+ } else {
+ actionName = parameter;
+ }
+
+ ((PosableShape)this._targetShape).animate(actionName);
+ }
+ case 0:
+ case 1:
+ case 2:
+ case 4:
+ }
+ }
+}