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

91 lines
2.4 KiB
C++

#ifndef CENTITY_HPP
#define CENTITY_HPP
#include <forward_list>
#include <functional>
#include "../../Utils/JsonParser/CSerializable.hpp"
#include "EntityComponentManager.hpp"
namespace CosmicCore
{
class CScene;
class CEntity : public CSerializable {
private:
/**
* @brief A pointer to the scene containing the entity.
*/
CScene* m_scene;
std::reference_wrapper<EntityComponentManager> m_registryReference;
EntityId m_handle;
public:
/**
* @brief CEntity's default constructor, disabled.
*/
CEntity() = delete;
CEntity(std::reference_wrapper<EntityComponentManager> registry, EntityId handle, CScene* scene);
CEntity(const CEntity& cop);
CEntity& operator=(const CEntity& ent);
/**
* @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);
}
template<typename compType>
void addComponent()
{
m_registryReference().emplace<compType>(m_handle, *this);
}
EntityComponentManager& getRegistry(){return m_registryReference;};
const EntityComponentManager& getRegistry() const {return m_registryReference;};
EntityId getHandle(){return m_handle;};
/**
* @brief Getter to the entity's scene.
* @return The pointer m_scene.
*/
CScene* getScene();
/**
* @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;
}
const EntityId operator*() const {
return m_handle;
}
//TODO GET COMPONENT VECTOR OF SPECIFIC TYPE ? si utile
nlohmann::json to_json();
};
}
#endif