1 package cz.cuni.amis.pogamut.defcon.communication.messages.infos;
2
3 import cz.cuni.amis.pogamut.defcon.base3d.worldview.object.DefConLocation;
4 import cz.cuni.amis.pogamut.defcon.communication.messages.Updatable;
5 import cz.cuni.amis.pogamut.defcon.consts.UnitType;
6 import cz.cuni.amis.pogamut.defcon.consts.state.IState;
7
8
9 /*
10 * Basic object for all units
11 *
12 * @author Jimmy
13 * @author Black_Hand
14 */
15 /**
16 * DOCUMENT ME!
17 *
18 * @author $author$
19 * @version $Revision$
20 *
21 * @param <T> DOCUMENT ME!
22 */
23 public class DefConUnitObject<T extends IState> extends DefConViewableObject {
24 /**
25 * Current state of of the object. Exposed by getState().
26 */
27 @Updatable
28 private T state;
29
30 /**
31 * Current count of activations of units state. Exposed by getStateCount().
32 */
33 @Updatable
34 private int stateCount;
35
36 /**
37 * Current target of this unit. Exposed by getTarget().
38 */
39 @Updatable
40 private int target;
41
42 /**
43 * Construtor of DefConUnitObject.
44 *
45 * @param id
46 * @param type DOCUMENT ME!
47 * @param teamId DOCUMENT ME!
48 * @param location DOCUMENT ME!
49 * @param visible visibility of this object
50 * @param state observed state of UnitObject
51 * @param stateCount DOCUMENT ME!
52 * @param target DOCUMENT ME!
53 * @param time
54 */
55 public DefConUnitObject(int id, UnitType type, int teamId, DefConLocation location,
56 boolean visible, T state, int stateCount, int target, double time) {
57 super(id, type, teamId, location, visible, time);
58
59 this.state = state;
60 this.stateCount = stateCount;
61 this.target = target;
62 }
63
64 /**
65 * Creates a new DefConUnitObject object.
66 *
67 * @param original DOCUMENT ME!
68 */
69 public DefConUnitObject(DefConUnitObject<T> original) {
70 super(original);
71
72 this.state = original.state;
73 this.stateCount = original.stateCount;
74 this.target = original.target;
75 }
76
77 /**
78 * Gets current state of the object.
79 *
80 * @return state
81 */
82 public T getState() {
83 return state;
84 }
85
86 /**
87 * Sets current state of the object.
88 *
89 * @param state
90 */
91 protected void setState(T state) {
92 this.state = state;
93 }
94
95 /**
96 * Gets number of activations of this object's state.
97 *
98 * @return activations
99 */
100 public int getStateCount() {
101 return stateCount;
102 }
103
104 /**
105 * Sets number of activations of this object's state.
106 *
107 * @param stateCount activation
108 */
109 protected void setStateCount(int stateCount) {
110 this.stateCount = stateCount;
111 }
112
113 /**
114 * Gets current target of this object.
115 *
116 * @return
117 */
118 public int getTarget() {
119 return target;
120 }
121
122 /**
123 * Sets current target of this object.
124 *
125 * @param target
126 */
127 protected void setTarget(int target) {
128 this.target = target;
129 }
130
131 /**
132 * DOCUMENT ME!
133 *
134 * @return DOCUMENT ME!
135 */
136 @Override
137 public String getStringizedFields() {
138 return super.getStringizedFields() + "; state: " +
139 ((state != null) ? state.toString() : "none") + "; stateCount: " + stateCount +
140 "; target: " + target;
141 }
142 }