Skip to content

Commit

Permalink
feat(tesseratos): show entity generation in inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Feb 14, 2024
1 parent ffefd43 commit a89e497
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/tesseratos/src/tesseratos/entity_inspector/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ void tesseratos::entityInspectorPlugin(Cubos& cubos)
ImGui::Begin("Entity Inspector");
if (!ImGui::IsWindowCollapsed())
{
if (!entitySelector.selection.isNull() && world.isAlive(entitySelector.selection))
auto entity = entitySelector.selection;
if (!entity.isNull() && world.isAlive(entity))
{
ImGui::Text("Entity %d selected", entitySelector.selection.index);
ImGui::Text("Entity %d#%d selected", entity.index, entity.generation);
ImGui::Separator();

if (ImGui::Button("Add Component"))
Expand All @@ -53,7 +54,7 @@ void tesseratos::entityInspectorPlugin(Cubos& cubos)
if (ImGui::Button(name.c_str()))
{
auto value = AnyValue::defaultConstruct(*type);
world.components(entitySelector.selection).add(value.type(), value.get());
world.components(entity).add(value.type(), value.get());
ImGui::CloseCurrentPopup();
}
}
Expand All @@ -62,7 +63,7 @@ void tesseratos::entityInspectorPlugin(Cubos& cubos)
}

const Type* removed = nullptr;
for (auto [type, value] : world.components(entitySelector.selection))
for (auto [type, value] : world.components(entity))
{
ImGui::SeparatorText(type->name().c_str());
dataInspector.edit(*type, value);
Expand All @@ -74,7 +75,7 @@ void tesseratos::entityInspectorPlugin(Cubos& cubos)

if (removed != nullptr)
{
world.components(entitySelector.selection).remove(*removed);
world.components(entity).remove(*removed);
}
}
else
Expand Down

0 comments on commit a89e497

Please sign in to comment.