My Project
SpawnEnemySystem.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** B-CPP-500-PAR-5-1-rtype-martin.vanaud
4 ** File description:
5 ** SpawnEnemySystem
6 */
7 
8 #ifndef SPAWNENEMYSYSTEM_HPP_
9  #define SPAWNENEMYSYSTEM_HPP_
10 
11  #include <utility>
12  #include <unordered_map>
13  #include <functional>
14 
15  /* Ecs */
16  #include "Registry.hpp"
17 
18  /* Components */
19  #include "Component/CNetworkQueue.hpp"
20  #include "Component/CPosition.hpp"
21  #include "Component/CType.hpp"
22  #include "Component/CTimer.hpp"
23  #include "Component/CLobbiesStatus.hpp"
24  #include "Component/CMap.hpp"
25  #include "Component/CHealth.hpp"
26 
27  /* Structure */
28  #include "Structure/spec.hpp"
29 
33 namespace System {
38  public:
43  ~SpawnEnemySystem() = default;
44 
56  void operator()(
57  Registry &registry,
65  );
66 
77  Entity createEnemyFromSpec(Registry &registry, int enemyType, int lobby_id, std::size_t line, std::size_t map_size);
78 
79  protected:
80  private:
87  nlohmann::json getJsonData(std::string const &filepath);
88 
94  void loadAssets(std::string const &filepath);
95 
96  enum MAPCONTENT {
97  EMPTY = '0',
98  ENEMY1 = '1',
99  ENEMY2 = '2',
100  ENEMY3 = '3'
101  };
102  std::pair<int, int> _mapDimension;
103  std::unordered_map<MAPCONTENT, int> _entityCreator;
104  std::vector<spec_t> _enemySpec;
105  };
106 }
107 
108 #endif /* !SPAWNENEMYSYSTEM_HPP_ */
Sparse_array
Class that handle Element of type Component like a vector which can be holed.
Definition: SparseArray.hpp:22
System
Namespace for systems.
Definition: DirectionSystem.hpp:24
Registry
Class that handle ECS.
Definition: Registry.hpp:22
System::SpawnEnemySystem
The SpawnEnemy System class, it handles all packets related to the spawn of an enemy in the game.
Definition: SpawnEnemySystem.hpp:37
System::SpawnEnemySystem::operator()
void operator()(Registry &registry, Sparse_array< component::cnetwork_queue_t > &netqueue, Sparse_array< component::cposition_t > &position, Sparse_array< component::ctype_t > &type, Sparse_array< component::ctimer_t > &timer, Sparse_array< component::clobbies_status_t > &lobbiesStatus, Sparse_array< component::cmap_t > &map, Sparse_array< component::chealth_t > &health)
The main handler for the SpawnEnemy System.
Definition: SpawnEnemySystem.cpp:38
Entity
Class that handle entity in a sparse array like an index.
Definition: Entity.hpp:16
System::SpawnEnemySystem::createEnemyFromSpec
Entity createEnemyFromSpec(Registry &registry, int enemyType, int lobby_id, std::size_t line, std::size_t map_size)
Create an Enemy object from spec list load from config file.
Definition: SpawnEnemySystem.cpp:68
System::SpawnEnemySystem::SpawnEnemySystem
SpawnEnemySystem()
Construct a new Spawn Enemy System object.
Definition: SpawnEnemySystem.cpp:31