Emergency 20 Dokumentation  4.2.0
UseDivingSpotAction.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 
18 //[-------------------------------------------------------]
19 //[ Namespace ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23 
24 
25  //[-------------------------------------------------------]
26  //[ Classes ]
27  //[-------------------------------------------------------]
33  {
34 
35 
36  //[-------------------------------------------------------]
37  //[ Public definitions ]
38  //[-------------------------------------------------------]
39  public:
41 
42 
43  //[-------------------------------------------------------]
44  //[ Public methods ]
45  //[-------------------------------------------------------]
46  public:
52 
57  virtual ~UseDivingSpotAction();
58 
63  void init(const qsf::Entity& targetEntity);
64 
65  uint64 getTargetEntityId() const;
66 
67 
68  //[-------------------------------------------------------]
69  //[ Public virtual qsf::Actions methods ]
70  //[-------------------------------------------------------]
71  public:
72  virtual void serialize(qsf::BinarySerializer& serializer) override;
73 
74 
75  //[-------------------------------------------------------]
76  //[ Protected virtual qsf::Action methods ]
77  //[-------------------------------------------------------]
78  protected:
79  virtual bool onStartup() override;
80  virtual void onShutdown() override;
81  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
82 
83 
84  //[-------------------------------------------------------]
85  //[ Private definitions ]
86  //[-------------------------------------------------------]
87  private:
88  enum State
89  {
90  STATE_INIT,
91  STATE_DIVE_DOWN,
92  STATE_DIVING,
93  STATE_DIVING_END
94  };
95 
96  enum LootType
97  {
98  LOOT_NONE,
99  LOOT_CAR,
100  LOOT_PERSON
101  };
102 
103 
104  //[-------------------------------------------------------]
105  //[ Private methods ]
106  //[-------------------------------------------------------]
107  private:
108  void handleDivingState();
109  void handleResultNone();
110  qsf::Entity* spawnBuoyEntity() const;
111  qsf::Entity* spawnUnderWaterTarget();
112  void handleUnderWaterTarget(qsf::Entity& underWaterTarget);
113  void createMessage(const qsf::Entity& underWaterTarget);
114  void flagDivingSpotAsUsed();
115 
116  // Overlay has to be attached to some visible part of the diving-spot
117  qsf::Entity* getVisibleDivingSpotEntity() const;
118  void showHint() const;
119 
120 
121  //[-------------------------------------------------------]
122  //[ Private data ]
123  //[-------------------------------------------------------]
124  private:
125  uint64 mTargetEntityId;
126  State mState;
127  float mDivingTimeMax;
128  qsf::Time mDiveTime;
129  uint64 mParticlesId;
130  qsf::WeakPtr<qsf::Entity> mUnderwaterEntity;
131  LootType mLootType;
132  bool mWasInvincible;
133 
134 
135  //[-------------------------------------------------------]
136  //[ CAMP reflection system ]
137  //[-------------------------------------------------------]
138  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
139 
140 
141  };
142 
143 
144 //[-------------------------------------------------------]
145 //[ Namespace ]
146 //[-------------------------------------------------------]
147 } // em5
148 
149 
150 //[-------------------------------------------------------]
151 //[ CAMP reflection system ]
152 //[-------------------------------------------------------]
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
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
EMERGENCY 5 use diving spot action.
Definition: UseDivingSpotAction.h:32
Class combining strings with their hashes.
Definition: NamedIdentifier.h:34
Binary serializer class.
Definition: BinarySerializer.h:35
Result
Definition: ActionResult.h:20
static const qsf::NamedIdentifier ACTION_ID
"em5::UseDivingSpotAction" unique action identifier
Definition: UseDivingSpotAction.h:40
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32