Emergency 20 Dokumentation  4.2.0
TurnToAction.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 //[ Namespace ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25 
26 
27  //[-------------------------------------------------------]
28  //[ Classes ]
29  //[-------------------------------------------------------]
35  {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Public definitions ]
40  //[-------------------------------------------------------]
41  public:
43 
44 
45  //[-------------------------------------------------------]
46  //[ Public static methods ]
47  //[-------------------------------------------------------]
48  public:
49  static bool turnToTarget(qsf::Entity& entity, float timeSeconds, float targetYaw, float turnSpeed = 270.0f);
50  static float calcYawRotationToTarget(const qsf::Entity& sourceEntity, const qsf::Entity& targetEntity, bool reverse);
51 
52 
53  //[-------------------------------------------------------]
54  //[ Public methods ]
55  //[-------------------------------------------------------]
56  public:
61  TurnToAction();
62 
67  virtual ~TurnToAction();
68 
80  void init(uint64 targetEntityId, bool reverse = false, float turnSpeed = 270.0f);
81  void init(const qsf::Entity& targetEntity, bool reverse = false, float turnSpeed = 270.0f);
82 
83  void initWithRotation(const glm::quat& rotation, float turnSpeed = 270.0f);
84  void initWithRotation(const glm::quat& rotation1, const glm::quat& rotation2, float turnSpeed = 270.0f);
85 
90  void addAlternativeRotation(const glm::quat& rotation);
91 
92 
93  //[-------------------------------------------------------]
94  //[ Public virtual qsf::Actions methods ]
95  //[-------------------------------------------------------]
96  public:
97  virtual void serialize(qsf::BinarySerializer& serializer) override;
98 
99 
100  //[-------------------------------------------------------]
101  //[ Protected virtual qsf::Action methods ]
102  //[-------------------------------------------------------]
103  protected:
104  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
105  virtual bool onStartup() override;
106 
107 
108  //[-------------------------------------------------------]
109  //[ Private data ]
110  //[-------------------------------------------------------]
111  private:
112  uint64 mTargetEntityId;
113  float mTurnSpeed;
114  bool mReverse;
115  float mTargetYaw;
116 
117  std::vector<float> mAlternativeYaws; // Multiple Yaws to get the nearest rotations
118 
119 
120  //[-------------------------------------------------------]
121  //[ CAMP reflection system ]
122  //[-------------------------------------------------------]
123  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
124 
125 
126  };
127 
128 
129 //[-------------------------------------------------------]
130 //[ Namespace ]
131 //[-------------------------------------------------------]
132 } // em5
133 
134 
135 //[-------------------------------------------------------]
136 //[ CAMP reflection system ]
137 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Entity class.
Definition: Entity.h:46
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
uint64_t uint64
Definition: PlatformTypes.h:184
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
static const qsf::NamedIdentifier ACTION_ID
"em5::TurnToAction" unique action identifier
Definition: TurnToAction.h:42
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
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
EMERGENCY 5 turn to action.
Definition: TurnToAction.h:34