Emergency 20 Dokumentation  4.2.0
RiotEvent.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 
15 
16 //[-------------------------------------------------------]
17 //[ Namespace ]
18 //[-------------------------------------------------------]
19 namespace em5
20 {
21 
22 
23  //[-------------------------------------------------------]
24  //[ Classes ]
25  //[-------------------------------------------------------]
31  {
32 
33 
34  //[-------------------------------------------------------]
35  //[ Public definitions ]
36  //[-------------------------------------------------------]
37  public:
38  static const uint32 FREEPLAY_EVENT_ID;
39 
40 
41  //[-------------------------------------------------------]
42  //[ Public methods ]
43  //[-------------------------------------------------------]
44  public:
49  RiotEvent();
50 
55  virtual ~RiotEvent();
56 
61  std::vector<uint64> const& getGangsterIds() const;
62 
67  void addGangster(const qsf::Entity& entity);
68 
73  uint64 getBuildingId() const;
74 
79  void setBuilding(const qsf::Entity& entity);
80 
81  void setPeopleToAttack(uint32 peopleToAttack);
82  void setStartGangsters(uint32 startGangsters);
83  void setHintToTriggerWhenFleeing(const std::string& hintId);
84 
93  void enableGangsterFleeingBehavior(uint32 remainingGangsters);
94 
103  void setPreferToAttackSquad(bool gangstersPreferToAttackSquad);
104 
105 
106  //[-------------------------------------------------------]
107  //[ Public virtual em5::FreeplayEvent methods ]
108  //[-------------------------------------------------------]
109  public:
110  virtual bool onStartup() override;
111  virtual void onShutdown() override;
112  virtual void onRun() override;
113  virtual bool onFailure(EventResult& eventResult) override;
114  virtual void updateFreeplayEvent(const qsf::Time& timePassed) override;
115  virtual void hintCallback(Observer& hintObserver) override;
116  virtual const qsf::Entity* getFocusEntity() override;
117  virtual bool checkEventConfiguration() override;
118  virtual void serialize(qsf::BinarySerializer& serializer) override;
119  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
120 
121 
122  //[-------------------------------------------------------]
123  //[ Private methods ]
124  //[-------------------------------------------------------]
125  private:
126  bool checkIfIsHealthy(qsf::Entity& victim);
127  bool checkIfReachedVictim(qsf::Entity& gangster, qsf::Entity& victim);
128  qsf::Entity* findNewTarget(qsf::Entity& gangster);
129  void attackTarget(qsf::Entity& gangster, qsf::Entity& victim);
130  void vigilanteAttackTarget(qsf::Entity& gangster, qsf::Entity& victim);
131  bool checkVigilante(qsf::Entity& gangster, qsf::Entity& victim, bool onlyCheckClose);
132  bool isAttacked(qsf::Entity& gangster);
133  bool isFighting(qsf::Entity& gangster);
134  bool isAttackingSquad(qsf::Entity& gangsterEntity);
135  bool tryAttackSquad(qsf::Entity& gangsterEntity);
136  bool tryAttackGangster(qsf::Entity& gangsterEntity);
137  qsf::Entity* createRiotGangster();
138  void instructGangstersToFlee();
139 
140 
141  //[-------------------------------------------------------]
142  //[ Private data ]
143  //[-------------------------------------------------------]
144  private:
145  uint64 mBuildingId;
146  std::vector<uint64> mGangsterIds;
147  std::vector<uint64> mAttackingSquad;
148  boost::container::flat_map<uint64, uint64> mCurrentFights;
149  boost::container::flat_map<uint64, Observer*> mArrestObservers;
150  std::string mHintToTriggerWhenFleeing;
151  uint32 mAttackersLeft;
152  uint32 mStartGangsters;
153  uint32 mGangstersRemainingBeforeTheyFlee;
154  bool mAreGangstersFleeing;
155  bool mDontShootTriggered;
156  bool mVigilanteTriggered;
157  bool mPreferToAttackSquad;
158  bool mRemainingGangstersFleeWhenOthersArrested;
159 
160 
161  //[-------------------------------------------------------]
162  //[ CAMP reflection system ]
163  //[-------------------------------------------------------]
164  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
165 
166 
167  };
168 
169 
170 //[-------------------------------------------------------]
171 //[ Namespace ]
172 //[-------------------------------------------------------]
173 } // em5
174 
175 
176 //[-------------------------------------------------------]
177 //[ CAMP reflection system ]
178 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
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
EMERGENCY 5 freeplay event class for "Riot".
Definition: RiotEvent.h:30
static const uint32 FREEPLAY_EVENT_ID
"em5::RiotEvent" unique freeplay event ID
Definition: RiotEvent.h:38
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