#pragma once #include #include #include #include #include #include #include namespace UI { class EditorSceneManager { public: static EditorSceneManager& Get() { static EditorSceneManager instance; return instance; } XCEngine::Components::GameObject* CreateEntity(const std::string& name, XCEngine::Components::GameObject* parent = nullptr); XCEngine::Components::GameObject* GetEntity(XCEngine::Components::GameObject::ID id) { return m_scene ? m_scene->Find(std::to_string(id)) : nullptr; } const XCEngine::Components::GameObject* GetEntity(XCEngine::Components::GameObject::ID id) const { return m_scene ? m_scene->Find(std::to_string(id)) : nullptr; } const std::vector& GetRootEntities() const { return m_rootEntities; } void DeleteEntity(XCEngine::Components::GameObject::ID id); void RenameEntity(XCEngine::Components::GameObject::ID id, const std::string& newName) { if (auto* entity = GetEntity(id)) { entity->SetName(newName); OnEntityChanged.Invoke(id); } } void CopyEntity(XCEngine::Components::GameObject::ID id); XCEngine::Components::GameObject::ID PasteEntity(XCEngine::Components::GameObject::ID parent = 0); XCEngine::Components::GameObject::ID DuplicateEntity(XCEngine::Components::GameObject::ID id); void MoveEntity(XCEngine::Components::GameObject::ID id, XCEngine::Components::GameObject::ID newParent); void CreateDemoScene(); bool HasClipboardData() const { return m_clipboard.has_value(); } XCEngine::Core::Event OnEntityCreated; XCEngine::Core::Event OnEntityDeleted; XCEngine::Core::Event OnEntityChanged; XCEngine::Core::Event<> OnSceneChanged; private: EditorSceneManager() = default; struct ClipboardData { std::string name; std::vector> components; std::vector children; }; ClipboardData CopyEntityRecursive(const XCEngine::Components::GameObject* entity); XCEngine::Components::GameObject::ID PasteEntityRecursive(const ClipboardData& data, XCEngine::Components::GameObject::ID parent); XCEngine::Components::Scene* m_scene = nullptr; std::vector m_rootEntities; std::optional m_clipboard; }; }