1
2
3
4
5
6
7
8
9 package cz.cuni.amis.pogamut.defcon.communication.messages.commands;
10
11 import cz.cuni.amis.pogamut.base.communication.messages.*;
12 import cz.cuni.amis.pogamut.base.communication.worldview.*;
13 import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
14 import cz.cuni.amis.pogamut.defcon.base3d.worldview.object.DefConLocation;
15 import cz.cuni.amis.pogamut.defcon.communication.messages.*;
16 import cz.cuni.amis.pogamut.defcon.communication.messages.commands.*;
17 import cz.cuni.amis.pogamut.defcon.communication.messages.infos.*;
18 import cz.cuni.amis.pogamut.defcon.consts.*;
19 import cz.cuni.amis.pogamut.defcon.consts.state.*;
20 import cz.cuni.amis.utils.exception.*;
21
22 import java.util.*;
23
24 import javabot.*;
25
26
27
28
29
30 public class SetActionTarget extends DefConCommand {
31
32
33
34 private int unitId = 0;
35
36
37
38
39 private int targetUnitId = 0;
40
41
42
43
44 private DefConLocation location = null;
45
46
47
48
49
50
51
52
53
54
55
56
57
58 public SetActionTarget(int unitId, int targetUnitId, DefConLocation location) {
59 this.unitId = unitId;
60
61 this.targetUnitId = targetUnitId;
62
63 this.location = location;
64 }
65
66
67
68
69
70 public SetActionTarget(SetActionTarget original) {
71 this.unitId = original.unitId;
72
73 this.targetUnitId = original.targetUnitId;
74
75 this.location = original.location;
76 }
77
78
79
80
81
82
83 public int getUnitId() {
84 return this.unitId;
85 }
86
87
88
89
90
91
92
93
94 public SetActionTarget setUnitId(int unitId) {
95 this.unitId = unitId;
96
97 return this;
98 }
99
100
101
102
103
104
105 public int getTargetUnitId() {
106 return this.targetUnitId;
107 }
108
109
110
111
112
113
114
115
116 public SetActionTarget setTargetUnitId(int targetUnitId) {
117 this.targetUnitId = targetUnitId;
118
119 return this;
120 }
121
122
123
124
125
126
127 public DefConLocation getLocation() {
128 return this.location;
129 }
130
131
132
133
134
135
136
137
138 public SetActionTarget setLocation(DefConLocation location) {
139 this.location = location;
140
141 return this;
142 }
143
144
145
146
147 @Override
148 public void perform() {
149 DefConLocation location = getLocation();
150
151 if (location == null) {
152 JBot.SetActionTarget(getUnitId(), getTargetUnitId(), 0f, 0f);
153 } else {
154 JBot.SetActionTarget(getUnitId(), getTargetUnitId(), (float) location.getX(),
155 (float) location.getY());
156 }
157 }
158
159
160
161
162
163
164 @Override
165 public String toString() {
166 return "SetActionTarget[" + getStringizedFields() + "; UnitId = " + this.unitId +
167 "; TargetUnitId = " + this.targetUnitId + "; Location = " + this.location + "]";
168 }
169
170
171
172
173
174
175 public String toHtmlString() {
176 return "<p><b>SetActionTarget:</b></p>" + "<p><i>UnitId:</i> " + this.unitId + "</p>" +
177 "<p><i>TargetUnitId:</i> " + this.targetUnitId + "</p>" + "<p><i>Location:</i> " +
178 this.location + "</p>";
179 }
180 }