Improvements on the bool conversion of entities (09.06 22:40)
@@ -142,6 +142,14 @@ public:
return m_id;
}
+ bool operator==(const id& other) const {
+ return m_id == other.m_id;
+ }
+
+ bool operator!=(const id& other) const {
+ return !(*this == other);
+ }
+
/* World is optional, but guarantees that entity identifiers extracted from
* the id are valid */
flecs::world_t *m_world;
@@ -207,15 +215,19 @@ public:
*
* @return True if the entity is alive, false otherwise.
*/
- bool is_valid() {
+ bool is_valid() const {
return m_world && ecs_is_valid(m_world, m_id);
}
+ explicit operator bool() const {
+ return is_valid();
+ }
+
/** Check is entity is alive.
*
* @return True if the entity is alive, false otherwise.
*/
- bool is_alive() {
+ bool is_alive() const {
return m_world && ecs_is_alive(m_world, m_id);
}
