Emergency 20 Dokumentation  4.2.0
MainEvent07.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 #include <qsf/base/WeakPtr.h>
16 #include <qsf/job/JobProxy.h>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24 
25 
26  //[-------------------------------------------------------]
27  //[ Classes ]
28  //[-------------------------------------------------------]
33  class MainEvent07 : public MainEvent
34  {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Friends ]
39  //[-------------------------------------------------------]
40  friend class MainEventMetaclasses; // CAMP export of editable values for Game Design
41 
42 
43  //[-------------------------------------------------------]
44  //[ Public definitions ]
45  //[-------------------------------------------------------]
46  public:
47  static const uint32 FREEPLAY_EVENT_ID;
48 
49 
50  //[-------------------------------------------------------]
51  //[ Public methods ]
52  //[-------------------------------------------------------]
53  public:
58  MainEvent07();
59 
64  virtual ~MainEvent07();
65 
66 
67  //[-------------------------------------------------------]
68  //[ Public virtual em5::FreeplayEvent methods ]
69  //[-------------------------------------------------------]
70  public:
71  //[-------------------------------------------------------]
72  //[ Life cycle ]
73  //[-------------------------------------------------------]
74  virtual bool onStartup() override;
75  virtual void onShutdown() override;
76  virtual void onRun() override;
77  virtual bool onSuccess(EventResult& eventResult) override;
78  virtual bool onFailure(EventResult& eventResult) override;
79 
80  //[-------------------------------------------------------]
81  //[ Points evaluation ]
82  //[-------------------------------------------------------]
83  virtual uint32 calculatePointGain(EventResult& eventResult) override;
84 
85  //[-------------------------------------------------------]
86  //[ Callbacks from observers ]
87  //[-------------------------------------------------------]
88  virtual bool addEntityToEvent(qsf::Entity& targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override;
89  virtual void hintCallback(Observer& hintObserver) override;
90  virtual void hintCallbackWithMessage(Observer& hintObserver, const qsf::MessageParameters& parameters);
91 
92  //[-------------------------------------------------------]
93  //[ Miscellaneous ]
94  //[-------------------------------------------------------]
95  virtual const qsf::Entity* getFocusEntity() override;
96 
97  //[-------------------------------------------------------]
98  //[ Serialize ]
99  //[-------------------------------------------------------]
100  virtual void serialize(qsf::BinarySerializer& serializer) override;
101 
102 
103  //[-------------------------------------------------------]
104  //[ Protected virtual em5::MainEvent methods ]
105  //[-------------------------------------------------------]
106  protected:
107  virtual void onIntroStart(const qsf::MessageParameters& parameters) override;
108  virtual void onIntroFinished(const qsf::MessageParameters& parameters) override;
109  virtual void onPrologueFinished(const qsf::MessageParameters& parameters) override;
110 
111  //[-------------------------------------------------------]
112  //[ Regular update ]
113  //[-------------------------------------------------------]
114  virtual void onUpdateMainEvent(const qsf::Time& timePassed) override;
115  virtual void onUpdateMusic(const qsf::Time& timePassed) override;
116 
117  virtual uint32 getEventNumber() override;
118 
119 
120  //[-------------------------------------------------------]
121  //[ Private definitions ]
122  //[-------------------------------------------------------]
123  private:
124  struct GangsterConfiguration
125  {
126  qsf::WeakPtr<qsf::Entity> mGangsterEntity;
127  qsf::Time mTimeTillShot;
128 
129  enum Gang
130  {
131  GANG_1,
132  GANG_2
133  } mGang;
134 
135  enum State
136  {
137  SPAWNED, // Spawned, not yet kneeling down
138  MANUAL_SHOOTING_ANIMATIONS, // Hiding behind car and shooting other faction (hard coded animations)
139  FREE_GANGSTER, // Gangster found target and follow it. No way back
140  DISABLED // Gangster has been injured or arrested
141  } mState;
142 
143  GangsterConfiguration(qsf::Entity& gangsterEntity, Gang gang);
144  };
145 
146 
147  //[-------------------------------------------------------]
148  //[ Private methods ]
149  //[-------------------------------------------------------]
150  private:
151  void gatherEventEntities();
152 
153  void startObjectives();
154  void startHintObservers();
155 
156  void updateGangsters(const qsf::Time& timePassed);
157  void updateGangsterAnimation(GangsterConfiguration& gangster, const qsf::Time& timePassed);
158  qsf::Entity* findBestTarget(GangsterConfiguration& gangster) const;
159  bool targetIsBeingAttacked(qsf::Entity& targetEntity) const;
160  int getTargetPriority(qsf::Entity& targetEntity) const;
161 
162 
163  //[-------------------------------------------------------]
164  //[ Private data ]
165  //[-------------------------------------------------------]
166  private:
167  // Connected to CAMP
168  float mPlayerAttackDistance;
169  float mHint01LifeEnergy;
170  int mHint03Count;
171  int mHint04Count;
172  qsf::Time mMinShootTime;
173  qsf::Time mMaxShootTime;
174  float mShotInjuryProbability;
175  qsf::Time mHint13WaitTime;
176  qsf::Time mHint13WaitTime2;
177  qsf::Time mHint14WaitTime;
178  qsf::Time mHint14WaitTime2;
179  qsf::Time mHint12WaitTime;
180  qsf::Time mHint16WaitTime;
181  int mHint17Count;
182  float mHint20LifeEnergy;
183  int mHint21FireCount;
184  qsf::Time mHint27WaitTime;
185  int mFail02Count;
186  int mFail04Count;
187  int mFail05Count;
188  int mFail06Count;
189 
190  // Achievement
191  bool mAllGangstersArrested;
192 
193  // Internal
194  std::vector<GangsterConfiguration> mGangsters;
195  boost::container::flat_map<qsf::Entity*, Observer*> mArrestObservers;
196 
197  std::vector<qsf::Entity*> mInjuredGangsters1;
198  std::vector<qsf::Entity*> mInjuredGangsters2;
199  std::vector<qsf::Entity*> mFires;
200  boost::container::flat_set<qsf::Entity*> mUniqueBurningBuildings;
201  qsf::Entity* mGangsterVehicle;
202  qsf::Entity* mGang1Car;
203  qsf::Entity* mGang2Car;
204  qsf::JobProxy mUpdateJobProxy;
205  qsf::Time mTimePassed;
206  bool mHint01Played;
207 
208  // Ending
209  bool mPlayingWinFadeOut;
210 
211 
212  //[-------------------------------------------------------]
213  //[ CAMP reflection system ]
214  //[-------------------------------------------------------]
215  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
216 
217 
218  };
219 
220 
221 //[-------------------------------------------------------]
222 //[ Namespace ]
223 //[-------------------------------------------------------]
224 } // em5
225 
226 
227 //[-------------------------------------------------------]
228 //[ CAMP reflection system ]
229 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Definition: FreeplayEvent.h:110
Job proxy class.
Definition: JobProxy.h:51
virtual void serialize(qsf::BinarySerializer &serializer) override
Serialization using a binary serializer.
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
virtual void onIntroFinished(const qsf::MessageParameters &parameters) override
React to the end of the intro; note that the prologue cutscene is played next.
EMERGENCY 5 main event base class.
Definition: MainEvent.h:48
unsigned int uint32
Definition: PlatformTypes.h:181
MainEvent07()
Default constructor.
virtual void hintCallback(Observer &hintObserver) override
Handle the activation of a hint observer.
virtual uint32 calculatePointGain(EventResult &eventResult) override
Calculate the point gain for this event.
virtual uint32 getEventNumber() override
Gets number of the main event (Is needed for the highscore management)
Reason
Definition: EventSpreadReason.h:20
virtual void hintCallbackWithMessage(Observer &hintObserver, const qsf::MessageParameters &parameters)
virtual bool onStartup() override
React to startup of the freeplay event.
virtual void onUpdateMusic(const qsf::Time &timePassed) override
Gets called when the main event gets an update call We use here a separate update method...
virtual void onRun() override
React to state change from (initial) hidden state to running state.
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
virtual ~MainEvent07()
Destructor.
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
EMERGENCY 5 main event 07 "Gang War".
Definition: MainEvent07.h:33
virtual void onPrologueFinished(const qsf::MessageParameters &parameters) override
React to the end of the prologue.
virtual bool addEntityToEvent(qsf::Entity &targetEntity, eventspreadreason::Reason eventSpreadReason, bool newReason) override
React to adding to an entity to this event, i.e. setting the event ID for the entity.
virtual void onIntroStart(const qsf::MessageParameters &parameters) override
React to the activation of the black screen, which is the start of the intro cutscene.
Static CAMP main event plugin metaclass collection class.
Definition: MainEventMetaclasses.h:30
virtual void onUpdateMainEvent(const qsf::Time &timePassed) override
Gets called when the main event gets an update call We use here a separate update method...
Binary serializer class.
Definition: BinarySerializer.h:35
static const uint32 FREEPLAY_EVENT_ID
"em5::MainEvent07" unique freeplay event ID
Definition: MainEvent07.h:47
virtual void onShutdown() override
React to shutdown of the freeplay event.
virtual bool onFailure(EventResult &eventResult) override
React to state change from running state to failed state.
State
Definition: FreeplayEvent.h:90
virtual bool onSuccess(EventResult &eventResult) override
React to state change from running state to success state.
virtual const qsf::Entity * getFocusEntity() override
Get an event entity that is currently crucial for this event This is the entity which gets the focus ...
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32