#pragma once // The editor's component-inspection layer. Operates ENTIRELY in engine handle space // (OEntity / PScene) - the entt::entity type never appears in this header or in any // function the editor calls. Every EnTT operation the inspector needs (does-this-entity- // have-T, read-T) is performed by the Entity/Scene methods (hasComponent / accessComponent // / getEntities), which is exactly the separation the engine wants: tooling works through // handles, the registry stays internal to the engine. #include "Actor/Actor.h" #include "Scene/Scene.h" #include #include #include namespace Seele { namespace Editor { // A single entry in the component catalog: how to recognize one component type on an // entity and how to render its fields as human-readable text (Unity-inspector style). // // Both callbacks take a PEntity (a non-owning handle view) - never a raw entt id. They use // the entity's own hasComponent() / accessComponent() so the inspector code reads // exactly the way game code attaches/reads components: in handle space. // // This is the type-erased bridge between "I have an OEntity handle" and "show me every // component attached to it". EnTT does not expose a generic "iterate all registered // component types" API, so the inspector keeps an explicit catalog of the types it knows // how to display. Adding a new engine component to the inspector is one entry in // ComponentRegistry.cpp - no changes to this header. struct ComponentEntry { // Display name shown as the section header in the inspector (e.g. "Transform"). std::string name; // True if the given entity currently has this component attached. std::function isAttached; // Render the component's fields as a multi-line string (Unity-style: "field: value" per // line). Returns "" when the entity does not have the component (the caller skips it). std::function describe; }; // The catalog of every component type the editor knows how to display. Populated exactly // once by initComponentRegistry() (called from the editor's main before the first frame). // The vector is process-global by design: component *types* are a fixed set, so the // catalog is built once and read-only afterwards. std::vector& componentCatalog(); // Build the catalog. Idempotent - safe to call more than once; it only (re)populates the // static vector, which every editor tool reads. Must be called before any inspector reads // the catalog (main.cpp does this before the render loop). void initComponentRegistry(); // One row in the entity list (the left pane). Built from the scene's roster of live // handles - the "ID of an entity" is shown via the handle's own getLabel() (formatted in // the engine, so no entt type leaks), and the component summary is the names of the // cataloged components the handle actually has. struct EntityInfo { // The non-owning handle the row refers to. The editor stores these to drive the // "selected entity" state across frames. Non-owning by design: the *scene* owns the // entity's existence (the roster) and the creator's O* owns the C++ object. PEntity entity; // A short, stable label for the row (e.g. "#3") - the "ID of an entity" the user asked // to display, produced by Entity::getLabel() so the entt type never reaches the editor. std::string label; // Human-readable summary of the attached components (e.g. "Transform, Mesh") for the // row's subtitle. std::string componentSummary; }; // Enumerate every live entity in the scene (as non-owning handles) with its label + a // component summary. Source of the left pane. Iterates the scene's roster (getEntities) - // the scene's single source of truth for "what entities exist" - so this is the // "OEntity you can query via the scene" the user asked for, with no entt id anywhere. std::vector enumerateEntities(const PScene& scene); // Describe one entity's components for the inspector pane: a vector of (componentName, // fieldText) pairs, one entry per attached, displayable component, in catalog order. The // caller (InspectorView) maps these to UI::Text rows and refreshes them in update(). struct ComponentDisplay { std::string name; std::string fieldText; }; std::vector describeEntityComponents(const PScene& scene, PEntity entity); } // namespace Editor } // namespace Seele