editor icon is removed if a component is removed while entity is being removed
This commit is contained in:
parent
9a7dbdd285
commit
8456c274e1
3 changed files with 14 additions and 3 deletions
|
@ -961,7 +961,7 @@ void EditorServer::onEvent(Event& evt)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(e.component.entity.getComponents().empty())
|
||||
if(e.component.entity.existsInUniverse() && e.component.entity.getComponents().empty())
|
||||
{
|
||||
EditorIcon* er = new EditorIcon();
|
||||
er->create(e.component.entity, Component::INVALID);
|
||||
|
|
|
@ -47,6 +47,17 @@ Universe::Universe()
|
|||
}
|
||||
|
||||
|
||||
bool Entity::existsInUniverse() const
|
||||
{
|
||||
for(int i = 0; i < universe->m_free_slots.size(); ++i)
|
||||
{
|
||||
if(universe->m_free_slots[i] == index)
|
||||
return false;
|
||||
}
|
||||
return index != -1;
|
||||
}
|
||||
|
||||
|
||||
const Quat& Entity::getRotation() const
|
||||
{
|
||||
return universe->m_rotations[index];
|
||||
|
@ -180,9 +191,9 @@ void Universe::destroyEntity(Entity entity)
|
|||
{
|
||||
if(entity.isValid())
|
||||
{
|
||||
m_free_slots.push_back(entity.index);
|
||||
m_event_manager->emitEvent(EntityDestroyedEvent(entity));
|
||||
m_component_list[entity.index].clear();
|
||||
m_free_slots.push_back(entity.index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ struct LUX_ENGINE_API Entity LUX_FINAL
|
|||
bool isValid() const { return index >= 0; }
|
||||
const Component& getComponent(unsigned int type);
|
||||
const ComponentList& getComponents() const;
|
||||
|
||||
bool existsInUniverse() const;
|
||||
|
||||
bool operator ==(const Entity& rhs) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue