Skip to content

Commit e438d90

Browse files
committed
Don't traverse attributes on Entity.clear
This causes confusion for the clear method and causes data to be missed instead of removed.
1 parent 81b801b commit e438d90

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Clearing an entity with inherited components no longer leaves the entity with missed components.
13+
1014
## [5.2.3] - 2024-08-20
1115

1216
### Fixed

tcod/ecs/entity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ def clear(self) -> None:
126126
127127
.. versionadded:: 4.2.0
128128
"""
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()
133133

134134
def instantiate(self) -> Self:
135135
"""Return a new entity which inherits the components, tags, and relations of this entity.

0 commit comments

Comments
 (0)