Emergency 20 Dokumentation  4.2.0
HuntAndShootAction.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 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace qsf
22 {
23  class PhysicsWorldComponent;
24 }
25 
26 
27 //[-------------------------------------------------------]
28 //[ Namespace ]
29 //[-------------------------------------------------------]
30 namespace em5
31 {
32 
33 
34  //[-------------------------------------------------------]
35  //[ Classes ]
36  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Public definitions ]
50  //[-------------------------------------------------------]
51  public:
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public methods ]
57  //[-------------------------------------------------------]
58  public:
64 
69  virtual ~HuntAndShootAction();
70 
75  void init(qsf::Entity& targetEntity, const weapon::WeaponConfiguration& weaponConfiguration);
76 
81  float getShootRange() const;
82 
83 
84  //[-------------------------------------------------------]
85  //[ Public virtual qsf::Actions methods ]
86  //[-------------------------------------------------------]
87  public:
88  virtual void serialize(qsf::BinarySerializer& serializer) override;
89 
90 
91  //[-------------------------------------------------------]
92  //[ Protected virtual qsf::Action methods ]
93  //[-------------------------------------------------------]
94  protected:
95  virtual bool onStartup() override;
96  virtual void onShutdown() override;
97  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
98 
99 
100  //[-------------------------------------------------------]
101  //[ Private methods ]
102  //[-------------------------------------------------------]
103  private:
104  bool isTargetValid() const;
105  void playStandUpAnimation();
106  void showOutOfRangeHint(const glm::vec3& position) const;
107  bool hasFreeSightlineTo(qsf::PhysicsWorldComponent* physicsWorldComponent, const qsf::TransformComponent& startTransform, const qsf::TransformComponent& targetTransform, qsf::Entity* targetEntity);
108 
109 
110  //[-------------------------------------------------------]
111  //[ Private definitions ]
112  //[-------------------------------------------------------]
113  private:
114  enum State
115  {
116  STATE_INIT,
117  STATE_GOTOTARGET,
118  STATE_SHOOT,
119  STATE_END
120  };
121 
122 
123  //[-------------------------------------------------------]
124  //[ Private data ]
125  //[-------------------------------------------------------]
126  private:
127  State mCurrentState;
128  qsf::WeakPtr<qsf::Entity> mTargetEntity;
129  uint32 mNumberOfShots;
130  weapon::WeaponConfiguration mWeaponConfiguration;
131 
132 
133  //[-------------------------------------------------------]
134  //[ CAMP reflection system ]
135  //[-------------------------------------------------------]
136  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
137 
138 
139  };
140 
141 
142 //[-------------------------------------------------------]
143 //[ Namespace ]
144 //[-------------------------------------------------------]
145 } // em5
146 
147 
148 //[-------------------------------------------------------]
149 //[ CAMP reflection system ]
150 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Entity class.
Definition: Entity.h:46
unsigned int uint32
Definition: PlatformTypes.h:181
Transform component class.
Definition: TransformComponent.h:33
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
Component managing a bullet dynamic collision world. Currently it is optimized to the specific AI nee...
Definition: PhysicsWorldComponent.h:59
Definition: WeaponConfiguration.h:31
static const qsf::NamedIdentifier ACTION_ID
"em5::HuntAndShootAction" unique action identifier
Definition: HuntAndShootAction.h:52
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Definition: PickupPersonByParamedicAction.h:21
EMERGENCY 5 hunt and shoot action.
Definition: HuntAndShootAction.h:44
State
Definition: ProcessState.h:20
#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
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