1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3
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
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public abstract class BombInfoLocal
29 extends InfoMessage
30 implements ILocalWorldObject
31
32 ,ILocalGBViewable
33 {
34
35
36
37
38
39
40 public BombInfoLocal()
41 {
42 }
43
44
45
46
47 protected long SimTime;
48
49
50
51
52 @Override
53 public long getSimTime() {
54 return SimTime;
55 }
56
57
58
59
60 protected void setSimTime(long SimTime) {
61 this.SimTime = SimTime;
62 }
63
64
65 @Override
66 public abstract
67 BombInfoLocal clone();
68
69 @Override
70 public Class getCompositeClass() {
71 return BombInfo.class;
72 }
73
74
75
76
77
78
79
80
81 public abstract UnrealId getId()
82 ;
83
84
85
86
87 public abstract boolean isVisible()
88 ;
89
90
91
92
93 public BombInfoLocal getLocal() {
94 return this;
95 }
96 public ISharedWorldObject getShared() {
97 throw new UnsupportedOperationException("Could not return LOCAL");
98 }
99 public IStaticWorldObject getStatic() {
100 throw new UnsupportedOperationException("Could not return LOCAL");
101 }
102
103
104 @Override
105 public ILocalWorldObjectUpdatedEvent createDisappearEvent() {
106 return new ObjectDisappeared(this, getSimTime());
107 }
108
109 public static class ObjectDisappeared implements ILocalWorldObjectUpdatedEvent
110 {
111
112 public ObjectDisappeared(BombInfoLocal obj, long time) {
113 this.obj = obj;
114 this.time = time;
115 }
116
117 private BombInfoLocal obj;
118 private long time;
119
120 @Override
121 public WorldObjectId getId() {
122 return obj.getId();
123 }
124
125
126
127
128 @Override
129 public long getSimTime() {
130 return time;
131 }
132
133 @Override
134 public IWorldObjectUpdateResult<ILocalWorldObject> update(ILocalWorldObject obj)
135 {
136 if (obj == null) {
137 throw new PogamutException("Can't 'disappear' null!", this);
138 }
139 if (!(obj instanceof BombInfoLocalImpl)) {
140 throw new PogamutException("Can't update different class than BombInfoLocalImpl, got class " + obj.getClass().getSimpleName() + "!", this);
141 }
142 BombInfoLocalImpl toUpdate = (BombInfoLocalImpl)obj;
143 if (toUpdate.Visible) {
144 toUpdate.Visible = false;
145 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.UPDATED, obj);
146 } else {
147 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.SAME, obj);
148 }
149 }
150
151 }
152
153
154
155 public String toString() {
156 return
157 super.toString() + "[" +
158
159 "Id = " + String.valueOf(getId()
160 ) + " | " +
161
162 "Visible = " + String.valueOf(isVisible()
163 ) + " | " +
164
165 "]";
166 }
167
168
169 public String toHtmlString() {
170 return super.toString() + "[<br/>" +
171
172 "<b>Id</b> = " + String.valueOf(getId()
173 ) + " <br/> " +
174
175 "<b>Visible</b> = " + String.valueOf(isVisible()
176 ) + " <br/> " +
177
178 "<br/>]";
179 }
180
181
182
183
184
185
186
187
188
189
190 }
191