Emergency 20 Dokumentation  4.2.0
BombComponent.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/audio/AudioProxy.h"
14 
16 #include <qsf/job/JobProxy.h>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  class FreeplayEvent;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Public definitions ]
50  //[-------------------------------------------------------]
51  public:
52  static const uint32 COMPONENT_ID;
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public methods ]
57  //[-------------------------------------------------------]
58  public:
66  explicit BombComponent(qsf::Prototype* prototype);
67 
72  virtual ~BombComponent();
73 
74  qsf::Time getTimeRunning() const;
75  void setTimeRunning(qsf::Time timeRunning);
76 
77  qsf::Time getTimeToDefuse() const;
78  void setTimeToDefuse(qsf::Time timeToDefuse);
79 
80  // "true" if the bomb is currently defused (de: wird entschärft)
81  bool getIsDefuseBombActive() const;
82  void setIsDefuseBombActive(bool isDefuseBomb);
83 
84  bool isBombActive() const;
85  bool isBombDefused() const;
86  bool isBombIntact() const;
87 
88  // "true" if the defusing process can continue, "false" if bomb is exploded or defused
89  bool canBeDefused() const;
90 
95  void startBombTimer(FreeplayEvent& freeplayEvent, bool playTicking = true);
96 
101  void explodeBomb();
102 
107  void defuseBomb();
108 
109  void enableTicking(bool enable);
110 
111 
112  //[-------------------------------------------------------]
113  //[ Public virtual qsf::Component methods ]
114  //[-------------------------------------------------------]
115  public:
116  virtual void serialize(qsf::BinarySerializer& serializer) override;
117 
118 
119  //[-------------------------------------------------------]
120  //[ Private methods ]
121  //[-------------------------------------------------------]
122  private:
123  void activateJob();
124  void deactivateJob();
125  void updateJob(const qsf::JobArguments& jobArguments);
126 
127  void damageObjectsAroundBomb();
128  void drawDebugDisplay();
129 
130 
131  //[-------------------------------------------------------]
132  //[ Private data ]
133  //[-------------------------------------------------------]
134  private:
135  enum BombState
136  {
137  STATE_INACTIVE,
138  STATE_ACTIVE,
139  STATE_DEFUSED,
140  STATE_EXPLODED
141  };
142 
143  // Internal
144  qsf::JobProxy mUpdateJobProxy;
145  qsf::Time mTimeRunning;
146  qsf::Time mTimeToDefuse;
147  qsf::Time mCurrentTimeDefuse;
148  BombState mState;
149  bool mIsDefuseActive;
150 
151  qsf::DebugDrawProxy mDebugDrawProxy;
152  AudioProxy mAudioProxy;
153 
154 
155  //[-------------------------------------------------------]
156  //[ CAMP reflection system ]
157  //[-------------------------------------------------------]
158  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
159 
160 
161  };
162 
163 
164 //[-------------------------------------------------------]
165 //[ Namespace ]
166 //[-------------------------------------------------------]
167 } // em5
168 
169 
170 //[-------------------------------------------------------]
171 //[ CAMP reflection system ]
172 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
unsigned int uint32
Definition: PlatformTypes.h:181
EMERGENCY 5 bomb component.
Definition: BombComponent.h:44
#define EM5_API_EXPORT
Definition: Export.h:28
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
Debug draw proxy class.
Definition: DebugDrawProxy.h:46
#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
static const uint32 COMPONENT_ID
"em5::BombComponent" unique component ID
Definition: BombComponent.h:52
Prototype class.
Definition: Prototype.h:100
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