blob: 620e9c428def1ee74c7bb3610c2e81af6c0b7a6b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package NET.worlds.console;
import NET.worlds.scape.Drone;
import NET.worlds.scape.HoloPilot;
import NET.worlds.scape.Pilot;
import NET.worlds.scape.Point3Temp;
import NET.worlds.scape.TeleportAction;
import NET.worlds.scape.TeleportStatus;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class BBTeleportCommand extends BlackBoxCommand implements TeleportStatus {
private String location;
public BBTeleportCommand() {
this.commandType = 1;
}
public BBTeleportCommand(String pLocation) {
this();
if (pLocation != null) {
this.location = new String(pLocation);
}
}
@Override
public boolean execute() {
if (this.location != null) {
TeleportAction.teleport(this.location, this);
}
return true;
}
@Override
public void save(DataOutputStream dos) throws IOException {
super.save(dos);
if (this.location == null) {
dos.writeUTF("");
} else {
dos.writeUTF(this.location);
}
}
@Override
public void load(DataInputStream dis) throws IOException {
super.load(dis);
this.location = dis.readUTF();
if (this.location.equals("")) {
this.location = null;
}
}
@Override
public void teleportStatus(String err, String targetURL) {
Pilot p = Pilot.getActive();
if (p instanceof HoloPilot) {
HoloPilot hp = (HoloPilot)p;
Drone d = hp.getInternalDrone();
if (d != null) {
short dir = (short)(-p.getYaw() + 90.0F);
dir = (short)(dir % 360);
while (dir < 0) {
dir = (short)(dir + 360);
}
dir = (short)(90 - dir);
dir = (short)(360 - dir);
Point3Temp pos = p.getPosition();
d.reset((short)pos.x, (short)pos.y, (short)p.getFootHeight(), dir);
}
}
if (err == null) {
this.doCallback(true);
} else {
this.doCallback(false);
}
}
}
|