Khaotic Engine Reborn
Loading...
Searching...
No Matches
identity_component.h
1#pragma once
2#include "../component.h"
3#include <string>
4
5namespace ecs {
10 enum class ObjectType
11 {
12 Sphere,
13 Cube,
14 Terrain,
15 Unknown
16 };
17
19public:
23 IdentityComponent() : m_id(0), m_type(ObjectType::Unknown) {}
24 explicit IdentityComponent(int id) : m_id(id), m_type(ObjectType::Unknown) {}
25 IdentityComponent(int id, const std::string& name) : m_id(id), m_name(name), m_type(ObjectType::Unknown) {}
26 ~IdentityComponent() = default;
27
33 void Initialize() override {}
34 //void Update(float deltaTime) override {}
35
40 int GetId() const { return m_id; }
45 void SetId(int id) { m_id = id; }
46
51 const std::string& GetName() const { return m_name; }
56 void SetName(const std::string& name) { m_name = name; }
57
62 ObjectType GetType() const { return m_type; }
67 void SetType(ObjectType type) { m_type = type; }
68
74 static std::string ObjectTypeToString(ObjectType type) {
75 switch (type) {
76 case ObjectType::Cube: return "Cube";
77 case ObjectType::Sphere: return "Sphere";
78 case ObjectType::Terrain: return "Terrain";
79 default: return "Unknown";
80 }
81 }
82
88 static ObjectType StringToObjectType(const std::string& str) {
89 if (str == "Cube") return ObjectType::Cube;
90 if (str == "Sphere") return ObjectType::Sphere;
91 if (str == "Terrain") return ObjectType::Terrain;
92 return ObjectType::Unknown;
93 }
94
95private:
96 int m_id; // ID unique de l'objet
97 std::string m_name; // Nom de l'objet
98 ObjectType m_type; // Type de l'objet (Cube, Sphere, Terrain, etc.)
99};
100
101} // namespace ecs
static std::string ObjectTypeToString(ObjectType type)
const std::string & GetName() const
void SetType(ObjectType type)
static ObjectType StringToObjectType(const std::string &str)
void SetName(const std::string &name)
ObjectType GetType() const
Definition component.h:9