Emergency 20 Dokumentation  4.2.0
LinearMoveAction.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 
17 #include <glm/fwd.hpp>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25  class GameComponent;
26 }
27 
28 
29 //[-------------------------------------------------------]
30 //[ Namespace ]
31 //[-------------------------------------------------------]
32 namespace em5
33 {
34 
35 
36  //[-------------------------------------------------------]
37  //[ Classes ]
38  //[-------------------------------------------------------]
44  {
45 
46 
47  //[-------------------------------------------------------]
48  //[ Public definitions ]
49  //[-------------------------------------------------------]
50  public:
52  static const float TOLERANCE;
53  static const float DEFAULT_MAX_SPEED;
54  static const float DEFAULT_ACCELERATION;
55 
56 
57  //[-------------------------------------------------------]
58  //[ Public methods ]
59  //[-------------------------------------------------------]
60  public:
66 
71  virtual ~LinearMoveAction();
72 
84  void init(const glm::vec3& targetPosition, float minDistance = 0.0f, float maxDistance = std::numeric_limits<float>::max());
85 
86 
87  //[-------------------------------------------------------]
88  //[ Public virtual qsf::Action methods ]
89  //[-------------------------------------------------------]
90  public:
91  virtual void serialize(qsf::BinarySerializer& serializer) override;
92 
93 
94  //[-------------------------------------------------------]
95  //[ Protected virtual qsf::Action methods ]
96  //[-------------------------------------------------------]
97  protected:
98  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
99  virtual bool onStartup() override;
100  virtual void onShutdown() override;
101  virtual void onAbort() override;
102 
103 
104  //[-------------------------------------------------------]
105  //[ Private methods ]
106  //[-------------------------------------------------------]
107  private:
108  float getMovementSpeed(float oldSpeed, float secondsPassed, float distance);
109 
110 
111  //[-------------------------------------------------------]
112  //[ Private data ]
113  //[-------------------------------------------------------]
114  private:
115 
116  glm::vec3 mTargetPosition;
117  float mMinDistance;
118  float mMaxDistance;
119  float mMaxSpeed;
120  float mAcceleration;
121 
122 
123  //[-------------------------------------------------------]
124  //[ CAMP reflection system ]
125  //[-------------------------------------------------------]
126  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
127 
128 
129  };
130 
131 
132 //[-------------------------------------------------------]
133 //[ Namespace ]
134 //[-------------------------------------------------------]
135 } // em5
136 
137 
138 //[-------------------------------------------------------]
139 //[ CAMP reflection system ]
140 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
static const float DEFAULT_ACCELERATION
Definition: LinearMoveAction.h:54
Clock class.
Definition: Clock.h:33
static const float DEFAULT_MAX_SPEED
Definition: LinearMoveAction.h:53
#define EM5_API_EXPORT
Definition: Export.h:28
static const qsf::NamedIdentifier ACTION_ID
"em5::MoveAction" unique action identifier
Definition: LinearMoveAction.h:51
static const float TOLERANCE
Definition: LinearMoveAction.h:52
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 linear move action on XZ plane ignoring all collisions.
Definition: LinearMoveAction.h:43
Abstract action base class.
Definition: Action.h:59
Class combining strings with their hashes.
Definition: NamedIdentifier.h:34
Binary serializer class.
Definition: BinarySerializer.h:35
Result
Definition: ActionResult.h:20