1 package cz.cuni.amis.pogamut.defcon.communication.messages.infos;
2
3 import cz.cuni.amis.pogamut.base.communication.worldview.object.IWorldObject;
4 import cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectId;
5 import cz.cuni.amis.pogamut.defcon.communication.messages.Updatable;
6 import cz.cuni.amis.pogamut.defcon.consts.UnitType;
7
8
9
10
11
12
13
14
15 public abstract class DefConObject implements IWorldObject {
16
17
18
19 private WorldObjectId id;
20
21
22
23
24 private UnitType type;
25
26
27
28
29 @Updatable
30 private double time;
31
32
33
34
35 private boolean destroyed = false;
36
37
38
39
40
41
42
43
44 public DefConObject(int id, UnitType type, double time) {
45 this.id = WorldObjectId.get(id);
46 this.type = type;
47 this.time = time;
48 }
49
50
51
52
53
54
55 public DefConObject(DefConObject original) {
56 this.id = original.getId();
57 this.type = original.type;
58 this.time = original.time;
59 }
60
61
62
63
64
65
66 @Override
67 public WorldObjectId getId() {
68 return id;
69 }
70
71
72
73
74
75
76 public UnitType getType() {
77 return type;
78 }
79
80
81
82
83
84
85 public double getLastSeenTime() {
86 return time;
87 }
88
89
90
91
92
93
94 protected void setLastSeenTime(double time) {
95 this.time = time;
96 }
97
98
99
100
101
102
103 @Override
104 public long getSimTime() {
105 return (long) time;
106 }
107
108
109
110
111
112
113 public DefConObjectUpdate createUpdateEvent() {
114 return new DefConObjectUpdate(this);
115 }
116
117
118
119
120
121
122 public DefConObjectUpdate createDestroyedEvent() {
123 destroyed = true;
124
125 return createUpdateEvent();
126 }
127
128
129
130
131
132
133 public boolean getDestroyed() {
134 return destroyed;
135 }
136
137
138
139
140
141
142 public String getStringizedFields() {
143 return "id: " + id.toString() + "; type: " + type.toString() + "; time: " + time;
144 }
145 }