forked from Dynamitos/Seele
Engine (headless construction, no display / no WSI):
- Graphics/Vulkan/Graphics.{h,cpp} + Graphics/Initializer.h: a 'headless' flag
skips surface/swapchain extension negotiation and the window path so a VkDevice
can be created with a driver present but no display.
- Scene/Scene.{h,cpp}: null-guards + PScene circular-include decoupling.
- Actor/Entity.{h,cpp}: hasComponent fix (handle-space component query).
Editor:
- Editor/Window/InspectorView.{h,cpp}: Unity-style entity/component inspector on a
fixed widget pool (no runtime tree mutation) driven by a UIPass in the render
graph; owns its UI::System via UI::OSystem.
- Editor/ComponentRegistry.{h,cpp}: type-erased component catalog (handle-space only,
no entt in the editor API) that drives the inspector's component pane.
- Editor/main.cpp: --headless / --dump-entities path (headless device + scene dump,
no window) and InspectorView wiring with a live PScene on the windowed path.
Compile-verified (-fsyntax-only, -std=c++23) across all touched TUs.
52 lines
2.5 KiB
C++
52 lines
2.5 KiB
C++
#pragma once
|
|
#include "MinimalEngine.h"
|
|
#include "Scene/Scene.h"
|
|
#include <entt/entt.hpp>
|
|
#include <string>
|
|
#include <sstream>
|
|
|
|
namespace Seele {
|
|
// An entity describes a part of a scene
|
|
// It is just a wrapper the ID of a registry
|
|
class Entity {
|
|
public:
|
|
Entity(PScene scene);
|
|
virtual ~Entity();
|
|
|
|
// True if this entity currently has the given component attached. Pure handle-space
|
|
// (no entt::entity crosses the boundary) - the building block the editor's component
|
|
// inspector uses to ask "what is attached to this OEntity?" without ever touching the
|
|
// registry directly. Uses the entt try_get idiom: it returns a pointer to the component
|
|
// storage the entity holds, or null if the component is not attached - so the check is
|
|
// null-safe (no assertion) and works for any displayable component type.
|
|
template <typename Component> bool hasComponent() const { return scene->registry.try_get<Component>(identifier) != nullptr; }
|
|
|
|
// The entt record this handle wraps. Exposed (not as the old raw `getId()`, but scoped
|
|
// and documented as internal) so the *scene* can keep its roster in lock-step with the
|
|
// registry during Entity ctor/dtor. The editor never calls this - it works entirely in
|
|
// handle space via hasComponent/accessComponent.
|
|
entt::entity getIdentifier() const { return identifier; }
|
|
|
|
// A short, stable, human-facing label for tooling (the inspector's row text). Formatted
|
|
// *inside* the engine so the editor never has to name the entt::entity type at all -
|
|
// it just asks "what should I display for this OEntity?" and gets a string. This is the
|
|
// "display the ID of an entity" requirement satisfied in pure handle space: the numeric
|
|
// id is rendered to text here and never leaks out as an entt type.
|
|
std::string getLabel() const {
|
|
std::ostringstream oss;
|
|
oss << "#" << static_cast<uint32>(identifier);
|
|
return oss.str();
|
|
}
|
|
|
|
template <typename Component, typename... Args> Component& attachComponent(Args&&... args) {
|
|
return scene->attachComponent<Component>(identifier, std::forward<Args>(args)...);
|
|
}
|
|
template <typename Component> Component& accessComponent() { return scene->accessComponent<Component>(identifier); }
|
|
template <typename Component> const Component& accessComponent() const { return scene->accessComponent<Component>(identifier); }
|
|
|
|
protected:
|
|
PScene scene;
|
|
entt::entity identifier;
|
|
};
|
|
DEFINE_REF(Entity)
|
|
} // namespace Seele
|