# Khaotic Engine Reborn: enginecustom/src/inc/system/ecs/component.h Source File

Loading...
Searching...
No Matches
component.h
#pragma once
#include <memory>
#include <typeindex>
#include <typeinfo>
namespace ecs {
// Classe de base pour tous les composants
class Component {
public:
Component() = default;
virtual ~Component() = default;
// Empêcher la copie
Component(const Component&) = delete;
Component& operator=(const Component&) = delete;
// Permettre le déplacement
Component(Component&&) = default;
Component& operator=(Component&&) = default;
virtual void Initialize() {}
virtual void Update(float deltaTime) {}
// virtual std::string Serialize() {}
// virtual void Deserialize(const std::string& data) {}
};
using ComponentPtr = std::shared_ptr<Component>;
using ComponentTypeID = std::type_index;
template<typename T>
ComponentTypeID GetComponentTypeID() {
static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
return std::type_index(typeid(T));
}
} // namespace ecs
ecs::Component
Definition component.h:12
ecs::Component::Update
virtual void Update(float deltaTime)
Definition component.h:34
ecs::Component::Initialize
virtual void Initialize()
Definition component.h:28
ecs
Definition component.h:9
ecs::ComponentPtr
std::shared_ptr< Component > ComponentPtr
Definition component.h:43
ecs::ComponentTypeID
std::type_index ComponentTypeID
Definition component.h:48
ecs::GetComponentTypeID
ComponentTypeID GetComponentTypeID()
Definition component.h:54