Emergency 20 Dokumentation  4.2.0
AiSpeedLimitFunctor.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 //[ Forward declarations ]
18 //[-------------------------------------------------------]
19 namespace qsf
20 {
21  class Clock;
22  namespace game
23  {
24  class WeatherComponent;
25  class TimeOfDayComponent;
26  }
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
49  {
50 
51 
52  //[-------------------------------------------------------]
53  //[ Private definitions ]
54  //[-------------------------------------------------------]
55  private:
56  struct SpeedCacheEntry
57  {
58  qsf::Time mLastUpdate;
59  float mTargetResult;
60  float mLastResult;
61  };
62 
63 
64  //[-------------------------------------------------------]
65  //[ Public methods ]
66  //[-------------------------------------------------------]
67  public:
73 
74 
75  //[-------------------------------------------------------]
76  //[ Public virtual qsf::ai::SpeedLimitFunctor methods ]
77  //[-------------------------------------------------------]
78  public:
79  virtual qsf::UnsignedFloat getSpeedFor(const qsf::ai::NavigationComponent& navi, qsf::UnsignedFloat speedLimit) const override;
80  virtual qsf::UnsignedFloat getHaltingDistanceBefore(const qsf::ai::NavigationComponent& navi, qsf::Entity& other, qsf::UnsignedFloat defaultDistance) const override;
81 
82 
83  //[-------------------------------------------------------]
84  //[ Private methods ]
85  //[-------------------------------------------------------]
86  private:
87  void calculateSpeed(const qsf::ai::NavigationComponent& navigationComponent, float& newSpeedLimit) const;
88 
89 
90  //[-------------------------------------------------------]
91  //[ Private data ]
92  //[-------------------------------------------------------]
93  private:
94  const qsf::game::WeatherComponent* mWeatherComponent;
95  const qsf::game::TimeOfDayComponent* mTimeOfDayComponent;
96  const qsf::Clock& mSimulationClock;
97 
98  typedef std::unordered_map<uint64, AiSpeedLimitFunctor::SpeedCacheEntry> SpeedCache;
99  mutable SpeedCache mSpeedCache;
100 
101 
102  };
103 
104 
105 //[-------------------------------------------------------]
106 //[ Namespace ]
107 //[-------------------------------------------------------]
108 } // em5
Definition: ActionPriority.h:13
Definition: NavigationComponent.h:78
Entity class.
Definition: Entity.h:46
Clock class.
Definition: Clock.h:33
Speed limit functor for EMERGENCY 5.
Definition: AiSpeedLimitFunctor.h:48
Time of day component class.
Definition: TimeOfDayComponent.h:55
Definition: SpeedLimitFunctor.h:23
AiSpeedLimitFunctor()
Default constructor.
Weather core component class.
Definition: WeatherComponent.h:64
Definition: PickupPersonByParamedicAction.h:21
Definition: UnsignedFloat.h:33
virtual qsf::UnsignedFloat getSpeedFor(const qsf::ai::NavigationComponent &navi, qsf::UnsignedFloat speedLimit) const override
Speed Limit functor main method - shall return maximum speed (in world units per second) for the navi...
virtual qsf::UnsignedFloat getHaltingDistanceBefore(const qsf::ai::NavigationComponent &navi, qsf::Entity &other, qsf::UnsignedFloat defaultDistance) const override
Speed Limit functor auxiliary method - shall return the distance to keep between the active navigatio...
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32