Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
EntityInspectorManager.h
Go to the documentation of this file.
1/*
2 * Olympe Blueprint Editor - Entity Inspector Manager
3 *
4 * Tracks runtime entities and provides inspection/editing capabilities
5 * Synchronizes with World ECS to provide real-time entity access
6 */
7
8#pragma once
9
10#include "../ECS_Entity.h"
11#include "../ECS_Components.h"
12#include <vector>
13#include <string>
14#include <map>
15#include <functional>
16
17namespace Olympe
18{
19 // Entity metadata for inspector
21 {
23 std::string name;
24 bool isActive = true;
25 std::vector<std::string> componentTypes;
26
27 EntityInfo() = default;
28 EntityInfo(EntityID entityId) : id(entityId) {}
29 };
30
31 // Component property metadata
33 {
34 std::string name;
35 std::string type; // "float", "int", "bool", "string", "vec2", "vec3"
36 std::string value; // String representation of current value
37 void* dataPtr = nullptr; // Pointer to actual data (for editing)
38
40 ComponentPropertyInfo(const std::string& n, const std::string& t)
41 : name(n), type(t) {}
42 };
43
44 /**
45 * EntityInspectorManager - Manages runtime entity tracking and inspection
46 * Singleton that maintains a synchronized list of all entities in the world
47 */
49 {
50 public:
52 static EntityInspectorManager& Get() { return Instance(); }
53
54 // Lifecycle
55 void Initialize();
56 void Shutdown();
57 void Update(); // Called each frame to sync with World
58
59 // Entity notifications (called by World hooks)
60 void OnEntityCreated(EntityID entity);
61 void OnEntityDestroyed(EntityID entity);
62 void OnComponentAdded(EntityID entity, const std::string& componentType);
63 void OnComponentRemoved(EntityID entity, const std::string& componentType);
64
65 // Entity queries
66 std::vector<EntityID> GetAllEntities() const;
67 std::vector<EntityInfo> GetAllEntityInfo() const;
68 EntityInfo GetEntityInfo(EntityID entity) const;
69 bool IsEntityValid(EntityID entity) const;
70
71 // Component queries
72 std::vector<std::string> GetEntityComponents(EntityID entity) const;
73 bool HasComponent(EntityID entity, const std::string& componentType) const;
74
75 // Property queries and editing
76 std::vector<ComponentPropertyInfo> GetComponentProperties(EntityID entity, const std::string& componentType);
77 bool SetComponentProperty(EntityID entity, const std::string& componentType, const std::string& propertyName, const std::string& value);
78
79 // Filtering
80 std::vector<EntityID> FilterByName(const std::string& nameFilter) const;
81 std::vector<EntityID> FilterByComponent(const std::string& componentType) const;
82
83 // Selection
84 void SetSelectedEntity(EntityID entity);
87
88 // State
89 bool IsInitialized() const { return m_Initialized; }
90 size_t GetEntityCount() const { return m_EntityList.size(); }
91
92 // Force manual sync (for initial load or error recovery)
93 void ForceSyncWithWorld();
94
95 private:
98
101
102 // Sync with World ECS
103 void SyncWithWorld();
104
105 // Component name extraction helpers
106 std::string GetComponentName(ComponentTypeID typeId) const;
107 ComponentTypeID GetComponentTypeId(const std::string& name) const;
108
109 private:
110 bool m_Initialized = false;
112 std::vector<EntityID> m_EntityList;
113 std::map<EntityID, EntityInfo> m_EntityInfoCache;
114 };
115}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::uint64_t EntityID
Definition ECS_Entity.h:21
std::uint64_t ComponentTypeID
Definition ECS_Entity.h:27
const EntityID INVALID_ENTITY_ID
Definition ECS_Entity.h:23
EntityInspectorManager - Manages runtime entity tracking and inspection Singleton that maintains a sy...
std::vector< EntityID > GetAllEntities() const
std::vector< std::string > GetEntityComponents(EntityID entity) const
ComponentTypeID GetComponentTypeId(const std::string &name) const
static EntityInspectorManager & Instance()
static EntityInspectorManager & Get()
EntityInspectorManager(const EntityInspectorManager &)=delete
void OnComponentAdded(EntityID entity, const std::string &componentType)
EntityInfo GetEntityInfo(EntityID entity) const
std::vector< ComponentPropertyInfo > GetComponentProperties(EntityID entity, const std::string &componentType)
EntityInspectorManager & operator=(const EntityInspectorManager &)=delete
std::map< EntityID, EntityInfo > m_EntityInfoCache
bool HasComponent(EntityID entity, const std::string &componentType) const
bool SetComponentProperty(EntityID entity, const std::string &componentType, const std::string &propertyName, const std::string &value)
void OnComponentRemoved(EntityID entity, const std::string &componentType)
std::vector< EntityID > FilterByName(const std::string &nameFilter) const
std::string GetComponentName(ComponentTypeID typeId) const
bool IsEntityValid(EntityID entity) const
std::vector< EntityID > FilterByComponent(const std::string &componentType) const
std::vector< EntityInfo > GetAllEntityInfo() const
ComponentPropertyInfo(const std::string &n, const std::string &t)
EntityInfo(EntityID entityId)
std::vector< std::string > componentTypes
EntityInfo()=default