Emergency 20 Dokumentation  4.2.0
WaterjetComponent.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 
17 #include <qsf/job/JobProxy.h>
19 
20 #include <glm/gtc/quaternion.hpp>
21 
22 #include <vector>
23 
24 
25 //[-------------------------------------------------------]
26 //[ Forward declarations ]
27 //[-------------------------------------------------------]
28 namespace qsf
29 {
30  class JobArguments;
31  class Transform;
32 }
33 
34 
35 //[-------------------------------------------------------]
36 //[ Namespace ]
37 //[-------------------------------------------------------]
38 namespace em5
39 {
40 
41 
42  //[-------------------------------------------------------]
43  //[ Classes ]
44  //[-------------------------------------------------------]
50  {
51 
52 
53  //[-------------------------------------------------------]
54  //[ Public definitions ]
55  //[-------------------------------------------------------]
56  public:
57  static const uint32 COMPONENT_ID;
58  static const uint32 TARGET_ENTITY_ID;
59  static const uint32 ANGLE_IN_DEGREES;
60  static const uint32 ANGLE_IN_RADIANS;
61  static const uint32 START_RADIUS;
62  static const uint32 END_RADIUS;
64  static const uint32 END_BOTTOM_LAPSE;
68  static const uint32 HIT_ENTITY_ID;
69  static const uint32 HIT_POSITION;
71 
72 
73  //[-------------------------------------------------------]
74  //[ Public methods ]
75  //[-------------------------------------------------------]
76  public:
84  explicit WaterjetComponent(qsf::Prototype* prototype);
85 
90  virtual ~WaterjetComponent();
91 
92  inline uint64 getTargetEntityId() const;
93  inline void setTargetEntityId(uint64 entityId);
94 
95  qsf::Entity* getTargetEntity() const;
96  void setTargetEntity(qsf::Entity* targetEntity);
97 
98  inline float getAngleInRadians() const;
99  inline void setAngleInRadians(float angleInRadians);
100 
101  inline float getAngleInDegrees() const;
102  inline void setAngleInDegrees(float angleInDegree);
103 
104  inline float getStartRadius() const;
105  inline void setStartRadius(float startRadius);
106 
107  inline float getEndRadius() const;
108  inline void setEndRadius(float endRadius);
109 
110  inline float getEndRadiusYFactor() const;
111  inline void setEndRadiusYFactor(float endRadiusYFactor);
112 
113  inline float getEndBottomLapse() const;
114  inline void setEndBottomLapse(float endBottomLapse);
115 
116  QSF_DEFINE_PROPERTY_GETTER_AND_SETTER(BuildupDistancePerSecond, float, mBuildupDistancePerSecond, BUILDUP_DISTANCE_PER_SECOND);
117 
118  inline bool getDisableAllParticles() const;
119  inline void setDisableAllParticles(bool state);
120 
121  inline bool getDisableCollisionChecks() const;
122  inline void setDisableCollisionChecks(bool state);
123 
124  inline uint64 getHitEntityId() const;
125 
126  inline const glm::vec3& getHitPosition() const;
127 
128  inline const glm::vec3& getHitGroundPosition() const;
129 
130  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(CurrentDistance, float, mCurrentDistance);
131 
132 
133  //[-------------------------------------------------------]
134  //[ Public virtual qsf::Component methods ]
135  //[-------------------------------------------------------]
136  public:
137  virtual void serialize(qsf::BinarySerializer& serializer) override;
138 
139 
140  //[-------------------------------------------------------]
141  //[ Protected virtual qsf::Component methods ]
142  //[-------------------------------------------------------]
143  protected:
144  virtual void onSetDebug(bool debug) override;
145 
146  //[-------------------------------------------------------]
147  //[ Lifecycle ]
148  //[-------------------------------------------------------]
149  virtual bool onStartup() override;
150  virtual void onShutdown() override;
151 
152 
153  //[-------------------------------------------------------]
154  //[ Private methods ]
155  //[-------------------------------------------------------]
156  private:
157  void updateHit(uint64 entityId, const glm::vec3& hitPosition, const glm::vec3& hitGoundPosition);
158  void updateAnimation(const qsf::JobArguments& jobArguments);
159  void updateHitParticlesDead(const qsf::JobArguments& jobArguments);
160  void updateMesh();
161  void updateParticles();
162  void destroyParticles();
163  void destroyHitParticles();
164 
165 
166  //[-------------------------------------------------------]
167  //[ Private definitions ]
168  //[-------------------------------------------------------]
169  private:
170  static const float PARTICLES_SCALE; //< Scale down the particles, requested by the artists
171  static const float PARTICLE_DISTANCE_FACTOR; //< Factor that the distance between individual waterjet particles is multiplied with
172  static const char PARTICLES_WATERJET_ASSET[];
173  static const char PARTICLES_HIT_ASSET[];
174  static const char PARTICLES_HIT_HACK_ASSET[];
175  static const char PARTICLES_HIT_GROUND_ASSET[];
176 
177  struct JetParticle
178  {
179  float positionY;
180  float positionZ;
181  float scale;
182  };
183 
184 
185  //[-------------------------------------------------------]
186  //[ Private data ]
187  //[-------------------------------------------------------]
188  private:
189  // Input - connected to CAMP
190  uint64 mTargetEntityId;
191  float mAngleInRadians;
192  float mStartRadius;
193  float mEndRadius;
194  float mEndRadiusYFactor;
195  float mEndBottomLapse;
196  float mBuildupDistancePerSecond;
197  bool mDisableAllParticles;
198  bool mDisableCollisionChecks;
199 
200  // Output - connected to CAMP (read only)
201  uint64 mHitEntityId;
202  glm::vec3 mHitPosition;
203  glm::vec3 mHitGroundPosition;
204 
205  // Internal - not connected to CAMP
206  float mCurrentDistance;
207  float mTargetDistance;
208  float mTargetHeight;
209  float mLastDistance;
210  glm::quat mLastRotation;
211  qsf::DebugDrawProxy mDebugDrawProxy;
212  std::vector<uint64> mWaterjetParticlesEntityIds;
213  uint64 mHitParticlesEntityId;
214  uint64 mHitHackParticlesEntityId; // TODO(co) Remove this as soon as the artists integrated the hit particles into the hit & drop particles effect, we don't want to have too
215  uint64 mHitGroundParticlesEntityId;
216  std::vector<JetParticle> mParticlePoints;
217 
218  // Job proxies for regular update
219  qsf::JobProxy mAnimationJobProxy;
220  qsf::JobProxy mHitParticlesDeadJobProxy;
221 
222 
223  //[-------------------------------------------------------]
224  //[ CAMP reflection system ]
225  //[-------------------------------------------------------]
226  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
227 
228 
229  };
230 
231 
232 //[-------------------------------------------------------]
233 //[ Namespace ]
234 //[-------------------------------------------------------]
235 } // em5
236 
237 
238 //[-------------------------------------------------------]
239 //[ Implementation ]
240 //[-------------------------------------------------------]
242 
243 
244 //[-------------------------------------------------------]
245 //[ CAMP reflection system ]
246 //[-------------------------------------------------------]
static const uint32 HIT_ENTITY_ID
Definition: WaterjetComponent.h:68
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
#define QSF_DEFINE_PROPERTY_GETTER_AND_SETTER(name, type, variable, propertyId)
Definition: PropertyHelper.h:20
Abstract component class.
Definition: Component.h:105
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
static const uint32 BUILDUP_DISTANCE_PER_SECOND
Definition: WaterjetComponent.h:65
#define EM5_API_EXPORT
Definition: Export.h:28
static const uint32 ANGLE_IN_RADIANS
Definition: WaterjetComponent.h:60
static const uint32 DISABLE_COLLISION_CHECKS
Definition: WaterjetComponent.h:67
static const uint32 COMPONENT_ID
"em5::WaterjetComponent" unique component ID
Definition: WaterjetComponent.h:57
static const uint32 DISABLE_ALL_PARTICLES
Definition: WaterjetComponent.h:66
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 HIT_POSITION
Definition: WaterjetComponent.h:69
Definition: PickupPersonByParamedicAction.h:21
Debug draw proxy class.
Definition: DebugDrawProxy.h:46
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
static const uint32 ANGLE_IN_DEGREES
Definition: WaterjetComponent.h:59
EMERGENCY 5 waterjet component class.
Definition: WaterjetComponent.h:49
static const uint32 END_BOTTOM_LAPSE
Definition: WaterjetComponent.h:64
static const uint32 END_RADIUS
Definition: WaterjetComponent.h:62
static const uint32 TARGET_ENTITY_ID
Definition: WaterjetComponent.h:58
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
static const uint32 HIT_GROUND_POSITION
Definition: WaterjetComponent.h:70
#define QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(name, type, variable)
Definition: PropertyHelper.h:16
Prototype class.
Definition: Prototype.h:100
static const uint32 END_RADIUS_Y_FACTOR
Definition: WaterjetComponent.h:63
static const uint32 START_RADIUS
Definition: WaterjetComponent.h:61
Binary serializer class.
Definition: BinarySerializer.h:35