Emergency 20 Dokumentation  4.2.0
BomberEvent.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 
16 
17 
18 //[-------------------------------------------------------]
19 //[ Namespace ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23 
24 
25  //[-------------------------------------------------------]
26  //[ Classes ]
27  //[-------------------------------------------------------]
33  {
34 
35 
36  //[-------------------------------------------------------]
37  //[ Public definitions ]
38  //[-------------------------------------------------------]
39  public:
40  static const uint32 FREEPLAY_EVENT_ID;
41 
42 
43  //[-------------------------------------------------------]
44  //[ Public methods ]
45  //[-------------------------------------------------------]
46  public:
51  BomberEvent();
52 
57  virtual ~BomberEvent();
58 
63  uint64 getBombSpotId() const;
64 
69  void setBombSpot(const qsf::Entity& entity);
70 
71  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(BombTime, float, mBombTime);
72  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(EscapeTime, float, mEscapeTime);
73 
74 
75  //[-------------------------------------------------------]
76  //[ Public virtual em5::FreeplayEvent methods ]
77  //[-------------------------------------------------------]
78  public:
79  virtual bool onStartup() override;
80  virtual void onShutdown() override;
81  virtual void onRun() override;
82  virtual bool onFailure(EventResult& eventResult) override;
83  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
84  virtual const qsf::Entity* getFocusEntity() override;
85  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
86  virtual bool checkEventConfiguration() override;
87  virtual void serialize(qsf::BinarySerializer& serializer) override;
88 
89 
90  //[-------------------------------------------------------]
91  //[ Private methods ]
92  //[-------------------------------------------------------]
93  private:
94  void startHintObservers();
95  bool checkIfIsHealthy(const qsf::Entity& victim) const;
96  bool checkIfReachedBombSpot(qsf::Entity& gangster, qsf::Entity& victim);
97  void setupGangster(qsf::Entity& gangster, qsf::Entity& bombSpot);
98  void escape(qsf::Entity& gangster);
99  void onExplode(const qsf::MessageParameters& parameters);
100 
101 
102  //[-------------------------------------------------------]
103  //[ Private definitions ]
104  //[-------------------------------------------------------]
105  private:
106  enum BomberState
107  {
108  RUNNING_TO_BOMB_SPOT,
109  GUARDING,
110  ESCAPING,
111  RESCUE
112  };
113 
114 
115  //[-------------------------------------------------------]
116  //[ Private data ]
117  //[-------------------------------------------------------]
118  private:
119  uint64 mBombSpotId;
120  uint64 mBombId;
121  float mBombTime;
122  float mEscapeTime;
123  BomberState mState;
124  qsf::MessageProxy mMessageProxy;
125  bool mBombExploded;
126  qsf::Time mBombDeletionCountdown;
127 
128 
129  //[-------------------------------------------------------]
130  //[ CAMP reflection system ]
131  //[-------------------------------------------------------]
132  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
133 
134 
135  };
136 
137 
138 //[-------------------------------------------------------]
139 //[ Namespace ]
140 //[-------------------------------------------------------]
141 } // em5
142 
143 
144 //[-------------------------------------------------------]
145 //[ CAMP reflection system ]
146 //[-------------------------------------------------------]
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
#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 FREEPLAY_EVENT_ID
"em5::BomberEvent" unique freeplay event ID
Definition: BomberEvent.h:40
EMERGENCY 5 gangster freeplay event base class.
Definition: GangsterEvent.h:41
Binary serializer class.
Definition: BinarySerializer.h:35
EMERGENCY 5 freeplay event class for "Bomber".
Definition: BomberEvent.h:32
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32