Emergency 20 Dokumentation  4.2.0
TerrorAttackEvent.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 #include <qsf/time/Time.h>
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 ~TerrorAttackEvent();
59 
60  void addTerrorist(qsf::Entity& gangster, qsf::Entity& bombSpot);
61 
62  QSF_DEFINE_SIMPLE_GETTER_AND_SETTER(BombTime, qsf::Time, mBombTime);
63 
64 
65  //[-------------------------------------------------------]
66  //[ Public virtual em5::FreeplayEvent methods ]
67  //[-------------------------------------------------------]
68  public:
69  virtual bool onStartup() override;
70  virtual void onShutdown() override;
71  virtual void onRun() override;
72  virtual bool onFailure(EventResult& eventResult) override;
73  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
74  virtual const qsf::Entity* getFocusEntity() override;
75  virtual bool checkEventConfiguration() override;
76  virtual void serialize(qsf::BinarySerializer& serializer) override;
77  virtual bool addEntityToEvent( qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason ) override;
78  virtual void hintCallback( Observer& hintObserver ) override;
79 
80 
81  //[-------------------------------------------------------]
82  //[ Private definitions ]
83  //[-------------------------------------------------------]
84  private:
85  enum TerroristState
86  {
87  RUNNING_TO_BOMB_SPOT,
88  PERPETRATING,
89  RUNNING_AMOK,
90  RESCUE
91  };
92 
93  struct Terrorist
94  {
95  uint64 mGangsterId;
96  uint64 mBombSpotId;
97  uint64 mBombId;
98  TerroristState mState;
99  bool mBombExploded;
100  };
101 
102 
103  //[-------------------------------------------------------]
104  //[ Private methods ]
105  //[-------------------------------------------------------]
106  private:
107  void startHintObservers();
108  bool checkIfIsHealthy(const qsf::Entity& victim) const;
109  bool checkIfReachedBombSpot(qsf::Entity& gangster, qsf::Entity& victim) const;
110  void setupGangster(Terrorist& terrorist);
111  void onExplode(const qsf::MessageParameters& parameters, Terrorist& terrorist);
112  void removeTerrorist(Terrorist& terrorist);
113 
114 
115  //[-------------------------------------------------------]
116  //[ Private data ]
117  //[-------------------------------------------------------]
118  private:
119  std::vector<Terrorist> mTerrorists;
120  qsf::Time mBombTime;
121  qsf::MessageProxy mMessageProxy;
122  int mBombsPlaced;
123  qsf::Time mBombDeletionCountdown;
124 
125 
126  //[-------------------------------------------------------]
127  //[ CAMP reflection system ]
128  //[-------------------------------------------------------]
129  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
130 
131 
132  };
133 
134 
135 //[-------------------------------------------------------]
136 //[ Namespace ]
137 //[-------------------------------------------------------]
138 } // em5
139 
140 
141 //[-------------------------------------------------------]
142 //[ CAMP reflection system ]
143 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
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
Emergency 5 freeplay event class for "Terror Attack".
Definition: TerrorAttackEvent.h:33
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::TerrorAttackEvent" unique freeplay event ID
Definition: TerrorAttackEvent.h:41
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