38 lines
767 B
C
38 lines
767 B
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "Core/GameObject.h"
|
||
|
|
#include "Core/Event.h"
|
||
|
|
#include <unordered_set>
|
||
|
|
|
||
|
|
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() {
|
||
|
|
SetSelectedEntity(INVALID_ENTITY);
|
||
|
|
}
|
||
|
|
|
||
|
|
bool IsSelected(EntityID id) const {
|
||
|
|
return m_selectedEntity == id;
|
||
|
|
}
|
||
|
|
|
||
|
|
Event<EntityID> OnSelectionChanged;
|
||
|
|
|
||
|
|
private:
|
||
|
|
SelectionManager() = default;
|
||
|
|
EntityID m_selectedEntity = INVALID_ENTITY;
|
||
|
|
};
|
||
|
|
|
||
|
|
}
|