Files
CosmicEngine/src/Engine/Core/Entity/CEntity.hpp
T

83 lines
2.1 KiB
C++
Raw Normal View History

2026-02-13 19:15:05 +01:00
#ifndef CENTITY_HPP
#define CENTITY_HPP
#include <forward_list>
#include <memory>
#include "../Utils/CSerializable.hpp"
#include "../Systems/EntityComponentManager.hpp"
2026-02-13 19:15:05 +01:00
namespace CosmicCore
{
class CScene;
class CEntity : public CSerializable {
private:
/**
* @brief A pointer to the scene containing the entity.
*/
CScene* m_scene;
2026-02-13 19:15:05 +01:00
EntityComponentManager& m_registryReference;
2026-02-13 19:15:05 +01:00
EntityId m_handle;
public:
/**
* @brief CEntity's default constructor, disabled.
*/
CEntity() = delete;
CEntity(EntityComponentManager& registry, EntityId handle, CScene* scene);
2026-02-13 19:15:05 +01:00
CEntity(const CEntity& cop);
/**
* @brief CEntity's destructor.
*/
~CEntity(void) = default;
/**
* @brief Getter to the parent entity.
* @return a pointer to the parent entity m_parent. nullptr if there is not.
*/
CEntity getParent();
template<typename compType, typename... Args>
void addComponent(std::forward_list<Args...> args)
{
m_registryReference().emplace<compType>(m_handle, *this, args);
2026-02-13 19:15:05 +01:00
}
template<typename compType>
void addComponent()
{
m_registryReference().emplace<compType>(m_handle, *this);
2026-02-13 19:15:05 +01:00
}
EntityComponentManager& getRegistry(){return m_registryReference;};
2026-02-13 19:15:05 +01:00
/**
* @brief Getter to the entity's scene.
* @return The pointer m_scene.
*/
CScene* getScene();
2026-02-13 19:15:05 +01:00
/**
* @brief Setter of the scene.
* @param[in, out] e The scene in which the entity will be set.
*/
void setScene(CScene* s);
EntityId operator*(){
return m_handle;
}
//TODO GET COMPONENT VECTOR OF SPECIFIC TYPE ? si utile
2026-02-13 19:15:05 +01:00
nlohmann::json to_json();
};
}
#endif