R-Type
CollisionComponent.hpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2023
3 ** R-Type
4 ** File description:
5 ** CoLLisionComponent
6 */
7 
8 #ifndef COLLISIONCOMPONENT_HPP_
9 #define COLLISIONCOMPONENT_HPP_
10 #include "Registry.hpp"
11 #include <functional>
12 #include <vector>
13 
14 namespace GameEngine
15 {
17  {
19  std::vector<std::function<void(const std::size_t &entityId)>> actions;
20  std::size_t layer;
21  bool isActive = true;
22 
23  template <typename Function, class... Components>
24  void addAction(Registry &registry, const Function &function)
25  {
26  std::function<void(const std::size_t &entityId)> action = [function, &registry](
27  const std::size_t &entityId) {
28  function(entityId, registry.getComponent<Components>()...);
29  };
30  actions.push_back(action);
31  };
32  };
33 } // namespace GameEngine
34 
35 #endif /* !COLLISIONCOMPONENT_HPP_ */
Entity component system, handling entities, components and systems.
Definition: Registry.hpp:31
SparseArray< Component > & getComponent()
Getter to a speecific component's SparseArray.
Definition: Registry.hpp:61
Definition: AssetManager.hpp:15
Definition: CollisionComponent.hpp:17
std::size_t layer
Definition: CollisionComponent.hpp:20
std::vector< std::function< void(const std::size_t &entityId)> > actions
Definition: CollisionComponent.hpp:19
Rectf collider
Definition: CollisionComponent.hpp:18
void addAction(Registry &registry, const Function &function)
Definition: CollisionComponent.hpp:24
bool isActive
Definition: CollisionComponent.hpp:21