Radium Engine  1.5.0
System.hpp
1 #pragma once
2 
3 #include <Engine/RaEngine.hpp>
4 
5 #include <memory>
6 #include <vector>
7 
8 namespace Ra {
9 namespace Core {
10 class TaskQueue;
11 namespace Asset {
12 class FileData;
13 }
14 } // namespace Core
15 
16 namespace Engine {
17 struct FrameInfo;
18 
19 namespace Scene {
20 
21 class Component;
22 class Entity;
23 
30 class RA_ENGINE_API System
31 {
32  friend class Component;
33 
34  public:
35  System() = default;
36  virtual ~System() = default;
37 
46  virtual void handleAssetLoading( Entity* entity, const Core::Asset::FileData* data ) {
47  CORE_UNUSED( entity );
48  CORE_UNUSED( data );
49  }
50 
58  virtual void generateTasks( Core::TaskQueue* taskQueue,
59  const Engine::FrameInfo& frameInfo ) = 0;
60 
66  std::vector<Component*> getEntityComponents( const Entity* entity );
67 
73  void addComponent( Entity* entity, Component* component ) {
74  registerComponent( entity, component );
75  }
76 
77  protected:
84  virtual void registerComponent( const Entity* entity, Component* component );
85 
92  virtual void unregisterComponent( const Entity* entity, Component* component );
93 
99  virtual void unregisterAllComponents( const Entity* entity );
100 
101  protected:
103  std::vector<std::pair<const Entity*, Component*>> m_components;
104 };
105 
106 } // namespace Scene
107 } // namespace Engine
108 } // namespace Ra
A component is an element that can be updated by a system. It is also linked to some other components...
Definition: Component.hpp:31
An entity is an scene element. It ties together components with a transform.
Definition: Entity.hpp:23
std::vector< std::pair< const Entity *, Component * > > m_components
List of active components.
Definition: System.hpp:103
virtual void handleAssetLoading(Entity *entity, const Core::Asset::FileData *data)
Definition: System.hpp:46
virtual void generateTasks(Core::TaskQueue *taskQueue, const Engine::FrameInfo &frameInfo)=0
Pure virtual method to be overridden by any system. Must register in taskQueue the operations that mu...
void addComponent(Entity *entity, Component *component)
Definition: System.hpp:73
Definition: Cage.cpp:3
Structure passed to each system before they fill the task queue.
Definition: FrameInfo.hpp:8