55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <QObject>
|
|
|
|
#include "app/Singleton.h"
|
|
|
|
#include "xml/tinyxml2.h"
|
|
|
|
class Entity;
|
|
class WorkSpace;
|
|
|
|
class EntitiesManager : public QObject, public Singleton<EntitiesManager> {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit EntitiesManager(QObject* parent = nullptr);
|
|
~EntitiesManager();
|
|
void OnDestory();
|
|
|
|
// Initialize entity factory
|
|
void Initialize();
|
|
|
|
bool Contains(const QString& name) const;
|
|
|
|
bool Parse(const tinyxml2::XMLElement* element, class WorkSpace* workspce);
|
|
|
|
// Legacy methods (for backward compatibility)
|
|
Entity* Create(const QString& name);
|
|
Entity* CreateMesh(const QString& mesh);
|
|
|
|
// New factory methods
|
|
Entity* CreateEntity(const QString& type, WorkSpace* workspace = nullptr);
|
|
Entity* CreateEntityWithComponents(const QString& type, const QString& mesh, bool useLabel, WorkSpace* workspace = nullptr);
|
|
|
|
// Get supported entity types
|
|
QStringList GetSupportedEntityTypes() const;
|
|
QString GetEntityDisplayName(const QString& type) const;
|
|
QString GetEntityDescription(const QString& type) const;
|
|
|
|
bool DeleteEntity(Entity* entity);
|
|
|
|
Entity* GetEntity(const QString& uuid);
|
|
|
|
Entity* Create(const tinyxml2::XMLElement* element, Entity* parent, WorkSpace* workspce);
|
|
|
|
protected:
|
|
void AddEntity(Entity* entity);
|
|
void RemoveEntity(Entity* entity);
|
|
|
|
private:
|
|
std::unordered_map<QString, Entity*> entities_;
|
|
bool initialized_{false};
|
|
}; |