Destroy an entity and ensure it no longer exists
This commit is contained in:
parent
1962e97cf9
commit
c9a4e27630
2 changed files with 16 additions and 1 deletions
|
@ -12,3 +12,12 @@ TEST_CASE("Create a single entity and verify its existence")
|
|||
auto e = w.make_entity();
|
||||
REQUIRE(w.is_alive(e));
|
||||
}
|
||||
|
||||
TEST_CASE("Destroy an entity and ensure it no longer exists in the world")
|
||||
{
|
||||
world w;
|
||||
|
||||
auto e = w.make_entity();
|
||||
w.destroy_entity(e);
|
||||
REQUIRE_FALSE(w.is_alive(e));
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace zecsy
|
|||
world &operator=(world &&) = default;
|
||||
|
||||
entity_id make_entity();
|
||||
void destroy_entity(entity_id e);
|
||||
bool is_alive(entity_id e) const;
|
||||
private:
|
||||
std::bitset<MAX_ZECSY_ENTITIES> entities_bitset;
|
||||
|
@ -38,6 +39,11 @@ namespace zecsy
|
|||
return id;
|
||||
}
|
||||
|
||||
inline void world::destroy_entity(entity_id e)
|
||||
{
|
||||
entities_bitset.reset(e);
|
||||
}
|
||||
|
||||
inline bool world::is_alive(entity_id e) const
|
||||
{
|
||||
return entities_bitset.test(e);
|
||||
|
|
Loading…
Reference in a new issue