Emergency 20 Dokumentation  4.2.0
ArrestGangsterAction.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 #include "em5/audio/AudioProxy.h"
15 
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24 
25 
26  //[-------------------------------------------------------]
27  //[ Classes ]
28  //[-------------------------------------------------------]
34  {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Public definitions ]
39  //[-------------------------------------------------------]
40  public:
42 
43  static const uint64 FIGHT_ROUNDS;
44 
45 
46  //[-------------------------------------------------------]
47  //[ Public static methods ]
48  //[-------------------------------------------------------]
49  public:
50  static void setArrestedParameters(qsf::Entity& arrestedEntity, bool arrested);
51 
52  // Offset between player and target
53  // Usually this is in the target points, but arresting has none so far, so I had to put it here
54  static glm::vec3 getArrestOffset();
55  static glm::vec3 getFightingOffset();
56  static glm::vec3 getFightingLongRangeOffset();
57 
58 
59  //[-------------------------------------------------------]
60  //[ Public methods ]
61  //[-------------------------------------------------------]
62  public:
68 
73  virtual ~ArrestGangsterAction();
74 
79  void init(const qsf::Entity& targetEntity);
80 
81  uint64 getTargetEntityId() 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  weapon::Weapon getWeaponFromGangster() const;
105  void ensureRelativePositions(bool arrestSituation);
106 
107 
108  //[-------------------------------------------------------]
109  //[ Private definitions ]
110  //[-------------------------------------------------------]
111  private:
112  enum State
113  {
114  STATE_INIT,
115  STATE_FIGHT,
116  STATE_ARRESTING,
117  STATE_WAIT_FOR_ANIMATIONS,
118  STATE_DONE
119  };
120 
121 
122  //[-------------------------------------------------------]
123  //[ Private data ]
124  //[-------------------------------------------------------]
125  private:
126  // Configuration
127  uint64 mTargetEntityId;
128  qsf::WeakPtr<qsf::Entity> mTargetEntity;
129 
130  State mCurrentState;
131  AudioProxy mAudioProxy;
132 
133 
134  //[-------------------------------------------------------]
135  //[ CAMP reflection system ]
136  //[-------------------------------------------------------]
137  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
138 
139 
140  };
141 
142 
143 //[-------------------------------------------------------]
144 //[ Namespace ]
145 //[-------------------------------------------------------]
146 } // em5
147 
148 
149 //[-------------------------------------------------------]
150 //[ CAMP reflection system ]
151 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Entity class.
Definition: Entity.h:46
EMERGENCY 5 arrest gangster action.
Definition: ArrestGangsterAction.h:33
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
State
Definition: ProcessState.h:20
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
Extended audio proxy for easier multiplay usage.
Definition: AudioProxy.h:47
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Weapon
Definition: Weapon.h:22
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
static const uint64 FIGHT_ROUNDS
number of fight rounds before a gangster is arrested
Definition: ArrestGangsterAction.h:43
static const qsf::NamedIdentifier ACTION_ID
"em5::ArrestGangsterAction" unique action identifier
Definition: ArrestGangsterAction.h:41