feat(editor): unify component registration pipeline

This commit is contained in:
2026-03-26 02:24:11 +08:00
parent 1ef3048da1
commit d018a4c82c
17 changed files with 268 additions and 116 deletions

View File

@@ -0,0 +1,32 @@
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
namespace XCEngine {
namespace Components {
class Component;
class GameObject;
class ComponentFactoryRegistry {
public:
using CreateComponentFn = Component* (*)(GameObject* gameObject);
static ComponentFactoryRegistry& Get();
void RegisterFactory(const std::string& typeName, CreateComponentFn createFn);
Component* CreateComponent(GameObject* gameObject, const std::string& typeName) const;
bool IsRegistered(const std::string& typeName) const;
const std::vector<std::string>& GetRegisteredTypes() const;
private:
ComponentFactoryRegistry();
std::unordered_map<std::string, CreateComponentFn> m_factories;
std::vector<std::string> m_registrationOrder;
};
} // namespace Components
} // namespace XCEngine