43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/Components/ComponentFactoryRegistry.h>
|
|
#include <XCEngine/Components/Component.h>
|
|
#include <XCEngine/Components/GameObject.h>
|
|
|
|
namespace XCEngine {
|
|
namespace Editor {
|
|
|
|
class IUndoManager;
|
|
|
|
class IComponentEditor {
|
|
public:
|
|
virtual ~IComponentEditor() = default;
|
|
|
|
virtual const char* GetComponentTypeName() const = 0;
|
|
virtual const char* GetDisplayName() const = 0;
|
|
virtual bool CanEdit(::XCEngine::Components::Component* component) const {
|
|
return component && component->GetName() == GetComponentTypeName();
|
|
}
|
|
virtual bool Render(::XCEngine::Components::Component* component, IUndoManager* undoManager) = 0;
|
|
|
|
virtual bool ShowInAddComponentMenu() const { return true; }
|
|
virtual bool CanAddTo(::XCEngine::Components::GameObject* gameObject) const { return false; }
|
|
virtual const char* GetAddDisabledReason(::XCEngine::Components::GameObject* gameObject) const {
|
|
(void)gameObject;
|
|
return nullptr;
|
|
}
|
|
virtual ::XCEngine::Components::Component* AddTo(::XCEngine::Components::GameObject* gameObject) const {
|
|
return gameObject
|
|
? ::XCEngine::Components::ComponentFactoryRegistry::Get().CreateComponent(gameObject, GetComponentTypeName())
|
|
: nullptr;
|
|
}
|
|
|
|
virtual bool CanRemove(::XCEngine::Components::Component* component) const {
|
|
(void)component;
|
|
return false;
|
|
}
|
|
};
|
|
|
|
} // namespace Editor
|
|
} // namespace XCEngine
|