summaryrefslogtreecommitdiff
path: root/NET/worlds/console/BBAppearDroneCommand.java
blob: 1a12af45e54b4a8bc1836aa012f3b0197b837b06 (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
package NET.worlds.console;

import NET.worlds.scape.HoloDrone;
import NET.worlds.scape.Room;
import NET.worlds.scape.World;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class BBAppearDroneCommand extends BlackBoxCommand {
   private short x;
   private short y;
   private short z;
   private short dir;
   private String room;
   private String name;

   public BBAppearDroneCommand(String roomName, String pName, short px, short py, short pz, short pdir) {
      this();
      this.x = px;
      this.y = py;
      this.z = pz;
      this.dir = pdir;
      this.room = new String(roomName);
      this.name = new String(pName);
   }

   public BBAppearDroneCommand() {
      this.commandType = 5;
   }

   @Override
   public boolean execute() {
      HoloDrone d = new HoloDrone(null, null);
      d.setName(this.name);
      Room r = World.findRoomByName(this.room);
      if (r != null) {
         d.appear(r, this.x, this.y, this.z, this.dir);
         d.makeTag(true);
         ArmyOfZombies.instance().addZombie(d);
         this.doCallback(true);
      } else {
         this.doCallback(false);
      }

      return true;
   }

   @Override
   public void save(DataOutputStream dos) throws IOException {
      super.save(dos);
      dos.writeShort(this.x);
      dos.writeShort(this.y);
      dos.writeShort(this.z);
      dos.writeShort(this.dir);
      dos.writeUTF(this.room);
      dos.writeUTF(this.name);
   }

   @Override
   public void load(DataInputStream dis) throws IOException {
      super.load(dis);
      this.x = dis.readShort();
      this.y = dis.readShort();
      this.z = dis.readShort();
      this.dir = dis.readShort();
      this.room = new String(dis.readUTF());
      this.name = new String(dis.readUTF());
   }
}