Emergency 20 Dokumentation  4.2.0
EventIdComponent.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 //[-------------------------------------------------------]
15 
17 #include <qsf/math/EnumBitmask.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Namespace ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25 
26 
27  //[-------------------------------------------------------]
28  //[ Classes ]
29  //[-------------------------------------------------------]
35  {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Friends ]
40  //[-------------------------------------------------------]
41  friend class Objective; // To access and modify the mPlayerInteractedWith list
42 
43 
44  //[-------------------------------------------------------]
45  //[ Public definitions ]
46  //[-------------------------------------------------------]
47  public:
48  static const uint32 COMPONENT_ID;
49 
50 
51  //[-------------------------------------------------------]
52  //[ Public static methods ]
53  //[-------------------------------------------------------]
54  public:
55  static bool addToEvent(qsf::Entity& entity, FreeplayEvent& freeplayEvent, eventspreadreason::Reason reason);
56 
72  static bool tryLockForTeam(const qsf::Entity& targetEntity, const qsf::Entity& unitEntity);
73 
86  static void releaseTeamLock(const qsf::Entity& targetEntity, const qsf::Entity& unitEntity);
87 
100  static void releaseTeamLock(uint64 targetEntityId, qsf::Entity& unitEntity);
101 
118  static bool isUnlockedForTeam(const qsf::Entity& targetEntity, const qsf::Entity& unitEntity);
119 
136  static bool isUnlockedForTeam(const qsf::Entity& targetEntity, uint16 teamId);
137 
150  static void registerPlayer(const qsf::Entity& targetEntity, const qsf::Entity& unitEntity);
151 
152 
153  //[-------------------------------------------------------]
154  //[ Public methods ]
155  //[-------------------------------------------------------]
156  public:
161  explicit EventIdComponent(qsf::Prototype* prototype);
162 
167  inline ~EventIdComponent();
168 
173  uint32 getEventId() const;
174 
179  inline FreeplayEvent* getFreeplayEvent() const;
180 
193  bool setEvent(FreeplayEvent& freeplayEvent, eventspreadreason::Reason eventSpreadReason);
194 
205  void setEvent(FreeplayEvent& freeplayEvent);
206 
207 
208  //[-------------------------------------------------------]
209  //[ Object locking ]
210  //[-------------------------------------------------------]
211  void lockForTeam(uint64 unitEntityId, uint16 teamId);
212  void releaseTeamLock(uint64 unitEntityId, uint16 teamId);
213  bool isUnlockedForTeam(uint16 teamId);
214  uint16 getCurrentTeamId() const;
215  // This only needed for multiplay on client side
216  void setCurrentTeamId(uint16 teamId);
217 
218 
219  //[-------------------------------------------------------]
220  //[ Public virtual qsf::Component methods ]
221  //[-------------------------------------------------------]
222  public:
223  virtual void serialize(qsf::BinarySerializer& serializer) override;
224  virtual bool onStartup() override;
225  virtual void onShutdown() override;
226 
227 
228  //[-------------------------------------------------------]
229  //[ Private methods ]
230  //[-------------------------------------------------------]
231  private:
232  void registerPlayerAsInteractedWithMe(uint32 playerIndex);
233 
234 
235  //[-------------------------------------------------------]
236  //[ Private data ]
237  //[-------------------------------------------------------]
238  private:
239  qsf::WeakPtr<FreeplayEvent> mFreeplayEvent;
240  uint16 mCurrentTeamId;
241  std::vector<uint64> mCurrentPlayerRefCount;
242  uint8 mPlayerInteractedWithFlags;
243 
245  EventSpreadReasonBitmask mEventSpreadReasons;
246 
247 
248  //[-------------------------------------------------------]
249  //[ CAMP reflection system ]
250  //[-------------------------------------------------------]
251  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
252 
253 
254  };
255 
256 
257 //[-------------------------------------------------------]
258 //[ Namespace ]
259 //[-------------------------------------------------------]
260 } // em5
261 
262 
263 //[-------------------------------------------------------]
264 //[ Implementation ]
265 //[-------------------------------------------------------]
267 
268 
269 //[-------------------------------------------------------]
270 //[ CAMP reflection system ]
271 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Abstract component class.
Definition: Component.h:105
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Reason
Definition: EventSpreadReason.h:20
EMERGENCY 5 event ID component class.
Definition: EventIdComponent.h:34
uint64_t uint64
Definition: PlatformTypes.h:184
Lightweight weak pointer implementation.
Definition: WeakPtr.h:133
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
EMERGENCY 5 objective class.
Definition: Objective.h:51
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
static const uint32 COMPONENT_ID
"em5::EventIdComponent" unique component ID
Definition: EventIdComponent.h:48
unsigned short uint16
Definition: PlatformTypes.h:178
Prototype class.
Definition: Prototype.h:100
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Binary serializer class.
Definition: BinarySerializer.h:35
unsigned char uint8
Definition: PlatformTypes.h:175