summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/InterpolatedDrone.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/InterpolatedDrone.java')
-rw-r--r--NET/worlds/scape/InterpolatedDrone.java298
1 files changed, 298 insertions, 0 deletions
diff --git a/NET/worlds/scape/InterpolatedDrone.java b/NET/worlds/scape/InterpolatedDrone.java
new file mode 100644
index 0000000..efae497
--- /dev/null
+++ b/NET/worlds/scape/InterpolatedDrone.java
@@ -0,0 +1,298 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.console.BBAppearDroneCommand;
+/* */ import NET.worlds.console.BBDisappearDroneCommand;
+/* */ import NET.worlds.console.BBDroneDeltaPosCommand;
+/* */ import NET.worlds.console.BBMoveDroneCommand;
+/* */ import NET.worlds.console.BlackBox;
+/* */ import NET.worlds.core.Std;
+/* */ import NET.worlds.network.ObjID;
+/* */ import NET.worlds.network.URL;
+/* */ import NET.worlds.network.WorldServer;
+/* */ import java.io.IOException;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class InterpolatedDrone
+/* */ extends Drone
+/* */ implements FrameHandler
+/* */ {
+/* */ private int _last_FrameTime;
+/* */ private int _last_PosTime;
+/* */ private int _vel_x;
+/* */ private int _vel_y;
+/* */ private int _vel_z;
+/* */ private int _vel_yaw;
+/* */ private int _last_x;
+/* */ private int _last_y;
+/* */ private int _last_z;
+/* */ private int _last_yaw;
+/* */ private int _x;
+/* */ private int _y;
+/* */ private int _z;
+/* */ private int _yaw;
+/* */
+/* */ public InterpolatedDrone(ObjID objID, WorldServer serv)
+/* */ {
+/* 41 */ super(objID, serv);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 53 */ private boolean inited = false;
+/* */
+/* */ public InterpolatedDrone() {}
+/* */
+/* 57 */ public Point3Temp getVelocity() { return Point3Temp.make(this._vel_x, this._vel_y, this._vel_z); }
+/* */
+/* */
+/* */ public int getYawRate()
+/* */ {
+/* 62 */ return this._vel_yaw;
+/* */ }
+/* */
+/* */ public boolean handle(FrameEvent fe)
+/* */ {
+/* 67 */ if (this._server == null) {
+/* 68 */ return true;
+/* */ }
+/* 70 */ int timeNow = fe.time;
+/* */
+/* 72 */ interpolate(timeNow, this._server.getUpdateTime(), this);
+/* */
+/* 74 */ return true;
+/* */ }
+/* */
+/* */ public void interpolate(int timeNow, int updateTime, Transform target)
+/* */ {
+/* 79 */ if (!this.inited) { return;
+/* */ }
+/* 81 */ if (timeNow - this._last_PosTime > updateTime)
+/* */ {
+/* */
+/* 84 */ this._last_PosTime = timeNow;
+/* 85 */ this._vel_x = (this._last_x - this._x);
+/* 86 */ this._vel_y = (this._last_y - this._y);
+/* 87 */ this._vel_z = (this._last_z - this._z);
+/* 88 */ this._vel_yaw = (((this._last_yaw - this._yaw) % 360 + 360) % 360);
+/* 89 */ assert (this._vel_yaw >= 0);
+/* 90 */ if (this._vel_yaw > 180)
+/* 91 */ this._vel_yaw -= 360;
+/* */ }
+/* 93 */ double timeDiff = (timeNow - this._last_FrameTime) /
+/* 94 */ updateTime;
+/* 95 */ if (timeNow - this._last_FrameTime > updateTime)
+/* 96 */ timeDiff = 0.0D;
+/* 97 */ this._x += (int)(timeDiff * this._vel_x);
+/* 98 */ this._y += (int)(timeDiff * this._vel_y);
+/* 99 */ this._z += (int)(timeDiff * this._vel_z);
+/* 100 */ this._yaw += (int)(timeDiff * this._vel_yaw) % 360;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 106 */ target.makeIdentity().moveBy(this._x, this._y, this._z).yaw(this._yaw);
+/* */
+/* 108 */ this._last_FrameTime = timeNow;
+/* */ }
+/* */
+/* */ public void reset(short x, short y, short z, short yaw)
+/* */ {
+/* 113 */ this._x = x;
+/* 114 */ this._y = y;
+/* 115 */ this._z = z;
+/* 116 */ this._yaw = yaw;
+/* */
+/* 118 */ this._vel_x = (this._vel_y = this._vel_z = 0);
+/* 119 */ this._vel_yaw = 0;
+/* 120 */ this._last_x = this._x;
+/* 121 */ this._last_y = this._y;
+/* 122 */ this._last_z = this._z;
+/* 123 */ this._last_yaw = this._yaw;
+/* */
+/* 125 */ this._last_PosTime = (this._last_FrameTime = Std.getRealTime());
+/* */
+/* 127 */ this.inited = true;
+/* */ }
+/* */
+/* */
+/* */
+/* */ public void appear(Room rm, short x, short y, short z, short yaw)
+/* */ {
+/* 134 */ assert (rm != null);
+/* */
+/* 136 */ BlackBox.getInstance().submitEvent(new BBAppearDroneCommand(rm.toString(),
+/* 137 */ getName(), x, y, z, yaw));
+/* */
+/* 139 */ if (getRoom() != rm) {
+/* 140 */ detach();
+/* 141 */ rm.add(this);
+/* */ }
+/* */
+/* 144 */ makeIdentity().moveBy(x, y, z).yaw(yaw);
+/* */
+/* */
+/* 147 */ this._x = x;
+/* 148 */ this._y = y;
+/* 149 */ this._z = z;
+/* 150 */ this._yaw = yaw;
+/* 151 */ this._vel_x = (this._vel_y = this._vel_z = 0);
+/* 152 */ this._vel_yaw = 0;
+/* 153 */ this._last_x = x;
+/* 154 */ this._last_y = y;
+/* 155 */ this._last_z = z;
+/* 156 */ this._last_yaw = yaw;
+/* */
+/* 158 */ this._last_PosTime = (this._last_FrameTime = Std.getRealTime());
+/* */
+/* 160 */ URL u = getCurrentURL();
+/* 161 */ if (u != null) {
+/* 162 */ setAvatarNow(u);
+/* */ }
+/* 164 */ this.inited = true;
+/* */ }
+/* */
+/* */ public void disappear()
+/* */ {
+/* 169 */ BlackBox.getInstance().submitEvent(new BBDisappearDroneCommand(getName()));
+/* 170 */ detachFromServer(true);
+/* 171 */ detach();
+/* */ }
+/* */
+/* */ public void longLoc(short x, short y, short z, short yaw)
+/* */ {
+/* 176 */ if (!(getOwner() instanceof Pilot)) {
+/* 177 */ BlackBox.getInstance().submitEvent(
+/* 178 */ new BBMoveDroneCommand(getName(), x, y, z, yaw));
+/* */ }
+/* 180 */ this._last_x = x;
+/* 181 */ this._last_y = y;
+/* 182 */ this._last_z = z;
+/* 183 */ this._last_yaw = yaw;
+/* 184 */ this._vel_x = (this._last_x - this._x);
+/* 185 */ this._vel_y = (this._last_y - this._y);
+/* 186 */ this._vel_z = (this._last_z - this._z);
+/* 187 */ this._vel_yaw = (((this._last_yaw - this._yaw) % 360 + 360) % 360);
+/* 188 */ assert (this._vel_yaw >= 0);
+/* 189 */ if (this._vel_yaw > 180)
+/* 190 */ this._vel_yaw -= 360;
+/* 191 */ this._last_PosTime = Std.getRealTime();
+/* 192 */ this.inited = true;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ protected void transferFrom(Drone d)
+/* */ {
+/* 200 */ super.transferFrom(d);
+/* */
+/* 202 */ if ((d instanceof InterpolatedDrone))
+/* */ {
+/* 204 */ InterpolatedDrone i = (InterpolatedDrone)d;
+/* 205 */ this._x = i._x;
+/* 206 */ this._y = i._y;
+/* 207 */ this._z = i._z;
+/* 208 */ this._yaw = i._yaw;
+/* 209 */ this._vel_x = i._vel_x;
+/* 210 */ this._vel_y = i._vel_y;
+/* 211 */ this._vel_z = i._vel_z;
+/* 212 */ this._vel_yaw = i._vel_yaw;
+/* 213 */ this._last_x = i._last_x;
+/* 214 */ this._last_y = i._last_y;
+/* 215 */ this._last_z = i._last_z;
+/* 216 */ this._last_yaw = i._last_yaw;
+/* 217 */ this._last_PosTime = i._last_PosTime;
+/* 218 */ this._last_FrameTime = i._last_FrameTime;
+/* 219 */ this.inited = true;
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public void roomChange(Room newRoom, short x, short y, short z, short yaw)
+/* */ {
+/* 228 */ detach();
+/* 229 */ if (newRoom != null) {
+/* 230 */ appear(newRoom, x, y, z, yaw);
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */ public void shortLoc(byte dx, byte dy, byte dyaw)
+/* */ {
+/* 238 */ if (!(getOwner() instanceof Pilot)) {
+/* 239 */ BlackBox.getInstance().submitEvent(
+/* 240 */ new BBDroneDeltaPosCommand(getName(), dx, dy, dyaw));
+/* */ }
+/* 242 */ this._last_x += dx;
+/* 243 */ this._last_y += dy;
+/* */
+/* 245 */ this._last_yaw += dyaw;
+/* 246 */ this._last_yaw %= 360;
+/* */
+/* 248 */ this._vel_x = (this._last_x - this._x);
+/* 249 */ this._vel_y = (this._last_y - this._y);
+/* */
+/* 251 */ this._vel_z = 0;
+/* 252 */ this._vel_yaw = (((this._last_yaw - this._yaw) % 360 + 360) % 360);
+/* 253 */ assert (this._vel_yaw >= 0);
+/* 254 */ if (this._vel_yaw > 180) {
+/* 255 */ this._vel_yaw -= 360;
+/* */ }
+/* 257 */ this._last_PosTime = Std.getRealTime();
+/* */ }
+/* */
+/* */
+/* */
+/* */ public Object properties(int index, int offset, int mode, Object value)
+/* */ throws NoSuchPropertyException
+/* */ {
+/* 265 */ Object ret = null;
+/* 266 */ (index - offset);
+/* */
+/* 268 */ ret = super.properties(index, offset + 0, mode, value);
+/* */
+/* 270 */ return ret;
+/* */ }
+/* */
+/* 273 */ private static Object classCookie = new Object();
+/* */
+/* */ public void saveState(Saver s) throws IOException
+/* */ {
+/* 277 */ s.saveVersion(0, classCookie);
+/* 278 */ super.saveState(s);
+/* */ }
+/* */
+/* */ public void restoreState(Restorer r) throws IOException, TooNewException
+/* */ {
+/* 283 */ switch (r.restoreVersion(classCookie)) {
+/* */ case 0:
+/* 285 */ super.restoreState(r);
+/* 286 */ break;
+/* */
+/* */ default:
+/* 289 */ throw new TooNewException();
+/* */ }
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\InterpolatedDrone.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file