Editor entity create and delete.

This commit is contained in:
2016-01-18 19:26:00 +01:00
parent 631dd57eeb
commit d4242bbead
5 changed files with 49 additions and 14 deletions
+14
View File
@@ -23,6 +23,8 @@ EditorSystem::EditorSystem(EventBroker* eventBroker, IRenderer* renderer, Render
m_EditorGUI->SetEntitySelectedCallback(std::bind(&EditorSystem::OnEntitySelected, this, std::placeholders::_1));
m_EditorGUI->SetEntityImportCallback(std::bind(&EditorSystem::importEntity, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetEntitySaveCallback(std::bind(&EditorSystem::OnEntitySave, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetEntityCreateCallback(std::bind(&EditorSystem::OnEntityCreate, this, std::placeholders::_1));
m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1));
m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2));
@@ -65,6 +67,18 @@ void EditorSystem::OnEntitySave(EntityWrapper entity, boost::filesystem::path fi
writer.WriteEntity(entity.World, entity.ID);
}
EntityWrapper EditorSystem::OnEntityCreate(EntityWrapper parent)
{
EntityID entity = parent.World->CreateEntity(parent.ID);
parent.World->AttachComponent(entity, "Transform");
return EntityWrapper(parent.World, entity);
}
void EditorSystem::OnEntityDelete(EntityWrapper entity)
{
entity.World->DeleteEntity(entity.ID);
}
void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType)
{
entity.World->AttachComponent(entity.ID, componentType);