View Javadoc

1   /*
2      IMPORTANT !!!
3   
4      DO NOT EDIT THIS FILE. IT IS GENERATED FROM APPROPRIATE XML FILE
5      BY THE MessagesGenerator.xslt.
6      MODIFY THAT FILE INSTEAD OF THIS ONE.
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   * Places a structure of a specified type to a specified location.
29   */
30  public class PlaceStructure extends DefConCommand {
31      /**
32       * Id of unit to set target of.
33       */
34      private int typeId = 0;
35  
36      /**
37       * Target location of the structure.
38       */
39      private DefConLocation location = null;
40  
41  /**
42                       * Creates new instance of command PlaceStructure.
43                            
44                  Places a structure of a specified type to a specified location. 
45          
46                       @param
47                        typeId Id of unit to set target of.
48                       @param
49                        location Target location of the structure.
50                   */
51      public PlaceStructure(int typeId, DefConLocation location) {
52          this.typeId = typeId;
53  
54          this.location = location;
55      }
56  
57  /**
58                           * Cloning constructor...
59                           * @param original
60                           */
61      public PlaceStructure(PlaceStructure original) {
62          this.typeId = original.typeId;
63  
64          this.location = original.location;
65      }
66  
67      /**
68       * Id of unit to set target of.
69       *
70       * @return int
71       */
72      public int getTypeId() {
73          return this.typeId;
74      }
75  
76      /**
77       * Id of unit to set target of.
78       *
79       * @param typeId
80       *
81       * @return this object, allows you to chain setters
82       */
83      public PlaceStructure setTypeId(int typeId) {
84          this.typeId = typeId;
85  
86          return this;
87      }
88  
89      /**
90       * Target location of the structure.
91       *
92       * @return DefConLocation
93       */
94      public DefConLocation getLocation() {
95          return this.location;
96      }
97  
98      /**
99       * Target location of the structure.
100      *
101      * @param location
102      *
103      * @return this object, allows you to chain setters
104      */
105     public PlaceStructure setLocation(DefConLocation location) {
106         this.location = location;
107 
108         return this;
109     }
110 
111     /**
112      * Performs the command - to be used only by the {@link DefConCommandExecutor}.
113      */
114     @Override
115     public void perform() {
116         DefConLocation location = getLocation();
117         JBot.PlaceStructure(getTypeId(), (float) location.getX(), (float) location.getY());
118     }
119 
120     /**
121      * Returns human readable serialization of the message.
122      *
123      * @return human readable string
124      */
125     @Override
126     public String toString() {
127         return "PlaceStructure[" + getStringizedFields() + "; TypeId = " + this.typeId +
128         "; Location = " + this.location + "]";
129     }
130 
131     /**
132      * Returns message in html format.
133      *
134      * @return html message
135      */
136     public String toHtmlString() {
137         return "<p><b>PlaceStructure:</b></p>" + "<p><i>TypeId:</i> " + this.typeId + "</p>" +
138         "<p><i>Location:</i> " + this.location + "</p>";
139     }
140 }