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

Loading...
Searching...
No Matches
identity_component.h
#pragma once
#include "../component.h"
#include <string>
namespace ecs {
enum class ObjectType
{
Sphere,
Cube,
Terrain,
Unknown
};
class IdentityComponent : public Component {
public:
IdentityComponent() : m_id(0), m_type(ObjectType::Unknown) {}
explicit IdentityComponent(int id) : m_id(id), m_type(ObjectType::Unknown) {}
IdentityComponent(int id, const std::string& name) : m_id(id), m_name(name), m_type(ObjectType::Unknown) {}
~IdentityComponent() = default;
void Initialize() override {}
//void Update(float deltaTime) override {}
int GetId() const { return m_id; }
void SetId(int id) { m_id = id; }
const std::string& GetName() const { return m_name; }
void SetName(const std::string& name) { m_name = name; }
ObjectType GetType() const { return m_type; }
void SetType(ObjectType type) { m_type = type; }
static std::string ObjectTypeToString(ObjectType type) {
switch (type) {
case ObjectType::Cube: return "Cube";
case ObjectType::Sphere: return "Sphere";
case ObjectType::Terrain: return "Terrain";
default: return "Unknown";
}
}
static ObjectType StringToObjectType(const std::string& str) {
if (str == "Cube") return ObjectType::Cube;
if (str == "Sphere") return ObjectType::Sphere;
if (str == "Terrain") return ObjectType::Terrain;
return ObjectType::Unknown;
}
private:
int m_id; // ID unique de l'objet
std::string m_name; // Nom de l'objet
ObjectType m_type; // Type de l'objet (Cube, Sphere, Terrain, etc.)
};
} // namespace ecs
ecs::Component
Definition component.h:12
ecs::IdentityComponent
Definition identity_component.h:18
ecs::IdentityComponent::Initialize
void Initialize() override
Definition identity_component.h:33
ecs::IdentityComponent::IdentityComponent
IdentityComponent()
Definition identity_component.h:23
ecs::IdentityComponent::ObjectTypeToString
static std::string ObjectTypeToString(ObjectType type)
Definition identity_component.h:74
ecs::IdentityComponent::SetId
void SetId(int id)
Definition identity_component.h:45
ecs::IdentityComponent::GetName
const std::string & GetName() const
Definition identity_component.h:51
ecs::IdentityComponent::SetType
void SetType(ObjectType type)
Definition identity_component.h:67
ecs::IdentityComponent::StringToObjectType
static ObjectType StringToObjectType(const std::string &str)
Definition identity_component.h:88
ecs::IdentityComponent::SetName
void SetName(const std::string &name)
Definition identity_component.h:56
ecs::IdentityComponent::GetType
ObjectType GetType() const
Definition identity_component.h:62
ecs::IdentityComponent::GetId
int GetId() const
Definition identity_component.h:40
ecs
Definition component.h:9
ecs::ObjectType
ObjectType
Definition identity_component.h:11