2026-02-13 19:15:05 +01:00
|
|
|
#ifndef CENTITY_HPP
|
|
|
|
|
#define CENTITY_HPP
|
|
|
|
|
|
|
|
|
|
#include <forward_list>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include "../Utils/CSerializable.hpp"
|
2026-03-14 20:24:17 +01:00
|
|
|
#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.
|
|
|
|
|
*/
|
2026-03-14 20:24:17 +01:00
|
|
|
CScene* m_scene;
|
2026-02-13 19:15:05 +01:00
|
|
|
|
2026-03-14 20:24:17 +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;
|
|
|
|
|
|
2026-03-14 20:24:17 +01:00
|
|
|
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)
|
|
|
|
|
{
|
2026-03-14 20:24:17 +01:00
|
|
|
m_registryReference().emplace<compType>(m_handle, *this, args);
|
2026-02-13 19:15:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename compType>
|
|
|
|
|
void addComponent()
|
|
|
|
|
{
|
2026-03-14 20:24:17 +01:00
|
|
|
m_registryReference().emplace<compType>(m_handle, *this);
|
2026-02-13 19:15:05 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-14 20:24:17 +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.
|
|
|
|
|
*/
|
2026-03-14 20:24:17 +01:00
|
|
|
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.
|
|
|
|
|
*/
|
2026-03-14 20:24:17 +01:00
|
|
|
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
|