We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
__bool__
1 parent 42c4331 commit 654ed03Copy full SHA for 654ed03
2 files changed
CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
8
## [Unreleased]
9
10
+### Changed
11
+
12
+- Queries are now truthy if they match any entity.
13
14
## [5.1.0] - 2024-02-13
15
16
### Changed
tcod/ecs/query.py
@@ -352,6 +352,10 @@ def get_entities(self) -> AbstractSet[Entity]:
352
"""
353
return _get_query(self.registry, self._query)
354
355
+ def __bool__(self) -> bool:
356
+ """Return True if any entity matches this query."""
357
+ return bool(self.get_entities())
358
359
@staticmethod
360
def __as_queries(
361
components: Iterable[ComponentKey[object]] = (),
0 commit comments