Emergency 20 Dokumentation  4.2.0
RepairOrUseAction.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/audio/AudioProxy.h"
14 
16 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23  class RoadVehicleComponent;
24 }
25 
26 
27 //[-------------------------------------------------------]
28 //[ Namespace ]
29 //[-------------------------------------------------------]
30 namespace em5
31 {
32 
33 
34  //[-------------------------------------------------------]
35  //[ Classes ]
36  //[-------------------------------------------------------]
42  {
43 
44 
45  //[-------------------------------------------------------]
46  //[ Public definitions ]
47  //[-------------------------------------------------------]
48  public:
50 
51  enum Posture
52  {
55  INBULIDING
56  };
57 
58  enum Target
59  {
61  OBJECT, // any object with a UsableByEngineerComponent
62  BUILDING
63  };
64 
65 
66  //[-------------------------------------------------------]
67  //[ Public methods ]
68  //[-------------------------------------------------------]
69  public:
75 
80  virtual ~RepairOrUseAction();
81 
86  void init(const qsf::Entity& targetEntity, Posture posture, Target target=VEHICLE);
87 
88  uint64 getTargetEntityId() const;
89 
90 
91  //[-------------------------------------------------------]
92  //[ Public virtual qsf::Actions methods ]
93  //[-------------------------------------------------------]
94  public:
95  virtual void serialize(qsf::BinarySerializer& serializer) override;
96 
97 
98  //[-------------------------------------------------------]
99  //[ Protected virtual qsf::Action methods ]
100  //[-------------------------------------------------------]
101  protected:
102  virtual bool onStartup() override;
103  virtual qsf::action::Result updateAction(const qsf::Clock& clock) override;
104  virtual void onShutdown() override;
105 
106 
107  //[-------------------------------------------------------]
108  //[ Private methods ]
109  //[-------------------------------------------------------]
110  private:
111  void updateRepairVehicle(const qsf::Time& timePassed, RoadVehicleComponent& roadVehicleComponent, qsf::Entity& vehicleEntity);
112 
113  // NOTE - toolbox is mostly copy-pasted from the medikit stuff in TreatPersonAction. Just found no place to unify it.
114  // I tried putting that parts into an own action first, but that makes it harder to guarantee a cleanup as actions can't be
115  // inserted in the destructor with the guarantee that they will be called.
116  void placeToolbox();
117  void takeToolbox();
118  void openToolbox() const;
119  void closeToolbox() const;
120 
121 
122  //[-------------------------------------------------------]
123  //[ Private data ]
124  //[-------------------------------------------------------]
125  private:
126  enum State
127  {
128  INIT,
129  STATE_GET_DOWN,
130  STATE_OPEN_TOOLBOX,
131  START_REPAIRING,
132  REPAIRING,
133  USING_OBJECT,
134  REPARING_BUILDING,
135  STATE_CLOSE_TOOLBOX,
136  STATE_GET_UP
137  };
138 
139  Posture mPosture;
140  Target mTarget;
141  State mState;
142  bool mToolboxPlaced;
143  uint64 mTargetEntityId;
144  qsf::WeakPtr<qsf::Entity> mToolboxEntity;
145  AudioProxy mAudioProxy;
146 
147  qsf::Time mTimeUntilObjectIsUsed;
148  qsf::Time mTimeUntilNextRepairStep;
149  qsf::Time mTimeUntilRepairSteps;
150  float mAmountDamagePerRepairStep;
151 
152 
153  //[-------------------------------------------------------]
154  //[ CAMP reflection system ]
155  //[-------------------------------------------------------]
156  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
157 
158 
159  };
160 
161 
162 //[-------------------------------------------------------]
163 //[ Namespace ]
164 //[-------------------------------------------------------]
165 } // em5
166 
167 
168 //[-------------------------------------------------------]
169 //[ CAMP reflection system ]
170 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Entity class.
Definition: Entity.h:46
Definition: RepairOrUseAction.h:54
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: RepairOrUseAction.h:60
static const qsf::NamedIdentifier ACTION_ID
"em5::RepairOrUseAction" unique action identifier
Definition: RepairOrUseAction.h:49
Definition: RepairOrUseAction.h:61
uint64_t uint64
Definition: PlatformTypes.h:184
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
Definition: RepairOrUseAction.h:53
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
Target
Definition: RepairOrUseAction.h:58
EMERGENCY 5 road vehicle component class.
Definition: RoadVehicleComponent.h:54
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
EMERGENCY 5 repair vehicle or use object action.
Definition: RepairOrUseAction.h:41
Result
Definition: ActionResult.h:20
Posture
Definition: RepairOrUseAction.h:51
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32