Emergency 20 Dokumentation  4.2.0
EboxComponent.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 #include <qsf/job/JobProxy.h>
18 
19 #include <vector>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Namespace ]
24 //[-------------------------------------------------------]
25 namespace em5
26 {
27 
28 
29  //[-------------------------------------------------------]
30  //[ Classes ]
31  //[-------------------------------------------------------]
37  {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Public definitions ]
42  //[-------------------------------------------------------]
43  public:
44  static const uint32 COMPONENT_ID;
45 
46 
47  //[-------------------------------------------------------]
48  //[ Public methods ]
49  //[-------------------------------------------------------]
50  public:
58  inline explicit EboxComponent(qsf::Prototype* prototype);
59 
64  inline virtual ~EboxComponent();
65 
66  void setEboxDefective();
67  void setEboxDefectiveWithGaping(float gapeChance, float reactionRadius);
68  void setEboxIntact();
69 
70  inline bool isDefect() const;
71 
72  inline const qsf::AssetProxy& getDefectMesh() const;
73  inline void setDefectMesh(const qsf::AssetProxy& mesh);
74 
75  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(FlashWaitTime, const glm::vec2&, mFlashWaitTime);
76  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(SparksWaitTime, const glm::vec2&, mSparksWaitTime);
77  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(MaxInjuredPersons, int, mMaxInjuredPersons);
78 
79 
80  //[-------------------------------------------------------]
81  //[ Public virtual em5::DamageComponent methods ]
82  //[-------------------------------------------------------]
83  public:
84  inline virtual bool isReadyForCleanup() const override;
85  virtual void cleanup() override;
86 
87 
88  //[-------------------------------------------------------]
89  //[ Protected virtual em5::DamageComponent methods ]
90  //[-------------------------------------------------------]
91  protected:
92  virtual void onSetDamageState(DamageState damageState) override;
93 
94 
95  //[-------------------------------------------------------]
96  //[ Protected virtual qsf::Component methods ]
97  //[-------------------------------------------------------]
98  protected:
99  virtual bool onStartup() override;
100  virtual void onShutdown() override;
101  virtual void serialize(qsf::BinarySerializer& serializer) override;
102 
103 
104  //[-------------------------------------------------------]
105  //[ Private methods ]
106  //[-------------------------------------------------------]
107  private:
108  void updateJob(const qsf::JobArguments& jobArguments);
109  void updateSparks(const qsf::Time& timePassed);
110  void updateGapersAndShocks(const qsf::Time& timePassed);
111 
112  void setMeshToDefect(bool defect);
113  void activateFireComponents(bool active);
114  void injurePerson(qsf::Entity& entity) const;
115  void showSparksParticles();
116  void showFlashParticles();
117  void registerUpdateProxy();
118  void makePersonGaper(qsf::Entity& entity);
119  void makePersonSnooper(qsf::Entity& entity);
120 
121 
122  //[-------------------------------------------------------]
123  //[ Private definitions ]
124  //[-------------------------------------------------------]
125  private:
126  typedef std::vector<uint64> EntityIdArray;
127 
128 
129  //[-------------------------------------------------------]
130  //[ Private data ]
131  //[-------------------------------------------------------]
132  private:
133  // Connected to CAMP
134  EntityIdArray mFlashParticlesIds;
135  EntityIdArray mSparksParticlesIds;
136 
137  glm::vec2 mFlashWaitTime;
138  glm::vec2 mSparksWaitTime;
139 
140  // Internal
141  bool mIsDefect;
142  qsf::JobProxy mUpdateJobProxy;
143  float mGapeChance;
144  float mReactionRadius;
145 
146  std::vector<uint64> mSnoopingPersons;
147  std::vector<uint64> mAffectedPersons;
148 
149  qsf::Time mSecondsToNextFlash;
150  qsf::Time mSecondsToNextSparks;
151 
152  qsf::AssetProxy mIntactMesh;
153  qsf::AssetProxy mDamageMesh;
154 
155  int mMaxInjuredPersons;
156  int mCurrentInjuredPersons;
157 
158 
159  //[-------------------------------------------------------]
160  //[ CAMP reflection system ]
161  //[-------------------------------------------------------]
162  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
163 
164  public:
165  QSF_CAMP_ARRAY_INTERFACE_CLASS_WITH_VARIABLE(EntityIdArrayInterface, EboxComponent, std::vector<uint64>, uint64);
166  EntityIdArrayInterface FlashParticlesArray;
167  EntityIdArrayInterface SparksParticlesArray;
168 
169 
170  };
171 
172 
173 //[-------------------------------------------------------]
174 //[ Namespace ]
175 //[-------------------------------------------------------]
176 } // em5
177 
178 
179 //[-------------------------------------------------------]
180 //[ Implementation ]
181 //[-------------------------------------------------------]
182 #include "em5/component/objects/EboxComponent-inl.h"
183 
184 
185 //[-------------------------------------------------------]
186 //[ CAMP reflection system ]
187 //[-------------------------------------------------------]
189 QSF_CAMP_ARRAY_MAPPER_DEFINITION(em5::EboxComponent::EntityIdArrayInterface)
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: AreaConfiguration.h:58
#define QSF_CAMP_ARRAY_INTERFACE_CLASS_WITH_VARIABLE(interfaceClassName, ownerType, variableType, elementType)
Definition: CampClass.h:241
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
QSF_CAMP_ARRAY_MAPPER_DEFINITION(qsf::ai::TrafficLightTimerComponent::ManagedTrafficLightList)
Asset proxy class.
Definition: AssetProxy.h:57
#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
#define QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(name, type, variable)
Definition: PropertyHelper.h:16
static const uint32 COMPONENT_ID
"em5::EboxComponent" unique component ID
Definition: EboxComponent.h:44
Prototype class.
Definition: Prototype.h:100
Binary serializer class.
Definition: BinarySerializer.h:35
DamageState
Definition: DamageComponent.h:70
EMERGENCY 5 ebox component.
Definition: EboxComponent.h:36
EMERGENCY 5 deco object component class.
Definition: ObjectDamageComponent.h:30
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32