Emergency 20 Dokumentation  4.2.0
FairBomberEvent.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 
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24 
25 
26  //[-------------------------------------------------------]
27  //[ Classes ]
28  //[-------------------------------------------------------]
34  {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Public definitions ]
39  //[-------------------------------------------------------]
40  public:
41  static const uint32 FREEPLAY_EVENT_ID;
42 
43 
44  //[-------------------------------------------------------]
45  //[ Public methods ]
46  //[-------------------------------------------------------]
47  public:
53 
58  virtual ~FairBomberEvent();
59 
64  uint64 getBombSpotId() const;
65 
70  void setBombSpot(qsf::Entity& entity);
71 
72  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(BombTime, qsf::Time, mBombTime);
73  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(BombDefuseTime, qsf::Time, mBombDefuseTime);
74  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(EscapeTime, qsf::Time, mEscapeTime);
75  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(ExplosionRadius, float, mExplosionRadius);
76 
77 
78  //[-------------------------------------------------------]
79  //[ Public virtual em5::FreeplayEvent methods ]
80  //[-------------------------------------------------------]
81  public:
82  virtual bool onStartup() override;
83  virtual void onShutdown() override;
84  virtual void onRun() override;
85  virtual bool onFailure(EventResult& eventResult);
86  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
87  virtual const qsf::Entity* getFocusEntity() override;
88  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
89  virtual bool checkEventConfiguration() override;
90  virtual void serialize(qsf::BinarySerializer& serializer) override;
91 
92 
93  //[-------------------------------------------------------]
94  //[ Private methods ]
95  //[-------------------------------------------------------]
96  private:
97  void startHintObservers();
98  bool checkIfIsHealthy(const qsf::Entity& victim) const;
99  bool checkIfReachedBombSpot(qsf::Entity& gangster, const qsf::Entity& victim) const;
100  void setupGangster(qsf::Entity& gangster, qsf::Entity& bombSpot);
101  void escape(qsf::Entity& gangster);
102  void onExplode(const qsf::MessageParameters& parameters);
103 
104 
105  //[-------------------------------------------------------]
106  //[ Private definitions ]
107  //[-------------------------------------------------------]
108  private:
109  enum BomberState
110  {
111  RUNNING_TO_BOMB_SPOT,
112  PERPETRATING,
113  GUARDING,
114  ESCAPING,
115  RESCUE
116  };
117 
118 
119  //[-------------------------------------------------------]
120  //[ Private data ]
121  //[-------------------------------------------------------]
122  private:
123  uint64 mBombSpotId;
124  uint64 mBombId;
125  qsf::Time mBombTime;
126  qsf::Time mBombDefuseTime;
127  qsf::Time mEscapeTime;
128  BomberState mState;
129  qsf::MessageProxy mMessageProxy;
130  bool mBombExploded;
131  qsf::Time mBombDeletionCountdown;
132  float mExplosionRadius;
133 
134 
135  //[-------------------------------------------------------]
136  //[ CAMP reflection system ]
137  //[-------------------------------------------------------]
138  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
139 
140 
141  };
142 
143 
144 //[-------------------------------------------------------]
145 //[ Namespace ]
146 //[-------------------------------------------------------]
147 } // em5
148 
149 
150 //[-------------------------------------------------------]
151 //[ CAMP reflection system ]
152 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Definition: FreeplayEvent.h:110
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Message listener proxy class.
Definition: MessageProxy.h:47
Reason
Definition: EventSpreadReason.h:20
uint64_t uint64
Definition: PlatformTypes.h:184
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Emergency 5 freeplay event "fair bomber" 13.4.
Definition: FairBomberEvent.h:33
#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
EMERGENCY 5 gangster freeplay event base class.
Definition: GangsterEvent.h:41
static const uint32 FREEPLAY_EVENT_ID
"em5::FairBomberEvent" unique freeplay event ID
Definition: FairBomberEvent.h:41
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