Reserve entity #0
This commit is contained in:
parent
c9a4e27630
commit
c77948c441
2 changed files with 13 additions and 5 deletions
|
@ -10,6 +10,7 @@ TEST_CASE("Create a single entity and verify its existence")
|
||||||
world w;
|
world w;
|
||||||
|
|
||||||
auto e = w.make_entity();
|
auto e = w.make_entity();
|
||||||
|
|
||||||
REQUIRE(w.is_alive(e));
|
REQUIRE(w.is_alive(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,5 +20,15 @@ TEST_CASE("Destroy an entity and ensure it no longer exists in the world")
|
||||||
|
|
||||||
auto e = w.make_entity();
|
auto e = w.make_entity();
|
||||||
w.destroy_entity(e);
|
w.destroy_entity(e);
|
||||||
|
|
||||||
REQUIRE_FALSE(w.is_alive(e));
|
REQUIRE_FALSE(w.is_alive(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Entity #0 should be reserved and never used")
|
||||||
|
{
|
||||||
|
world w;
|
||||||
|
|
||||||
|
auto e = w.make_entity();
|
||||||
|
|
||||||
|
REQUIRE(e != 0);
|
||||||
|
}
|
||||||
|
|
|
@ -31,11 +31,8 @@ namespace zecsy
|
||||||
|
|
||||||
inline entity_id world::make_entity()
|
inline entity_id world::make_entity()
|
||||||
{
|
{
|
||||||
auto id = entity_counter;
|
auto id = ++entity_counter;
|
||||||
entities_bitset.set(id);
|
entities_bitset.set(id);
|
||||||
|
|
||||||
entity_counter++;
|
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue