Emergency 20 Dokumentation  4.2.0
EvadePlayerUnitsLogic.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/job/JobProxy.h>
17 
18 #include <boost/optional.hpp>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace qsf
25 {
26  class JobArguments;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Public definitions ]
50  //[-------------------------------------------------------]
51  public:
52  static const uint32 GAMELOGIC_TYPE_ID; // "em5::CarsEvadesPlayerUnitsLogic" game logic type ID
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public methods ]
57  //[-------------------------------------------------------]
58  public:
60 
69  void registerApproachFromEmergencyVehicle(qsf::Time approachTime, const qsf::ai::SpatialConfiguration3D& approachConfig);
70 
75  bool hasActiveApproach() const;
76 
84 
85 
86  //[-------------------------------------------------------]
87  //[ Public virtual qsf::GameLogic methods ]
88  //[-------------------------------------------------------]
89  public:
90  virtual bool onStartup() override;
91  virtual void onShutdown() override;
92 
93 
94  //[-------------------------------------------------------]
95  //[ Private methods ]
96  //[-------------------------------------------------------]
97  private:
98  // Job updates
99  void updateSimulation(const qsf::JobArguments& jobArguments);
100 
101  // Core logic that checks whether we should evade right now
102  void evadeIfNecessary(const qsf::Time& now);
103 
104 
105  //[-------------------------------------------------------]
106  //[ Private definitions ]
107  //[-------------------------------------------------------]
108  private:
109  static const uint32 ACTION_PRIORITY;
110 
111 
112  //[-------------------------------------------------------]
113  //[ Private data ]
114  //[-------------------------------------------------------]
115  private:
116  qsf::JobProxy mSimulationJobProxy;
117  boost::optional<qsf::Time> mNearestApproachRegistered;
118  qsf::ai::SpatialConfiguration3D mNearestApproachConfig;
119  bool mHadRelevantApproachInLastUpdate;
120 
121 
122  //[-------------------------------------------------------]
123  //[ CAMP reflection system ]
124  //[-------------------------------------------------------]
125  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
126 
127 
128  };
129 
130 
131 //[-------------------------------------------------------]
132 //[ Namespace ]
133 //[-------------------------------------------------------]
134 } // em5
135 
136 
137 //[-------------------------------------------------------]
138 //[ CAMP reflection system ]
139 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
virtual bool onStartup() override
Startup the game logic.
Job proxy class.
Definition: JobProxy.h:51
static const uint32 GAMELOGIC_TYPE_ID
Definition: EvadePlayerUnitsLogic.h:52
unsigned int uint32
Definition: PlatformTypes.h:181
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Definition: PickupPersonByParamedicAction.h:21
bool hasActiveApproach() const
Returns whether there was an approaching entity registered during the last update that was close enou...
virtual void onShutdown() override
Shutdown the game logic.
#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
A game logic that lets entity drive to the side of the road when units on emergency operations ("Alar...
Definition: EvadePlayerUnitsLogic.h:44
Game logic base class.
Definition: GameLogic.h:44
void registerApproachFromEmergencyVehicle(qsf::Time approachTime, const qsf::ai::SpatialConfiguration3D &approachConfig)
Register an approaching vehicle on emergency operations.
const qsf::ai::SpatialConfiguration3D & getLastApproachConfiguration() const
Returns the spatial AI configuration of the last registered approaching player unit on emergency oper...
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32