Emergency 20 Dokumentation  4.2.0
PersonMagnetComponent.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 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
16 #include <qsf/job/JobProxy.h>
18 #include <qsf/time/Time.h>
19 
20 #include <boost/container/flat_map.hpp>
21 
22 
23 //[-------------------------------------------------------]
24 //[ Forward declarations ]
25 //[-------------------------------------------------------]
26 namespace qsf
27 {
28  class TransformComponent;
29 }
30 
31 
32 //[-------------------------------------------------------]
33 //[ Namespace ]
34 //[-------------------------------------------------------]
35 namespace em5
36 {
37 
38 
39  //[-------------------------------------------------------]
40  //[ Classes ]
41  //[-------------------------------------------------------]
47  {
48 
49 
50  //[-------------------------------------------------------]
51  //[ Public definitions ]
52  //[-------------------------------------------------------]
53  public:
54  static const uint32 COMPONENT_ID;
55 
56 
57  //[-------------------------------------------------------]
58  //[ Public methods ]
59  //[-------------------------------------------------------]
60  public:
68  explicit PersonMagnetComponent(qsf::Prototype* prototype);
69 
74  virtual ~PersonMagnetComponent();
75 
80  void enableVisualization(float visualizationRadius);
85  void disableVisualization();
86  bool isVisualizationEnabled() const;
87  float getVisualizationRadius() const;
88 
89  void enableMagnet(float influenceRadius);
90  void disableMagnet();
91  bool isMagnetEnabled() const;
92  float getInfluenceRadius() const;
93 
94  void setCarrierEntityId(uint64 entityId);
95  uint64 getCarrierEntityId() const;
96 
97  void setMaxFollowers(uint32 maxFollowers);
98  uint32 getMaxFollowers() const;
99 
104  glm::vec3 getFollowOffset(uint64 followerEntityId, bool localCoordinates, bool recalculateOffset);
105 
106 
107  //[-------------------------------------------------------]
108  //[ Protected virtual qsf::Component methods ]
109  //[-------------------------------------------------------]
110  protected:
111  virtual void onSetSimulating(bool simulating) override;
112  virtual void onShutdown() override;
113 
114 
115  //[-------------------------------------------------------]
116  //[ Private methods ]
117  //[-------------------------------------------------------]
118  private:
119  void updateJob(const qsf::JobArguments& jobArguments);
120  void cancelMagnet(const qsf::MessageParameters& parameters);
121  void onChangeSelection(const qsf::MessageParameters& parameters);
122 
126  void setUpdateFrequency(qsf::Time updateInterval);
127 
128  glm::vec3 updateFollowerOffset(const qsf::TransformComponent& magnetTransform, const qsf::TransformComponent& followerTransform) const;
129 
130  void switchGroundSpot(bool activate);
131  void removeFollowers();
132 
133 
134  //[-------------------------------------------------------]
135  //[ Private data ]
136  //[-------------------------------------------------------]
137  private:
138  uint32 mMaxFollowers;
139  float mInfluenceRadius;
140  float mPlaceDistMin;
141  float mPlaceDistMax;
142  float mTalkPause;
143  qsf::JobProxy mUpdateJobProxy;
144  qsf::MessageProxy mOnInjuredProxy;
145  qsf::MessageProxy mOnContaminatedProxy;
146  qsf::MessageProxy mOnEnterVehicleProxy;
147  qsf::MessageProxy mOnSelectionChangeProxy;
148  boost::container::flat_map<uint64, glm::vec3> mFollowerOffsets;
149  qsf::Time mTimeLastAnnouncement;
150  uint64 mMagnetCarrier;
151  float mMaxForwardSpeedBackup;
152  float mVisualizationRadius;
153 
154 
155  //[-------------------------------------------------------]
156  //[ CAMP reflection system ]
157  //[-------------------------------------------------------]
158  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
159 
160 
161  };
162 
163 
164 //[-------------------------------------------------------]
165 //[ Namespace ]
166 //[-------------------------------------------------------]
167 } // em5
168 
169 
170 //[-------------------------------------------------------]
171 //[ CAMP reflection system ]
172 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
Message parameters class.
Definition: MessageParameters.h:34
static const uint32 COMPONENT_ID
"em5::PersonMagnetComponent" unique component ID
Definition: PersonMagnetComponent.h:54
unsigned int uint32
Definition: PlatformTypes.h:181
Transform component class.
Definition: TransformComponent.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5. The person magnet will make every (alife, healthy) civilian in it's area follow him...
Definition: PersonMagnetComponent.h:46
Message listener proxy class.
Definition: MessageProxy.h:47
uint64_t uint64
Definition: PlatformTypes.h:184
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
#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
Prototype class.
Definition: Prototype.h:100
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32