#ifndef HYDRAECS #define HYDRAECS #include "../engine/HydraObject.h" #include "HydraComponentManager.h" #include "HydraEntityManager.h" #include "HydraSystemManager.h" #include class HydraECS : HydraObject { private: std::unique_ptr m_entity_manager; std::unique_ptr m_component_manager; std::unique_ptr m_system_manager; public: void Init(); void Shutdown(); HydraID CreateEntity() { return m_entity_manager->CreateEntity(); } void DestroyEntity(HydraID entity_id) { m_entity_manager->DeleteEntity(entity_id); m_component_manager->EntityDeleted(entity_id); m_system_manager->EntityDeleted(entity_id); } template void RegisterComponentType() { m_component_manager->RegisterComponentType(); } template HydraID GetComponentType() { return m_component_manager->GetComponentTypeID(); } template void AddComponent(HydraID entity_id, T component) { // Add teh component to the entity m_component_manager->AddComponent(entity_id, component); // Get the current entity signature and update it to include // the new component auto signature = m_entity_manager->GetSignature(entity_id); signature.set(m_component_manager->GetComponentTypeID(), true); m_entity_manager->SetSignature(entity_id, signature); // Tell the sytem manager that the entities signature has changed m_system_manager->EntitySignatureChanged(entity_id, signature); } template void RemoveComponent(HydraID entity_id) { // Remove the component from the entity m_component_manager->RemoveComponent(entity_id); // Get the current signature, remove the component from it and update auto signature = m_entity_manager->GetSignature(entity_id); signature.set(m_component_manager->GetComponentTypeID(), false); m_entity_manager->SetSignature(entity_id, signature); // Tell the system manager that the entitys signature has changed m_system_manager->EntitySignatureChanged(entity_id, signature); } template bool HasComponent(HydraID entity_id) { return m_component_manager->HasComponent(entity_id); } template T &GetComponent(HydraID entity_id) { return m_component_manager->GetComponent(entity_id); } template std::shared_ptr RegisterSystem() { return m_system_manager->RegisterSystem(); } template void SetSystemSignature(HydraSignature signature) { m_system_manager->SetSignature(signature); } template std::shared_ptr GetSystem() { return m_system_manager->GetSystem(); } void InitialiseComponents() { m_system_manager->InitialiseComponents(); } }; #endif /* HYDRAECS */