Emergency 20 Dokumentation  4.2.0
HistoricPlagueBuildingComponent.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 
17 #include <qsf/job/JobProxy.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25  class BuildingComponent;
26  class FreeplayEvent;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Public definitions ]
50  //[-------------------------------------------------------]
51  public:
52  static const uint32 COMPONENT_ID;
53  static const std::string DECAL_X;
54 
55 
56  //[-------------------------------------------------------]
57  //[ Public static methods ]
58  //[-------------------------------------------------------]
59  public:
64  static HistoricPlagueBuildingComponent& getInstance();
65 
66  /*
67  * @brief
68  * Set if the person icons should be shown
69  */
70  static void showSpawnedEntityIcons(qsf::Entity& entity, bool show);
71 
72  static qsf::Entity* getMarkXDecalFromEntity(qsf::Entity& buildingEntity);
73 
74  static void showPestIconForBuilding(qsf::Entity& entity);
75 
76 
77  //[-------------------------------------------------------]
78  //[ Public methods ]
79  //[-------------------------------------------------------]
80  public:
89 
95 
100  void activateCleanHousesByEntityTag(FreeplayEvent& freeplayEvent, const std::string& entityTag, qsf::Entity& despawnPoint, qsf::Entity& destinationTrigger, bool spawnPersons);
101 
102  bool getMustClean(uint64 entityId) const;
103  void setMustClean(qsf::Entity& buildingEntity, bool mustClean = false);
104 
105  void setLayerName(const std::string& layername);
106 
107  bool isPersonReachedFleeingTrigger() const;
108 
109 
110  //[-------------------------------------------------------]
111  //[ Public virtual qsf::Component methods ]
112  //[-------------------------------------------------------]
113  public:
114  virtual bool onStartup() override;
115  virtual void onShutdown() override;
116  virtual void serialize(qsf::BinarySerializer& serializer) override;
117 
118 
119  //[-------------------------------------------------------]
120  //[ Private methods ]
121  //[-------------------------------------------------------]
122  private:
127  void spawnPersonsFromBuildings(std::vector<BuildingComponent*>& spawnBuildings);
128 
129  std::vector<BuildingComponent*> collectSpawnBuildingsFromMap();
130 
131  void onEntityRemoved(const qsf::MessageParameters& parameters);
132 
133  /*
134  * @brief
135  * Set if the building icons should be shown
136  */
137  void showBuildingIcons(qsf::Entity& buildingEntity, bool show);
138 
139  void setupAndMovePersonToDespawn(qsf::Entity& personEntity, uint64 homeBuildingId);
140 
141 
142  //[-------------------------------------------------------]
143  //[ Private data ]
144  //[-------------------------------------------------------]
145  private:
146  FreeplayEvent* mParentEvent;
147  glm::vec3 mDestinationPosition;
148  qsf::Entity* mDestinationTrigger;
149  std::string mEntityTag;
150 
151  // TODO(co) Public data? Is this correct in here?
152  public:
154  {
156  bool mustClean;
157  };
158  std::vector<MustCleanData> mMustCleanBuildings;
159 
160  private:
161  struct FleeingPersonData
162  {
163  qsf::WeakPtr<qsf::Entity> personEntity;
164  qsf::WeakPtr<qsf::Entity> triggerEntity;
165  };
166 
167  std::vector<FleeingPersonData> mFleeingPersons;
168 
169  qsf::MessageProxy mEntityReturnedProxy;
170  qsf::JobProxy mUpdateJobProxy;
171  uint32 mLayerId;
172 
173 
174  //[-------------------------------------------------------]
175  //[ CAMP reflection system ]
176  //[-------------------------------------------------------]
177  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
178 
179 
180  };
181 
182 
183 //[-------------------------------------------------------]
184 //[ Namespace ]
185 //[-------------------------------------------------------]
186 } // em5
187 
188 
189 //[-------------------------------------------------------]
190 //[ CAMP reflection system ]
191 //[-------------------------------------------------------]
static const uint32 COMPONENT_ID
"em5::HistoricPlagueBuildingComponent" unique component ID
Definition: HistoricPlagueBuildingComponent.h:52
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
bool mustClean
Definition: HistoricPlagueBuildingComponent.h:156
Definition: HistoricPlagueBuildingComponent.h:44
unsigned int uint32
Definition: PlatformTypes.h:181
static const std::string DECAL_X
"decal_x" the meta data tag if the "X"
Definition: HistoricPlagueBuildingComponent.h:53
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: HistoricPlagueBuildingComponent.h:153
Message listener proxy class.
Definition: MessageProxy.h:47
uint64_t uint64
Definition: PlatformTypes.h:184
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
#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
Prototype class.
Definition: Prototype.h:100
Abstract EMERGENCY 5 freeplay event base class.
Definition: FreeplayEvent.h:66
Binary serializer class.
Definition: BinarySerializer.h:35
uint64 entityId
Definition: HistoricPlagueBuildingComponent.h:155
std::vector< MustCleanData > mMustCleanBuildings
Definition: HistoricPlagueBuildingComponent.h:158