Emergency 20 Dokumentation  4.2.0
HelicopterComponent.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 //[-------------------------------------------------------]
14 
15 
16 //[-------------------------------------------------------]
17 //[ Namespace ]
18 //[-------------------------------------------------------]
19 namespace em5
20 {
21 
22 
23  //[-------------------------------------------------------]
24  //[ Classes ]
25  //[-------------------------------------------------------]
31  {
32 
33 
34  //[-------------------------------------------------------]
35  //[ Public definitions ]
36  //[-------------------------------------------------------]
37  public:
38  static const uint32 COMPONENT_ID;
39 
40 
41  //[-------------------------------------------------------]
42  //[ Public static methods ]
43  //[-------------------------------------------------------]
44  public:
45  static void ignoreMarkerSelectionEntityId(const qsf::Entity& entity, boost::container::flat_set<uint64>& ignoreEntityIds);
46 
47 
48  //[-------------------------------------------------------]
49  //[ Public methods ]
50  //[-------------------------------------------------------]
51  public:
59  explicit HelicopterComponent(qsf::Prototype* prototype);
60 
65  virtual ~HelicopterComponent();
66 
67  void setGroundMarkerEnabled(bool light, bool selector);
68  qsf::Entity* getMarkerSelectionEntity() const;
69 
74  bool getLightEnabled() const;
75 
83  void setLightEnabled(bool light);
84 
85  const qsf::AssetProxy& getDustEffect() const;
86  void setDustEffect(const qsf::AssetProxy& dustEffect);
87 
88  const qsf::AssetProxy& getGroundMarkerAsset() const;
89  void setGroundMarkerAsset(const qsf::AssetProxy& groundMarkerAsset);
90 
91  uint64 getGroundLightEntityId() const;
92  void setGroundLightEntityId(uint64 groundLightEntitId);
93 
94  const glm::vec3& getCollisionExtentsOnGround() const;
95  void setCollisionExtentsOnGround(const glm::vec3& collisionExtentsOnGround);
96 
101  bool isFlying() const;
102 
107  void setFlying(bool flying);
108 
113  void forceFlying(bool rotorActive);
114 
115  bool isRotorAtFullSpeed() const;
116  bool isRotorStopped() const;
117 
122  bool getCanLandOnGround() const;
123  void setCanLandOnGround(bool canLandOnGround);
124 
129  void startDustEffects();
130  void stopDustEffects();
131 
136  void startSwing();
137  void stopSwing();
138 
139  void setCollisionShapeAir();
140  void setCollisionShapeGround();
141 
149  bool isStartingOrLanding() const;
150 
158  void setIsStartingOrLanding(bool startingOrLading);
159 
160 
161  //[-------------------------------------------------------]
162  //[ Public virtual em5::DamageComponent methods ]
163  //[-------------------------------------------------------]
164  public:
165  virtual void onSetDamagedLevel2() override;
166  virtual void onSetDestroyed() override;
167  virtual void onFireStarted(FreeplayEvent* freeplayEvent) override;
168  virtual bool checkReceiveDamage(damagetype::DamageType damageType, qsf::Component* sender) override;
169 
170 
171  //[-------------------------------------------------------]
172  //[ Public virtual qsf::Component methods ]
173  //[-------------------------------------------------------]
174  public:
175  virtual void serialize(qsf::BinarySerializer& serializer) override;
176 
177 
178  //[-------------------------------------------------------]
179  //[ Protected virtual qsf::Component methods ]
180  //[-------------------------------------------------------]
181  protected:
182  virtual void onShutdown() override;
183  virtual void onSetSimulating(bool simulating) override;
184 
185 
186  //[-------------------------------------------------------]
187  //[ Protected virtual em5::VehicleComponent methods ]
188  //[-------------------------------------------------------]
189  protected:
190  virtual void restoreEntitiesFromPrefab(const qsf::Prototype& prototype, std::unordered_map<uint64, uint64>& prototypeIdMap) override;
191  virtual void initializePrefabClearComponentExceptions() override;
192 
193 
194  //[-------------------------------------------------------]
195  //[ Private definitions ]
196  //[-------------------------------------------------------]
197  private:
198  typedef std::vector<uint64> EntityIdArray;
199 
200 
201  //[-------------------------------------------------------]
202  //[ Private methods ]
203  //[-------------------------------------------------------]
204  private:
205  // Job updates
206  void updateAnimation(const qsf::JobArguments& jobArguments);
207  void updateRotor(const qsf::Time& timePassed);
208  void updateGroundMarker();
209 
210  // Helper
211  void enableLights(bool enable);
212 
213 
214  //[-------------------------------------------------------]
215  //[ Private data ]
216  //[-------------------------------------------------------]
217  private:
218  EntityIdArray mVehicleRotorIds;
219  qsf::AssetProxy mDustEffectAsset;
220  qsf::AssetProxy mGroundMarkerAsset;
221  uint64 mGroundLightEntityId;
222  glm::vec3 mCollisionExtentsOnGround;
223  glm::vec3 mCollisionExtentsInAir;
224 
225  // Lights
226  EntityIdArray mVehicleLightIds;
227  bool mLightEnabled;
228 
229  // Rotor
230  bool mIsFlying;
231 
232  bool mCanLandOnGround;
233 
234  // Needed for multiplay
235  bool mIsStartingOrLanding;
236 
237  // Audio proxy
238  AudioProxy mAudioProxy;
239 
240  // Marker and selection
241  qsf::WeakPtr<qsf::Entity> mMarkerLightEntity;
242  qsf::WeakPtr<qsf::Entity> mMarkerSelectionEntity;
243  qsf::WeakPtr<qsf::Entity> mDustEffectEntity;
244  bool mMarkerLightEnabled;
245  bool mMarkerSelectorEnabled;
246 
247  // Job proxies for regular update
248  qsf::JobProxy mAnimationJobProxy;
249 
250 
251  //[-------------------------------------------------------]
252  //[ CAMP reflection system ]
253  //[-------------------------------------------------------]
254  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
255 
256 
257  public:
258  EntityIdArrayInterface VehicleRotorArray;
259  EntityIdArrayInterface VehicleLightsArray;
260 
261 
262  };
263 
264 
265 //[-------------------------------------------------------]
266 //[ Namespace ]
267 //[-------------------------------------------------------]
268 } // em5
269 
270 
271 //[-------------------------------------------------------]
272 //[ CAMP reflection system ]
273 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
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
Vehicle component base class.
Definition: VehicleComponent.h:49
uint64_t uint64
Definition: PlatformTypes.h:184
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
static const uint32 COMPONENT_ID
"em5::HelicopterComponent" unique component ID
Definition: HelicopterComponent.h:38
Asset proxy class.
Definition: AssetProxy.h:57
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
Extended audio proxy for easier multiplay usage.
Definition: AudioProxy.h:47
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
EMERGENCY 5 helicopter component class.
Definition: HelicopterComponent.h:30
Prototype class.
Definition: Prototype.h:100
DamageType
Definition: DamageType.h:20
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Binary serializer class.
Definition: BinarySerializer.h:35
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32