Emergency 20 Dokumentation  4.2.0
CommandableComponent.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
16 
18 #include <qsf/job/JobProxy.h>
19 
20 #include <boost/container/flat_set.hpp>
21 
22 
23 //[-------------------------------------------------------]
24 //[ Forward declarations ]
25 //[-------------------------------------------------------]
26 namespace qsf
27 {
28  class JobArguments;
29 }
30 
31 
32 //[-------------------------------------------------------]
33 //[ Namespace ]
34 //[-------------------------------------------------------]
35 namespace em5
36 {
37 
38 
39  //[-------------------------------------------------------]
40  //[ Classes ]
41  //[-------------------------------------------------------]
47  {
48 
49 
50  //[-------------------------------------------------------]
51  //[ Public definitions ]
52  //[-------------------------------------------------------]
53  public:
54  static const uint32 COMPONENT_ID;
55 
56  // Departments
57  static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_FIREFIGHTERS; // "Firefighter" tag
58  static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_POLICE; // "Police" tag
59  static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_TECH; // "Tech" tag
60  static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_AMBULANCE; // "Ambulance" tag
61 
62  // Unit categories
63  static const qsf::NamedIdentifier UNITTAG_CATEGORY_PERSON; // "Person" tag for all persons
64  static const qsf::NamedIdentifier UNITTAG_CATEGORY_VEHICLE; // "Vehicle" tag for all kinds of vehicles
65  static const qsf::NamedIdentifier UNITTAG_CATEGORY_ROAD; // "Road" tag for road vehicles
66  static const qsf::NamedIdentifier UNITTAG_CATEGORY_BOAT; // "Boat" tag for ships and boats
67  static const qsf::NamedIdentifier UNITTAG_CATEGORY_HELI; // "Heli" tag for helicopters, drones and planes
68 
69  // Firefighter units
72  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DEKONP; // "DeKon-P" tag
76  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_BOAT; // "FirefightersMotorboat" tag
80  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DRONE; // "FirefightersDrone" tag
82  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_RW_HISTORIC; // "RW_Historic" tag
83 
84  // Firefighter units
85  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FIREFIGHTER; // "Firefighter" tag
86  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FIREFIGHTER_ABC; // "Firefighter_ABC" tag
87  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DIVER; // "Diver" tag
88  static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FIREFIGHTER_HISTORIC;// "Firefighter_Historic" tag
89 
90  // Police cars
91  static const qsf::NamedIdentifier UNITTAG_POLICE_MTW; // "MTW" tag
92  static const qsf::NamedIdentifier UNITTAG_POLICE_HELI; // "PHC" tag
93  static const qsf::NamedIdentifier UNITTAG_POLICE_SEK_HELI; // "SEKHC" tag
94  static const qsf::NamedIdentifier UNITTAG_POLICE_STW; // "STW" tag
96  static const qsf::NamedIdentifier UNITTAG_POLICE_DRONE; // "SEKD" tag
98  static const qsf::NamedIdentifier UNITTAG_POLICE_ROBOT; // "SEKR" tag
99  static const qsf::NamedIdentifier UNITTAG_POLICE_DOGCAR; // "PHF" tag
100 
101  // Police units
102  static const qsf::NamedIdentifier UNITTAG_POLICE_POLICE; // "Police" tag
103  static const qsf::NamedIdentifier UNITTAG_POLICE_SEK; // "SEKPolice" tag
104  static const qsf::NamedIdentifier UNITTAG_POLICE_POLICEDOG_LEADER; // "PoliceDogLeader" tag
105  static const qsf::NamedIdentifier UNITTAG_POLICE_POLICEDOG; // "PoliceDog" tag
106  static const qsf::NamedIdentifier UNITTAG_POLICE_GUARDSMAN_HISTORIC; // "Guardsman_Historic" tag
107 
108  // Tech cars
109  static const qsf::NamedIdentifier UNITTAG_TECH_TOWCAR; // "ASF" tag
111  static const qsf::NamedIdentifier UNITTAG_TECH_CRANE; // "BFZ" tag
112  static const qsf::NamedIdentifier UNITTAG_TECH_HELI; // "BHC" tag
113 
114  // Tech units
115  static const qsf::NamedIdentifier UNITTAG_TECH_ENGINEER; // "Engineer" tag
116 
117  // Ambulance cars
118  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_NEF; // "NEF" tag
119  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_RTW; // "RTW" tag
120  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_HELI; // "RHC" tag
122  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_IMT; // "IMT" tag
123 
124  // Ambulance units
125  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_DOCTOR; // "Doctor" tag
126  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_PARAMEDICS; // "Paramedics" tag
127  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_RESCUEDOG_LEADER; // "RescueDogLeader" tag
128  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_RESCUEDOG; // "RescueDog" tag
129  static const qsf::NamedIdentifier UNITTAG_AMBULANCE_DOCTOR_HISTORIC; // "Doctor_Historic" tag
130 
131  // Misc units
132  static const qsf::NamedIdentifier UNITTAG_MISC_CONVOITRUCK; // "ConvoiTruck" tag for ME104
133  static const qsf::NamedIdentifier UNITTAG_MISC_AMBULANCEBUS; // "AmbulanceBus" tag for ME310
134  static const qsf::NamedIdentifier UNITTAG_MISC_EVACBUS; // "EvacBus" tag for ME310
135 
136  // Special unit tags
137  static const qsf::NamedIdentifier UNITTAG_CAN_TRANSPORT_INJUREDS; // "CanTransportInjureds" for modded ambulance vehicles
138  static const qsf::NamedIdentifier UNITTAG_CAN_TRANSPORT_GANGSTERS; // "CanTransportGangsters" for modded police vehicles
139 
140  // Minimap icons
141  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_AMBULANCE; // "Ambulance" minimap icon identifier
142  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_FIREFIGHTER; // "Firefighter" minimap icon identifier
143  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_POLICE; // "Police" minimap icon identifier
144  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_TECH; // "Tech" minimap icon identifier
145  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_AMBULANCE_DOG; // "AmbulanceDog" minimap icon identifier
146  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_POLICE_DOG; // "PoliceDog" minimap icon identifier
147  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_MEDIEVAL; // "Medieval" minimap icon identifier
148 
149  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_AMBULANCE; // "AmbulanceVehicle" minimap icon identifier
150  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_FIREFIGHTER; // "FirefighterVehicle" minimap icon identifier
151  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_POLICE; // "PoliceVehicle" minimap icon identifier
152  static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_TECH; // "TechVehicle" minimap icon identifier
153 
154 
155  //[-------------------------------------------------------]
156  //[ Public methods ]
157  //[-------------------------------------------------------]
158  public:
166  explicit CommandableComponent(qsf::Prototype* prototype);
167 
172  virtual ~CommandableComponent();
173 
178  uint32 getPlayerId() const;
179 
187  void setPlayerId(uint32 playerId);
188 
193  uint16 getTeamId() const;
194 
202  void setTeamId(uint16 teamId);
203 
208  uint32 getSpeakerIndex() const;
209 
214  void setSpeakerIndex(uint32 speakerIndex);
215 
220  const std::string& getUnitTagsAsString() const;
221 
226  void setUnitTagsAsString(const std::string& unitTags);
227 
232  bool hasUnitTag(const qsf::StringHash& tag) const;
233 
241  const std::string& getMiniMapIconType() const;
242 
247  void setMiniMapIconType(const std::string& miniMapIconType);
248 
253  void delayedShineThrough();
254 
255  bool isUnitType(const qsf::StringHash& unitTypeId) const;
256  bool isAmbulanceNEF() const;
257  bool isAmbulanceRTW() const;
258  bool isAmbulanceIMT() const;
259  bool isAmbulanceHeli() const;
260  bool isAmbulanceDoctor() const;
261  bool isAmbulanceParamedics() const;
262  bool isAmbulanceRescueDogLeader() const;
263  bool isAmbulanceRescueDog() const;
264 
265  bool isPoliceSTW() const;
266  bool isPoliceMTW() const;
267  bool isPoliceHeli() const;
268  bool isPoliceSEKHeli() const;
269  bool isPolicePerson() const;
270  bool isPoliceSEKPerson() const;
271  bool isPoliceTSEKR() const;
272  bool isPoliceSEKR() const;
273  bool isPoliceSEKDrone() const;
274  bool isPoliceDogCar() const;
275  bool isPoliceDogLeader() const;
276  bool isPoliceDog() const;
277  bool isPoliceGuardsmanHistoric() const;
278 
279  bool isFireFighterRW() const;
280  bool isFireFighterDECONP() const;
281  bool isFireFighterPerson() const;
282  bool isFireFighterPersonHistoric() const;
283  bool isFireFighterDLK() const;
284  bool isFireFighterDiver() const;
285  bool isFireFighterBoat() const;
286  bool isFireFighterBoatTransport() const;
287  bool isFireFighterFLB() const;
288  bool isFireFighterDrone() const;
289 
290  bool isTechEngineer() const;
291  bool isTechEngineerCar() const;
292  bool isTechTowcar() const;
293  bool isTechHeli() const;
294  bool isTechCrane() const;
295 
296  bool canTransportGangster() const;
297  bool canTransportInjured() const;
298 
299  bool canSwim() const;
300 
301 
302  //[-------------------------------------------------------]
303  //[ Public virtual qsf::game::CommandableComponent methods]
304  //[-------------------------------------------------------]
305  public:
306  virtual void setUnitType(uint32 unitType) override;
307 
308 
309  //[-------------------------------------------------------]
310  //[ Public virtual qsf::Component methods ]
311  //[-------------------------------------------------------]
312  public:
313  virtual void serialize(qsf::BinarySerializer& serializer) override;
314 
315 
316  //[-------------------------------------------------------]
317  //[ Private methods ]
318  //[-------------------------------------------------------]
319  private:
320  void updateDelayedJob(const qsf::JobArguments& jobArguments);
321  const std::string& getUnitTagName() const;
322 
323 
324  //[-------------------------------------------------------]
325  //[ Private data ]
326  //[-------------------------------------------------------]
327  private:
328  // Connected to CAMP
329  uint32 mPlayerId;
330  std::string mUnitTagsString;
331  std::string mMiniMapIconType;
332 
333  // Internal
334  boost::container::flat_set<uint32> mUnitTags;
335  uint32 mSpeakerIndex;
336  uint16 mPlayerTeamId;
337  qsf::JobProxy mDelayedJobProxy;
338  float mSecondsPassed;
339 
340 
341  //[-------------------------------------------------------]
342  //[ CAMP reflection system ]
343  //[-------------------------------------------------------]
344  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
345 
346 
347  };
348 
349 
350 //[-------------------------------------------------------]
351 //[ Namespace ]
352 //[-------------------------------------------------------]
353 } // em5
354 
355 
356 //[-------------------------------------------------------]
357 //[ CAMP reflection system ]
358 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
static const qsf::NamedIdentifier UNITTAG_POLICE_POLICEDOG_LEADER
Definition: CommandableComponent.h:104
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_MEDIEVAL
Definition: CommandableComponent.h:147
Job proxy class.
Definition: JobProxy.h:51
static const qsf::NamedIdentifier UNITTAG_POLICE_POLICE
Definition: CommandableComponent.h:102
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DRONE_TRANSPORT
Definition: CommandableComponent.h:79
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_TECH
Definition: CommandableComponent.h:144
unsigned int uint32
Definition: PlatformTypes.h:181
static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_AMBULANCE
Definition: CommandableComponent.h:60
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DLK
Definition: CommandableComponent.h:73
static const qsf::NamedIdentifier UNITTAG_MISC_CONVOITRUCK
Definition: CommandableComponent.h:132
static const qsf::NamedIdentifier UNITTAG_POLICE_MTW
Definition: CommandableComponent.h:91
static const qsf::NamedIdentifier UNITTAG_POLICE_ROBOT_TRANSPORT
Definition: CommandableComponent.h:97
static const qsf::NamedIdentifier UNITTAG_POLICE_SEK_HELI
Definition: CommandableComponent.h:93
static const qsf::NamedIdentifier UNITTAG_POLICE_POLICEDOG
Definition: CommandableComponent.h:105
#define EM5_API_EXPORT
Definition: Export.h:28
static const qsf::NamedIdentifier UNITTAG_CATEGORY_VEHICLE
Definition: CommandableComponent.h:64
static const qsf::NamedIdentifier UNITTAG_CATEGORY_ROAD
Definition: CommandableComponent.h:65
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DEKONP
Definition: CommandableComponent.h:72
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_RTW
Definition: CommandableComponent.h:119
static const qsf::NamedIdentifier UNITTAG_POLICE_ROBOT
Definition: CommandableComponent.h:98
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_TLF
Definition: CommandableComponent.h:71
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_FIREFIGHTER
Definition: CommandableComponent.h:150
static const qsf::NamedIdentifier UNITTAG_TECH_HELI
Definition: CommandableComponent.h:112
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_RESCUEDOG
Definition: CommandableComponent.h:128
static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_TECH
Definition: CommandableComponent.h:59
static const qsf::NamedIdentifier UNITTAG_CATEGORY_PERSON
Definition: CommandableComponent.h:63
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_RW_HISTORIC
Definition: CommandableComponent.h:82
static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_POLICE
Definition: CommandableComponent.h:58
static const qsf::NamedIdentifier UNITTAG_CAN_TRANSPORT_GANGSTERS
Definition: CommandableComponent.h:138
Commandable component class.
Definition: CommandableComponent.h:37
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
static const qsf::NamedIdentifier UNITTAG_POLICE_DRONE_TRANSPORT
Definition: CommandableComponent.h:95
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_AMBULANCE_DOG
Definition: CommandableComponent.h:145
static const qsf::NamedIdentifier UNITTAG_POLICE_DOGCAR
Definition: CommandableComponent.h:99
static const qsf::NamedIdentifier UNITTAG_POLICE_STW
Definition: CommandableComponent.h:94
static const qsf::NamedIdentifier UNITTAG_MISC_AMBULANCEBUS
Definition: CommandableComponent.h:133
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DIVER
Definition: CommandableComponent.h:87
Definition: PickupPersonByParamedicAction.h:21
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_PARAMEDICS
Definition: CommandableComponent.h:126
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FIREFIGHTER_ABC
Definition: CommandableComponent.h:86
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_BOAT_TRANSPORT
Definition: CommandableComponent.h:75
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_RESCUEDOG_LEADER
Definition: CommandableComponent.h:127
static const qsf::NamedIdentifier UNITTAG_TECH_CRANE
Definition: CommandableComponent.h:111
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FIREFIGHTER
Definition: CommandableComponent.h:85
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_RESCUEDOGCAR
Definition: CommandableComponent.h:121
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FIREFIGHTER_HISTORIC
Definition: CommandableComponent.h:88
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_POLICE_DOG
Definition: CommandableComponent.h:146
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_DOCTOR
Definition: CommandableComponent.h:125
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_DOCTOR_HISTORIC
Definition: CommandableComponent.h:129
static const qsf::NamedIdentifier UNITTAG_MISC_EVACBUS
Definition: CommandableComponent.h:134
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_RW
Definition: CommandableComponent.h:70
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_POLICE
Definition: CommandableComponent.h:151
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_AMBULANCE
Definition: CommandableComponent.h:141
static const qsf::NamedIdentifier UNITTAG_DEPARTMENT_FIREFIGHTERS
Definition: CommandableComponent.h:57
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
static const qsf::NamedIdentifier UNITTAG_TECH_ENGINEER
Definition: CommandableComponent.h:115
static const qsf::NamedIdentifier UNITTAG_POLICE_GUARDSMAN_HISTORIC
Definition: CommandableComponent.h:106
unsigned short uint16
Definition: PlatformTypes.h:178
static const qsf::NamedIdentifier UNITTAG_CAN_TRANSPORT_INJUREDS
Definition: CommandableComponent.h:137
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FLB
Definition: CommandableComponent.h:74
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_IMT
Definition: CommandableComponent.h:122
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_NEF
Definition: CommandableComponent.h:118
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_POLICE
Definition: CommandableComponent.h:143
static const qsf::NamedIdentifier UNITTAG_POLICE_DRONE
Definition: CommandableComponent.h:96
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DIVER_TRANSPORT
Definition: CommandableComponent.h:81
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_FIREPLANE
Definition: CommandableComponent.h:78
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_FIREFIGHTER
Definition: CommandableComponent.h:142
Class combining strings with their hashes.
Definition: NamedIdentifier.h:34
Prototype class.
Definition: Prototype.h:100
static const qsf::NamedIdentifier UNITTAG_AMBULANCE_HELI
Definition: CommandableComponent.h:120
static const qsf::NamedIdentifier UNITTAG_POLICE_HELI
Definition: CommandableComponent.h:92
Compile time string hash class.
Definition: StringHash.h:59
static const qsf::NamedIdentifier UNITTAG_POLICE_SEK
Definition: CommandableComponent.h:103
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_DRONE
Definition: CommandableComponent.h:80
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_TECH
Definition: CommandableComponent.h:152
Binary serializer class.
Definition: BinarySerializer.h:35
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_BOAT
Definition: CommandableComponent.h:76
Commandable component class.
Definition: CommandableComponent.h:46
static const qsf::NamedIdentifier UNITTAG_FIREFIGHTERS_COMMANDOCAR
Definition: CommandableComponent.h:77
static const uint32 COMPONENT_ID
"em5::CommandableComponent" unique component ID
Definition: CommandableComponent.h:54
static const qsf::NamedIdentifier UNITTAG_CATEGORY_BOAT
Definition: CommandableComponent.h:66
static const qsf::NamedIdentifier UNITTAG_TECH_ENGINEERCAR
Definition: CommandableComponent.h:110
static const qsf::NamedIdentifier UNITTAG_CATEGORY_HELI
Definition: CommandableComponent.h:67
static const qsf::NamedIdentifier MINIMAP_ICON_UNIT_VEHICLE_AMBULANCE
Definition: CommandableComponent.h:149
static const qsf::NamedIdentifier UNITTAG_TECH_TOWCAR
Definition: CommandableComponent.h:109