Emergency 20 Dokumentation  4.2.0
Objective.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 <boost/noncopyable.hpp>
18 #include <boost/container/flat_set.hpp>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace qsf
25 {
26  class BinarySerializer;
27  class Entity;
28  class Map;
29 }
30 
31 
32 //[-------------------------------------------------------]
33 //[ Namespace ]
34 //[-------------------------------------------------------]
35 namespace em5
36 {
37 
38 
39  //[-------------------------------------------------------]
40  //[ Classes ]
41  //[-------------------------------------------------------]
51  class EM5_API_EXPORT Objective : public boost::noncopyable
52  {
53 
54 
55  //[-------------------------------------------------------]
56  //[ Friends ]
57  //[-------------------------------------------------------]
58  friend class ObjectiveHelper;
59  friend class ObjectiveManager; // Writes the objective unique ID
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public definitions ]
64  //[-------------------------------------------------------]
65  public:
66  typedef boost::container::flat_set<uint64> EntityIdSet;
67  typedef std::array<uint16, 4> PlayerCountMap;
68 
71  {
75  OBJECTIVETYPE_OPTIONAL_FAILED
76  };
77 
78 
79  //[-------------------------------------------------------]
80  //[ Public static methods ]
81  //[-------------------------------------------------------]
82  public:
83  static Objective* getObjectiveById(uint32 id);
84 
85 
86  //[-------------------------------------------------------]
87  //[ Public methods ]
88  //[-------------------------------------------------------]
89  public:
94  Objective(uint32 typeId, ObjectiveType type, uint32 eventId);
95 
100  explicit Objective(qsf::BinarySerializer& serializer);
101 
106  virtual ~Objective();
107 
108  inline uint32 getId() const;
109  inline uint32 getTypeId() const;
110 
115  inline uint32 getFreeplayEventId();
116 
117  inline ObjectiveType getObjectiveType() const;
118  inline void setObjectiveType(ObjectiveType type);
119 
124  inline const std::string& getText() const;
125 
130  inline void setText(const std::string& text);
131 
132  inline uint32 getCurrentNumber() const;
133  void setCurrentNumber(uint32 number);
134 
135  inline uint32 getNeededNumber() const;
136  void setNeededNumber(uint32 number);
137 
138  bool isCurrentEntity(qsf::Entity& entity) const;
139  bool isNeededEntity(qsf::Entity& entity) const;
140 
141  inline const EntityIdSet& getCurrentEntityIdSet() const;
142  inline const EntityIdSet& getNeededEntityIdSet() const;
143 
151  void increaseCurrentNumber(qsf::Entity* entity = nullptr);
152 
160  void decreaseCurrentNumber(qsf::Entity* entity = nullptr);
161 
169  void increaseNeededNumber(qsf::Entity* entity = nullptr);
170 
178  void decreaseNeededNumber(qsf::Entity* entity = nullptr);
179 
180  inline bool checkAccomplished() const;
181  void setAccomplished();
182 
187  uint64 getRandomCurrentEntityId() const;
188 
193  uint64 getRandomNeededEntityId() const;
194 
195  inline bool isHidden() const { return mHidden; }
196  inline void setHidden(bool hidden) { mHidden = hidden; }
197 
198  inline uint32 getOrderPriority() const { return mOrderPriority; }
199  inline void setOrderPriority(uint32 orderPriority) { mOrderPriority = orderPriority; }
200 
205  void updateObjectiveProcess();
206 
207  inline const PlayerCountMap& getPlayerCountMap() const;
208 
209  // Error handling
210  void fulfillNonexistingNeededEntities(qsf::Map& map);
211 
212  //[-------------------------------------------------------]
213  //[ Serialize ]
214  //[-------------------------------------------------------]
215  void serialize(qsf::BinarySerializer& serializer);
216 
217 
218  //[-------------------------------------------------------]
219  //[ Private methods ]
220  //[-------------------------------------------------------]
221  private:
222  bool addCurrentEntity(uint64 entityId);
223  bool removeCurrentEntity(uint64 entityId);
224  bool addNeededEntity(uint64 entityId);
225  bool removeNeededEntity(uint64 entityId);
226  void emitEventChangeMessage();
227 
228 
229  //[-------------------------------------------------------]
230  //[ Private data ]
231  //[-------------------------------------------------------]
232  private:
233  uint32 mUniqueId;
234  uint32 mTypeId;
235  ObjectiveType mObjectiveType;
236  bool mHidden;
237  std::string mText;
238  uint32 mCurrentNumber;
239  uint32 mNeededNumber;
240  EntityIdSet mCurrentEntities;
241  EntityIdSet mNeededEntities;
242  uint32 mFreeplayEventId;
243  uint32 mOrderPriority;
244  PlayerCountMap mPlayerCounter;
245 
246 
247  };
248 
249 
250 //[-------------------------------------------------------]
251 //[ Namespace ]
252 //[-------------------------------------------------------]
253 } // em5
254 
255 
256 //[-------------------------------------------------------]
257 //[ Implementation ]
258 //[-------------------------------------------------------]
260 
261 
262 //[-------------------------------------------------------]
263 //[ CAMP reflection system ]
264 //[-------------------------------------------------------]
void setHidden(bool hidden)
Definition: Objective.h:196
Definition: ActionPriority.h:13
boost::container::flat_set< uint64 > EntityIdSet
Definition: Objective.h:66
std::array< uint16, 4 > PlayerCountMap
Definition: Objective.h:67
Objective is a fail condition, and will lead to a failure if accomplished.
Definition: Objective.h:73
Entity class.
Definition: Entity.h:46
Map class.
Definition: Map.h:93
unsigned int uint32
Definition: PlatformTypes.h:181
uint32 getOrderPriority() const
Definition: Objective.h:198
#define EM5_API_EXPORT
Definition: Export.h:28
uint64_t uint64
Definition: PlatformTypes.h:184
bool isHidden() const
Definition: Objective.h:195
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
EMERGENCY 5 objective class.
Definition: Objective.h:51
Definition: PickupPersonByParamedicAction.h:21
EMERGENCY 5 objective helper class.
Definition: ObjectiveHelper.h:43
ObjectiveType
Definition: Objective.h:70
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Objective is required for success.
Definition: Objective.h:72
EMERGENCY 5 objective manager.
Definition: ObjectiveManager.h:45
void setOrderPriority(uint32 orderPriority)
Definition: Objective.h:199
Objective is optional (irrelevant for success) and still open.
Definition: Objective.h:74
Binary serializer class.
Definition: BinarySerializer.h:35