1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3 // --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4 import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5 // --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6
7
8 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9
10 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11
12 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] BEGIN
13
14 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15
16 /**
17 *
18 Definition of the event PLI.
19
20 *
21 * <p></p><p></p>
22 * Complete message documentation:
23 *
24 Aynchronous message. When the player has our bot selected by mouse cursor, he can provide the bot with key input (keys 0 - 9 represented by int 0-9 and key T represented by 10). If the player has some dialog on the HUD, Id of the dialog will be sent (if any).
25
26 */
27 public class PlayerInput
28 extends InfoMessage
29 implements IWorldEvent, IWorldChangeEvent
30
31 {
32
33 /** Example how the message looks like - used during parser tests. */
34 public static final String PROTOTYPE =
35 "PLI {Id unreal_id} {DialogId text} {Key 0} ";
36
37
38
39 /**
40 * Parameter-less contructor for the message.
41 */
42 public PlayerInput()
43 {
44 }
45
46
47
48
49 /**
50 * Creates new instance of the message PlayerInput.
51 *
52 Aynchronous message. When the player has our bot selected by mouse cursor, he can provide the bot with key input (keys 0 - 9 represented by int 0-9 and key T represented by 10). If the player has some dialog on the HUD, Id of the dialog will be sent (if any).
53
54 * Corresponding GameBots message
55 *
56 * is
57 * PLI.
58 *
59 *
60 *
61 * @param Id
62 Id of the player that sent the input.
63
64 *
65 *
66 *
67 * @param DialogId
68 An Id of the dialog (if set any) that the player has visible on the HUD. This attribute won't be sent at all if DialogId is "" or if no dialog on player HUD.
69
70 *
71 *
72 *
73 * @param Key
74 Which key was pressed. Supported keys: 0 - 9 represented by int 0-9 and key T represented by 10/
75
76 *
77 *
78 */
79 public PlayerInput(
80 UnrealId Id, String DialogId, int Key
81 ) {
82
83 this.Id = Id;
84
85 this.DialogId = DialogId;
86
87 this.Key = Key;
88
89 }
90
91 /**
92 * Cloning constructor from the full message.
93 *
94 * @param original
95 */
96 public PlayerInput(PlayerInput original) {
97
98 this.Id = original.getId()
99 ;
100
101 this.DialogId = original.getDialogId()
102 ;
103
104 this.Key = original.getKey()
105 ;
106
107 this.SimTime = original.getSimTime();
108 }
109
110
111 protected long SimTime;
112
113 /**
114 * Simulation time in MILLI SECONDS !!!
115 */
116 @Override
117 public long getSimTime() {
118 return SimTime;
119 }
120
121 /**
122 * Used by Yylex to slip correct time of the object or programmatically.
123 */
124 protected void setSimTime(long SimTime) {
125 this.SimTime = SimTime;
126 }
127
128
129 /**
130 *
131 Id of the player that sent the input.
132
133 */
134 protected
135 UnrealId Id =
136 null;
137
138 /**
139 *
140 Id of the player that sent the input.
141
142 */
143 public UnrealId getId()
144 {
145 return Id;
146 }
147
148
149 /**
150 *
151 An Id of the dialog (if set any) that the player has visible on the HUD. This attribute won't be sent at all if DialogId is "" or if no dialog on player HUD.
152
153 */
154 protected
155 String DialogId =
156 null;
157
158 /**
159 *
160 An Id of the dialog (if set any) that the player has visible on the HUD. This attribute won't be sent at all if DialogId is "" or if no dialog on player HUD.
161
162 */
163 public String getDialogId()
164 {
165 return DialogId;
166 }
167
168
169 /**
170 *
171 Which key was pressed. Supported keys: 0 - 9 represented by int 0-9 and key T represented by 10/
172
173 */
174 protected
175 int Key =
176 0;
177
178 /**
179 *
180 Which key was pressed. Supported keys: 0 - 9 represented by int 0-9 and key T represented by 10/
181
182 */
183 public int getKey()
184 {
185 return Key;
186 }
187
188
189 public String toString() {
190 return
191 super.toString() + "[" +
192
193 "Id = " + String.valueOf(getId()
194 ) + " | " +
195
196 "DialogId = " + String.valueOf(getDialogId()
197 ) + " | " +
198
199 "Key = " + String.valueOf(getKey()
200 ) + " | " +
201
202 "]";
203 }
204
205
206 public String toHtmlString() {
207 return super.toString() + "[<br/>" +
208
209 "<b>Id</b> = " + String.valueOf(getId()
210 ) + " <br/> " +
211
212 "<b>DialogId</b> = " + String.valueOf(getDialogId()
213 ) + " <br/> " +
214
215 "<b>Key</b> = " + String.valueOf(getKey()
216 ) + " <br/> " +
217
218 "<br/>]";
219 }
220
221 public String toJsonLiteral() {
222 return "PlayerInput(null, "
223
224 + ")";
225 }
226
227
228 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
229
230 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
231
232 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
233
234 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
235
236 }
237