tcod-ecs 5.2.3__tar.gz → 5.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/LICENSE +1 -1
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/PKG-INFO +4 -3
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/README.md +1 -1
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/pyproject.toml +8 -2
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/_version.py +9 -4
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/entity.py +9 -9
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/query.py +25 -1
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/typing.py +1 -1
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/__init__.py +0 -0
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/_converter.py +0 -0
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/callbacks.py +0 -0
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/constants.py +0 -0
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/py.typed +0 -0
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/registry.py +0 -0
- {tcod_ecs-5.2.3 → tcod_ecs-5.3.0}/tcod/ecs/world.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: tcod-ecs
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.3.0
|
|
4
4
|
Summary: A type-hinted Entity Component System based on Python dictionaries and sets.
|
|
5
5
|
Author-email: Kyle Benesch <4b796c65+github@gmail.com>
|
|
6
6
|
Requires-Python: >=3.8
|
|
@@ -12,6 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
14
|
Classifier: Typing :: Typed
|
|
15
|
+
License-File: LICENSE
|
|
15
16
|
Requires-Dist: attrs >=23.1.0
|
|
16
17
|
Requires-Dist: cattrs >=23.1.2
|
|
17
18
|
Requires-Dist: sentinel-value >=1.0.0
|
|
@@ -76,7 +77,7 @@ The ECS Registry is used to create and store entities and their components.
|
|
|
76
77
|
## Entity
|
|
77
78
|
|
|
78
79
|
Each Entity is identified by its unique id (`uid`) which can be any hashable object combined with the `registry` it belongs.
|
|
79
|
-
New unique entities can be created with `Registry.new_entity` which uses a new `object()` as the `uid`, this guarantees uniqueness which is not always
|
|
80
|
+
New unique entities can be created with `Registry.new_entity` which uses a new `object()` as the `uid`, this guarantees uniqueness which is not always desirable.
|
|
80
81
|
An entity always knows about its assigned registry, which can be accessed with the `Entity.registry` property from any Entity instance.
|
|
81
82
|
Registries only know about their entities once the entity is assigned a name, component, tag, or relation.
|
|
82
83
|
|
|
@@ -47,7 +47,7 @@ The ECS Registry is used to create and store entities and their components.
|
|
|
47
47
|
## Entity
|
|
48
48
|
|
|
49
49
|
Each Entity is identified by its unique id (`uid`) which can be any hashable object combined with the `registry` it belongs.
|
|
50
|
-
New unique entities can be created with `Registry.new_entity` which uses a new `object()` as the `uid`, this guarantees uniqueness which is not always
|
|
50
|
+
New unique entities can be created with `Registry.new_entity` which uses a new `object()` as the `uid`, this guarantees uniqueness which is not always desirable.
|
|
51
51
|
An entity always knows about its assigned registry, which can be accessed with the `Entity.registry` property from any Entity instance.
|
|
52
52
|
Registries only know about their entities once the entity is assigned a name, component, tag, or relation.
|
|
53
53
|
|
|
@@ -66,6 +66,14 @@ warn_return_any = true
|
|
|
66
66
|
no_implicit_reexport = true
|
|
67
67
|
strict_equality = true
|
|
68
68
|
|
|
69
|
+
[tool.pyright]
|
|
70
|
+
reportInconsistentOverload = false
|
|
71
|
+
reportIncompatibleMethodOverride = false
|
|
72
|
+
reportAssignmentType = false
|
|
73
|
+
reportCallIssue = false
|
|
74
|
+
reportInvalidTypeVarUse = false
|
|
75
|
+
reportArgumentType = false
|
|
76
|
+
|
|
69
77
|
[tool.pytest.ini_options]
|
|
70
78
|
minversion = "6.0"
|
|
71
79
|
required_plugins = ["pytest-cov>=4.0.0", "pytest-benchmark>=4.0.0"]
|
|
@@ -81,8 +89,6 @@ line-length = 120
|
|
|
81
89
|
[tool.ruff.lint] # https://docs.astral.sh/ruff/rules/
|
|
82
90
|
select = ["ALL"]
|
|
83
91
|
ignore = [
|
|
84
|
-
"ANN101", # missing-type-self
|
|
85
|
-
"ANN102", # missing-type-cls
|
|
86
92
|
"COM", # flake8-commas, handled by formatter
|
|
87
93
|
"E501", # line-too-long
|
|
88
94
|
"S101", # assert
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
# file generated by
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
3
6
|
TYPE_CHECKING = False
|
|
4
7
|
if TYPE_CHECKING:
|
|
5
|
-
from typing import Tuple
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
6
11
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
7
12
|
else:
|
|
8
13
|
VERSION_TUPLE = object
|
|
@@ -12,5 +17,5 @@ __version__: str
|
|
|
12
17
|
__version_tuple__: VERSION_TUPLE
|
|
13
18
|
version_tuple: VERSION_TUPLE
|
|
14
19
|
|
|
15
|
-
__version__ = version = '5.
|
|
16
|
-
__version_tuple__ = version_tuple = (5,
|
|
20
|
+
__version__ = version = '5.3.0'
|
|
21
|
+
__version_tuple__ = version_tuple = (5, 3, 0)
|
|
@@ -66,7 +66,7 @@ class Entity:
|
|
|
66
66
|
>>> other_entity = registry["other"]
|
|
67
67
|
""" # Changes here should be reflected in conftest.py
|
|
68
68
|
|
|
69
|
-
__slots__ = ("
|
|
69
|
+
__slots__ = ("__weakref__", "registry", "uid")
|
|
70
70
|
|
|
71
71
|
registry: Final[Registry] # type:ignore[misc] # https://github.com/python/mypy/issues/5774
|
|
72
72
|
"""The :any:`Registry` this entity belongs to."""
|
|
@@ -77,7 +77,7 @@ class Entity:
|
|
|
77
77
|
def world(self) -> Registry:
|
|
78
78
|
"""Deprecated alias for registry.
|
|
79
79
|
|
|
80
|
-
.. deprecated::
|
|
80
|
+
.. deprecated:: 5.1
|
|
81
81
|
Use :any:`registry` instead.
|
|
82
82
|
"""
|
|
83
83
|
if __debug__:
|
|
@@ -126,10 +126,10 @@ class Entity:
|
|
|
126
126
|
|
|
127
127
|
.. versionadded:: 4.2.0
|
|
128
128
|
"""
|
|
129
|
-
self.components.clear()
|
|
130
|
-
self.tags.clear()
|
|
131
|
-
self.relation_tags_many.clear()
|
|
132
|
-
self.relation_components.clear()
|
|
129
|
+
self.components(traverse=()).clear()
|
|
130
|
+
self.tags(traverse=()).clear()
|
|
131
|
+
self.relation_tags_many(traverse=()).clear()
|
|
132
|
+
self.relation_components(traverse=()).clear()
|
|
133
133
|
|
|
134
134
|
def instantiate(self) -> Self:
|
|
135
135
|
"""Return a new entity which inherits the components, tags, and relations of this entity.
|
|
@@ -394,7 +394,7 @@ def _traverse_entities(start: Entity, traverse_parents: tuple[object, ...]) -> I
|
|
|
394
394
|
|
|
395
395
|
|
|
396
396
|
@attrs.define(eq=False, frozen=True, weakref_slot=False)
|
|
397
|
-
class EntityComponents(MutableMapping[Union[Type[Any], Tuple[object, Type[Any]]],
|
|
397
|
+
class EntityComponents(MutableMapping[Union[Type[Any], Tuple[object, Type[Any]]], object]):
|
|
398
398
|
"""A proxy attribute to access an entities components like a dictionary.
|
|
399
399
|
|
|
400
400
|
See :any:`Entity.components`.
|
|
@@ -552,7 +552,7 @@ class EntityComponents(MutableMapping[Union[Type[Any], Tuple[object, Type[Any]]]
|
|
|
552
552
|
except KeyError:
|
|
553
553
|
return default # type: ignore[return-value] # https://github.com/python/mypy/issues/3737
|
|
554
554
|
|
|
555
|
-
def setdefault(self, __key: ComponentKey[T], __default: T) -> T:
|
|
555
|
+
def setdefault(self, __key: ComponentKey[T], __default: T, /) -> T:
|
|
556
556
|
"""Assign a default value if a component is missing, then returns the current value."""
|
|
557
557
|
try:
|
|
558
558
|
return self[__key]
|
|
@@ -1040,7 +1040,7 @@ class EntityComponentRelations(MutableMapping[ComponentKey[Any], EntityComponent
|
|
|
1040
1040
|
"""Access relations for this component key as a `{target: component}` dict-like object."""
|
|
1041
1041
|
return EntityComponentRelationMapping(self.entity, key, self.traverse)
|
|
1042
1042
|
|
|
1043
|
-
def __setitem__(self, __key: ComponentKey[T], __values: Mapping[Entity, object]) -> None:
|
|
1043
|
+
def __setitem__(self, __key: ComponentKey[T], __values: Mapping[Entity, object], /) -> None:
|
|
1044
1044
|
"""Redefine the component relations for this entity.
|
|
1045
1045
|
|
|
1046
1046
|
..versionadded:: 4.2.0
|
|
@@ -336,7 +336,7 @@ class BoundQuery:
|
|
|
336
336
|
def world(self) -> Registry:
|
|
337
337
|
"""Deprecated alias for registry.
|
|
338
338
|
|
|
339
|
-
.. deprecated::
|
|
339
|
+
.. deprecated:: 5.1
|
|
340
340
|
Use :any:`registry` instead.
|
|
341
341
|
"""
|
|
342
342
|
if __debug__:
|
|
@@ -404,6 +404,30 @@ class BoundQuery:
|
|
|
404
404
|
& self._query,
|
|
405
405
|
)
|
|
406
406
|
|
|
407
|
+
def any_of(
|
|
408
|
+
self,
|
|
409
|
+
components: Iterable[ComponentKey[object]] = (),
|
|
410
|
+
*,
|
|
411
|
+
tags: Iterable[object] = (),
|
|
412
|
+
relations: Iterable[_RelationQuery] = (),
|
|
413
|
+
traverse: Iterable[object] = (IsA,),
|
|
414
|
+
depth: int | None = None,
|
|
415
|
+
) -> Self:
|
|
416
|
+
"""Filter entities based on having at least one of the provided elements.
|
|
417
|
+
|
|
418
|
+
.. versionadded:: 5.3
|
|
419
|
+
"""
|
|
420
|
+
_check_suspicious_tags(tags, stacklevel=2)
|
|
421
|
+
return self.__class__(
|
|
422
|
+
self.registry,
|
|
423
|
+
_QueryLogicalAnd(
|
|
424
|
+
all_of=frozenset(
|
|
425
|
+
[_QueryLogicalOr(any_of=frozenset(self.__as_queries(components, tags, relations, traverse, depth)))]
|
|
426
|
+
)
|
|
427
|
+
)
|
|
428
|
+
& self._query,
|
|
429
|
+
)
|
|
430
|
+
|
|
407
431
|
def __iter__(self) -> Iterator[Entity]:
|
|
408
432
|
"""Iterate over the matching entities."""
|
|
409
433
|
return iter(self.get_entities())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|