- SelectionManager now implements ISelectionManager interface with uint64_t IDs - Remove SelectionManager/SceneManager circular dependency via EventBus - Add Scene::FindByID() for proper ID-based entity lookup - SceneManager::GetEntity() now uses FindByID instead of name-based Find - Fix editor CMakeLists.txt XCEngine.lib path - EventBus now thread-safe with shared_mutex
76 lines
2.7 KiB
C++
76 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <cstdint>
|
|
|
|
#include <XCEngine/Core/Event.h>
|
|
#include <XCEngine/Core/Math/Vector3.h>
|
|
#include <XCEngine/Core/Math/Quaternion.h>
|
|
#include <XCEngine/Components/GameObject.h>
|
|
#include <XCEngine/Scene/Scene.h>
|
|
|
|
#include "Core/ISceneManager.h"
|
|
|
|
namespace XCEngine {
|
|
namespace Editor {
|
|
|
|
class SceneManager : public ISceneManager {
|
|
public:
|
|
SceneManager();
|
|
|
|
::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->FindByID(id) : nullptr;
|
|
}
|
|
|
|
const ::XCEngine::Components::GameObject* GetEntity(::XCEngine::Components::GameObject::ID id) const {
|
|
return m_scene ? m_scene->FindByID(id) : nullptr;
|
|
}
|
|
|
|
const std::vector<::XCEngine::Components::GameObject*>& GetRootEntities() const {
|
|
return m_rootEntities;
|
|
}
|
|
|
|
void DeleteEntity(::XCEngine::Components::GameObject::ID id);
|
|
|
|
void RenameEntity(::XCEngine::Components::GameObject::ID id, const std::string& newName);
|
|
|
|
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<::XCEngine::Components::GameObject::ID> OnEntityCreated;
|
|
::XCEngine::Core::Event<::XCEngine::Components::GameObject::ID> OnEntityDeleted;
|
|
::XCEngine::Core::Event<::XCEngine::Components::GameObject::ID> OnEntityChanged;
|
|
::XCEngine::Core::Event<> OnSceneChanged;
|
|
|
|
private:
|
|
struct ClipboardData {
|
|
std::string name;
|
|
Math::Vector3 localPosition = Math::Vector3::Zero();
|
|
Math::Quaternion localRotation = Math::Quaternion::Identity();
|
|
Math::Vector3 localScale = Math::Vector3::One();
|
|
std::vector<ClipboardData> 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<::XCEngine::Components::GameObject*> m_rootEntities;
|
|
std::optional<ClipboardData> m_clipboard;
|
|
};
|
|
|
|
}
|
|
}
|