Sdk/World: Fix entity kill and invalidation bug

This commit is contained in:
Jérôme Leclercq
2019-05-13 16:50:19 +02:00
parent 73c0dbbd30
commit b88c9b2cec
5 changed files with 57 additions and 15 deletions

View File

@@ -126,4 +126,37 @@ SCENARIO("World", "[NDK][WORLD]")
}
}
}
GIVEN("An empty world")
{
Ndk::World world(false);
WHEN("We create two entities")
{
Ndk::EntityHandle a = world.CreateEntity();
REQUIRE(a->GetId() == 0);
Ndk::EntityHandle b = world.CreateEntity();
REQUIRE(b->GetId() == 1);
b->OnEntityDestruction.Connect([a](Ndk::Entity*)
{
REQUIRE(a.IsValid());
a->Kill();
});
THEN("We kill the second entity which will kill the first one")
{
b->Kill();
world.Refresh();
AND_THEN("Both entities should be dead next refresh")
{
world.Refresh();
REQUIRE_FALSE(a.IsValid());
REQUIRE_FALSE(b.IsValid());
}
}
}
}
}