2026-03-20 17:08:06 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Core/GameObject.h"
|
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
2026-03-20 17:28:06 +08:00
|
|
|
#include <XCEngine/Core/Event.h>
|
|
|
|
|
|
2026-03-20 17:08:06 +08:00
|
|
|
namespace UI {
|
|
|
|
|
|
|
|
|
|
class SelectionManager {
|
|
|
|
|
public:
|
|
|
|
|
static SelectionManager& Get() {
|
|
|
|
|
static SelectionManager instance;
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EntityID GetSelectedEntity() const { return m_selectedEntity; }
|
|
|
|
|
|
|
|
|
|
void SetSelectedEntity(EntityID id) {
|
|
|
|
|
m_selectedEntity = id;
|
|
|
|
|
OnSelectionChanged.Invoke(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClearSelection() {
|
2026-03-20 17:28:06 +08:00
|
|
|
SetSelectedEntity(INVALID_ENTITY_ID);
|
2026-03-20 17:08:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IsSelected(EntityID id) const {
|
|
|
|
|
return m_selectedEntity == id;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 17:28:06 +08:00
|
|
|
XCEngine::Core::Event<EntityID> OnSelectionChanged;
|
2026-03-20 17:08:06 +08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
SelectionManager() = default;
|
2026-03-20 17:28:06 +08:00
|
|
|
EntityID m_selectedEntity = INVALID_ENTITY_ID;
|
2026-03-20 17:08:06 +08:00
|
|
|
};
|
|
|
|
|
|
2026-03-20 17:28:06 +08:00
|
|
|
}
|