Emergency 20 Dokumentation  4.2.0
BarrierTapeComponent.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 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace qsf
22 {
23  class Color4;
24  class Transform;
25 }
26 namespace em5
27 {
28  class SimpleBarrierTapeComponent;
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 
57  {
60  };
61 
62 
63  //[-------------------------------------------------------]
64  //[ Public methods ]
65  //[-------------------------------------------------------]
66  public:
74  explicit BarrierTapeComponent(qsf::Prototype* prototype);
75 
80  virtual ~BarrierTapeComponent();
81 
82  //[-------------------------------------------------------]
83  //[ Preview poles ]
84  //[-------------------------------------------------------]
89  bool createPole(uint32 poleIndex);
90 
98  void movePole(uint32 poleIndex, const glm::vec3& targetPosition);
99 
104  const glm::vec3& getPolePosition(uint32 poleIndex) const;
105 
110  bool isPolePositionValid(uint32 poleIndex) const;
111 
116  void createBarrier();
117 
122  bool isBarrier() const;
123 
128  qsf::Entity* getPoleEntity(uint32 poleIndex) const;
129 
134  uint32 getNumPoles() const;
135 
140  void setPoleTransparency(uint32 poleIndex, float transparency);
141 
146  float getPoleTransparency(uint32 poleIndex) const;
147 
152  void setTapeTransparency(float transparency);
153 
158  float getTapeTransparency() const;
159 
164  void setPoleMarker(uint32 poleIndex, const qsf::Color4& color);
165 
170  void deletePoleMarker(uint32 poleIndex);
171 
179  void createTape(TapeConnection tapeConnection, qsf::Entity* policeEntity = nullptr);
180 
185  bool hasTape() const;
186 
191  TapeConnection getTapeConnectionType() const;
192 
197  uint64 getTapeConnectionPoliceEntityId() const;
198 
203  void destroyTape();
204 
209  bool isFinishedBuilding() const;
210  void setFinishedBuilding(bool finished);
211 
216  glm::vec3 getBarrierCenter() const;
217 
218 
219  //[-------------------------------------------------------]
220  //[ Public virtual qsf::Component methods ]
221  //[-------------------------------------------------------]
222  public:
223  virtual void serialize(qsf::BinarySerializer& serializer) override;
224 
225 
226  //[-------------------------------------------------------]
227  //[ Protected virtual qsf::Component methods ]
228  //[-------------------------------------------------------]
229  protected:
230  virtual void onShutdown() override;
231 
232 
233  //[-------------------------------------------------------]
234  //[ Private methods ]
235  //[-------------------------------------------------------]
236  private:
237  // Cleanup the poles and tapes
238  void clearBarrier();
239 
240  // Is this a valid place to put up a pole?
241  bool isValidPolePos(uint32 poleIndex, const qsf::Transform& targetTransform) const;
242 
243  // Find the ground position for the given position
244  bool dropToGround(glm::vec3& position) const;
245 
246  bool isPoleCollisionValid(qsf::Entity& poleEntity, const qsf::Transform& targetTransform) const;
247  bool isPolePositionValid(const qsf::Transform& targetTransform) const;
248  bool isTapePositionValid(const glm::vec3& groundPos1, const glm::vec3& groundPos2) const;
249 
250  glm::quat getBarrierRotation() const;
251  float getBarrierLength() const;
252 
253 
254  //[-------------------------------------------------------]
255  //[ Private data ]
256  //[-------------------------------------------------------]
257  private:
258  // Poles for barrier tape commands/actions
259 
260  qsf::WeakPtr<qsf::Entity> mPoleEntities[2];
261  qsf::WeakPtr<SimpleBarrierTapeComponent> mConnectedBarrierTape;
262  qsf::WeakPtr<qsf::Entity> mClickEntity;
263  float mPoleTransparency[2];
264 
265  TapeConnection mTapeConnection;
266  uint64 mTapeConnectionPoliceEntityId;
267  float mTapeTransparency;
268 
269  bool mFinishedBuilding;
270  bool mIsBarrier;
271 
272 
273  //[-------------------------------------------------------]
274  //[ CAMP reflection system ]
275  //[-------------------------------------------------------]
276  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
277 
278 
279  };
280 
281 
282 //[-------------------------------------------------------]
283 //[ Namespace ]
284 //[-------------------------------------------------------]
285 } // em5
286 
287 
288 //[-------------------------------------------------------]
289 //[ CAMP reflection system ]
290 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 barrier tape component.
Definition: BarrierTapeComponent.h:46
Abstract component class.
Definition: Component.h:105
Entity class.
Definition: Entity.h:46
static const uint32 COMPONENT_ID
"em5::BarrierTapeComponent" unique component ID
Definition: BarrierTapeComponent.h:54
Color class with red, green, blue and alpha component.
Definition: Color4.h:39
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
uint64_t uint64
Definition: PlatformTypes.h:184
Definition: BarrierTapeComponent.h:59
3D transform class
Definition: Transform.h:45
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Definition: PickupPersonByParamedicAction.h:21
Definition: BarrierTapeComponent.h:58
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
TapeConnection
Definition: BarrierTapeComponent.h:56
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Prototype class.
Definition: Prototype.h:100
Binary serializer class.
Definition: BinarySerializer.h:35