Emergency 20 Dokumentation  4.2.0
LightTimeControlComponent.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/time/Time.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Namespace ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25 
26 
27  //[-------------------------------------------------------]
28  //[ Classes ]
29  //[-------------------------------------------------------]
35  {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Public definitions ]
40  //[-------------------------------------------------------]
41  public:
42  static const uint32 COMPONENT_ID;
43 
44 
45  //[-------------------------------------------------------]
46  //[ Public methods ]
47  //[-------------------------------------------------------]
48  public:
56  inline explicit LightTimeControlComponent(qsf::Prototype* prototype);
57 
62  inline virtual ~LightTimeControlComponent();
63 
75  inline const qsf::AssetProxy& getLightsEmissiveMaterial() const;
76 
88  inline void setLightsEmissiveMaterial(const qsf::AssetProxy& material);
89 
100  inline const qsf::Time getLightsEarliestOnTime() const;
101 
112  inline void setLightsEarliestOnTime(const qsf::Time& time);
113 
124  inline const qsf::Time getLightsLatestOnTime() const;
125 
136  inline void setLightsLatestOnTime(const qsf::Time& time);
137 
148  inline const qsf::Time getLightsEarliestOffTime() const;
149 
160  inline void setLightsEarliestOffTime(const qsf::Time& time);
161 
172  inline const qsf::Time getLightsLatestOffTime() const;
173 
184  inline void setLightsLatestOffTime(const qsf::Time& time);
185 
196  inline uint64 getLightEntityId() const;
197 
208  inline void setLightEntityId(uint64 entityId);
209 
219  inline void updateLightState(const qsf::Time& currentTimeOfDay, bool forceSet);
220 
225  inline bool shouldBeSimulated() const;
226 
227 
228  //[-------------------------------------------------------]
229  //[ Protected virtual qsf::Component methods ]
230  //[-------------------------------------------------------]
231  protected:
232  virtual bool onStartup() override;
233  virtual void onSetSimulating(bool simulating) override;
234  virtual void onSetActive(bool active) override;
235  virtual void serialize(qsf::BinarySerializer& serializer) override;
236 
237 
238  //[-------------------------------------------------------]
239  //[ Protected virtual em5::LightTimeControlComponent methods ]
240  //[-------------------------------------------------------]
241  protected:
242  virtual void onUpdateLightState(const qsf::Time& currentTimeOfDay, bool forceSet);
243  virtual void enableChildLights(bool enable);
244  virtual void switchOffAllLights();
245 
246 
247  //[-------------------------------------------------------]
248  //[ Protected methods ]
249  //[-------------------------------------------------------]
250  protected:
251  void enableEmissiveMap(const qsf::AssetProxy& material, bool enable);
252  qsf::Time getTimeFromTimeRange(const qsf::Time& minimumTime, const qsf::Time& maximumTime);
253  bool isTimeInOnInterval(const qsf::Time& timeToCheck, const qsf::Time& lightsOnTime, const qsf::Time& lightsOffTime);
254 
255 
256  //[-------------------------------------------------------]
257  //[ Private data ]
258  //[-------------------------------------------------------]
259  private:
260  bool mShouldBeSimulated;
261 
262  qsf::AssetProxy mLightsEmissiveMaterial;
263  qsf::Time mLightsEarliestOnTime;
264  qsf::Time mLightsLatestOnTime;
265  qsf::Time mLightsEarliestOffTime;
266  qsf::Time mLightsLatestOffTime;
267 
268  qsf::Time mLightsOnTime;
269  qsf::Time mLightsOffTime;
270 
271  bool mLightsAreOnStatus;
272  uint64 mLightEntityId;
273 
274 
275  //[-------------------------------------------------------]
276  //[ CAMP reflection system ]
277  //[-------------------------------------------------------]
278  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
279 
280 
281  };
282 
283 
284 //[-------------------------------------------------------]
285 //[ Namespace ]
286 //[-------------------------------------------------------]
287 } // em5
288 
289 
290 //[-------------------------------------------------------]
291 //[ Implementation ]
292 //[-------------------------------------------------------]
294 
295 
296 //[-------------------------------------------------------]
297 //[ CAMP reflection system ]
298 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Abstract component class.
Definition: Component.h:105
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
uint64_t uint64
Definition: PlatformTypes.h:184
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
EMERGENCY 5 light time control component class.
Definition: LightTimeControlComponent.h:34
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
static const uint32 COMPONENT_ID
"em5::LightTimeControlComponent" unique component ID
Definition: LightTimeControlComponent.h:42
Prototype class.
Definition: Prototype.h:100
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