Emergency 20 Dokumentation  4.2.0
MapHelper.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"
15 
17 #include <qsf/base/StringHash.h>
18 #include <qsf/map/MapHelper.h>
19 
20 #include <glm/gtx/quaternion.hpp>
21 
22 #include <vector>
23 
24 
25 //[-------------------------------------------------------]
26 //[ Forward declarations ]
27 //[-------------------------------------------------------]
28 namespace qsf
29 {
30  class Entity;
31  class Layer;
32  class Map;
33  class ParticlesComponent;
34  class Transform;
35  class TransformComponent;
36 }
37 namespace em5
38 {
39  class Player;
40 }
41 
42 
43 //[-------------------------------------------------------]
44 //[ Namespace ]
45 //[-------------------------------------------------------]
46 namespace em5
47 {
48 
49 
50  //[-------------------------------------------------------]
51  //[ Classes ]
52  //[-------------------------------------------------------]
58  {
59 
60 
61  //[-------------------------------------------------------]
62  //[ Public static methods ]
63  //[-------------------------------------------------------]
64  public:
69  static bool destroyEntity(qsf::Entity& entity);
70 
75  static void flyCameraToPosition(const glm::vec3& position, const Player& player, bool keepCurrentZoom);
76 
81  static void flyCameraToEntity(const qsf::Entity& focusEntity, const Player& player, bool keepCurrentZoom);
82 
87  static bool isUnitAutomatismActive();
88 
93  static bool isDamageSimulationActive();
94 
99  static void resetStoredGangsterEventAreaInformation();
100 
101  static void resetNextEntityIdForMultiplay();
102 
103  static void activateLayer(qsf::Layer& layer, bool activate);
104 
105 
106  //[-------------------------------------------------------]
107  //[ Public methods ]
108  //[-------------------------------------------------------]
109  public:
114  explicit inline MapHelper(qsf::Map& map);
115 
120  inline ~MapHelper();
121 
126  bool destroyEntityById(uint64 entityId);
127 
132  qsf::Entity* createObjectByLocalPrefabAssetId(const qsf::StringHash& localAssetId, bool sendMessage = true) const;
133 
140  qsf::Entity* createEntityByPrototypeReference(const qsf::Prototype& prototype, bool sendMessage = true) const;
141 
159  void showEntityParticleIds(const std::vector<uint64>& particleEntityIds, bool show, bool repeatAnimation, bool showByHeight = false, float worldYOffset = 0.0f, bool restart = false) const;
160 
168  void disableEntityParticleIds(const std::vector<uint64>& particleEntityIds) const;
169 
177  void hideParticleChildrenAtMapSave(std::vector<uint64>& particleIds) const;
178 
183  qsf::ParticlesComponent* spawnParticle(qsf::LocalAssetId prefabAssetId, float timeout, const glm::vec3& position, const glm::vec3& scale=glm::vec3(1.f, 1.f, 1.f), const glm::quat& rotation=glm::quat(), bool isMultiplayerRelevant = true);
184 
185  void showEntityIds(std::vector<uint64>& entityIds, bool show, bool showByHeight = false, float worldYOffset = 0.0f) const;
186 
187  template <typename T>
188  void showComponentofEntityIds(std::vector<uint64>& entityIds, bool show) const;
189 
194  bool isNightTime() const;
195 
203  qsf::Entity* getHeadQuarter() const;
204 
212  bool isContaminationArea(const glm::vec3& position) const;
213 
221  std::pair<qsf::TransformComponent*, bool> getGangsterEventArea() const;
222 
229  qsf::Entity* createObjectWithinGangsterEventAreaByLocalPrefabAssetId(const qsf::StringHash& localAssetId) const;
230 
237  qsf::Entity* createGangsterFromPoolAndSpawnItInGangsterEventArea(GangsterPool gangsterPoolType) const;
238 
243  std::string getSpawnpoolNameFromGangsterPool(GangsterPool gangsterPoolType) const;
244 
251  qsf::Entity* getOrCreateGangsterCandidateInGangsterEventArea(GangsterPool gangsterPoolType, const std::string& gangsterTag = "") const;
252 
259  qsf::Entity* replaceCombinedEntityWithRealOne(qsf::Entity& combinedEntity) const;
260 
261  bool isInMapBoundaries(const glm::vec3& position) const;
262  bool isInEventBoundaries(const glm::vec3& position) const;
263 
268  bool isEntityCloseToMapBoundaries(qsf::Entity& entity, float tolerance = 1.0f);
269 
274  bool isEntityCloseToEventBoundaries(qsf::Entity& entity, float tolerance = 1.0f);
275 
280  void prepareMapBorderLayer(const std::string& layerName);
281 
286  void unlockUpgradeComponent(const std::string& upgradeName);
287 
300  void setEnergySectionEnabled(const qsf::StringHash& eventTag, bool enabled) const;
301  void setEnergySectionEnabled(const std::vector<qsf::Entity*>& areaBoxes, bool enabled) const;
302 
312  void evacuateAllUnits(const qsf::StringHash& fromEventTag, const qsf::StringHash& toEventTag, const std::vector<uint64>& ignoreEntityIds = std::vector<uint64>()) const;
313 
314  void removeAllCiviliansInArea(const qsf::StringHash& areaEventTag);
315  void removeAllCivilPersonsInArea(const qsf::StringHash& areaEventTag);
316  void removeAllCivilVehiclesInArea(const qsf::StringHash& areaEventTag);
317 
318  void removeCiviliansInArea(const qsf::StringHash& areaEventTag, bool ignorePersons, bool ignoreVehicles);
319 
320  bool getPointOnClosestLane(const glm::vec3& position, uint32 aiWorldIndex, uint32 laneTypeId, qsf::Transform& outTransform, boost::optional<glm::vec3> wantedDirection = boost::optional<glm::vec3>());
321 
322 
323  //[-------------------------------------------------------]
324  //[ Private static data ]
325  //[-------------------------------------------------------]
326  private:
327  static std::pair<qsf::TransformComponent*, bool> mGangsterEventArea;
328 
329 
330  };
331 
332 
333 //[-------------------------------------------------------]
334 //[ Namespace ]
335 //[-------------------------------------------------------]
336 } // em5
337 
338 
339 //[-------------------------------------------------------]
340 //[ Implementation ]
341 //[-------------------------------------------------------]
342 #include "em5/map/MapHelper-inl.h"
Definition: ActionPriority.h:13
Entity class.
Definition: Entity.h:46
Map class.
Definition: Map.h:93
Layer class.
Definition: Layer.h:56
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Map helper class.
Definition: MapHelper.h:44
uint64_t uint64
Definition: PlatformTypes.h:184
EMERGENCY 5 player class.
Definition: Player.h:57
3D transform class
Definition: Transform.h:45
Definition: PickupPersonByParamedicAction.h:21
EMERGENCY 5 map helper class.
Definition: MapHelper.h:57
uint32 LocalAssetId
Definition: AssetSystemTypes.h:35
GangsterPool
Defines pools of gangster prefabs needed for a events. Only prefabs from the resp. pool are picked for new gangster entities.
Definition: GangsterPool.h:22
Prototype class.
Definition: Prototype.h:100
Compile time string hash class.
Definition: StringHash.h:59
Particles component class.
Definition: ParticlesComponent.h:58