diff options
| author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-08-24 13:04:21 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-08-24 13:04:21 -0700 |
| commit | b144ad5df76e458297bd6dc030cad4af0f344901 (patch) | |
| tree | d3cdb19deea8f2e15e52af53d530305a8f01c258 /kennel/engine/entities | |
| parent | 5dc264e08253c3a97ea41d1fde5fbf3f33dd6591 (diff) | |
| download | kennel.hatecomputers.club-b144ad5df76e458297bd6dc030cad4af0f344901.tar.gz kennel.hatecomputers.club-b144ad5df76e458297bd6dc030cad4af0f344901.zip | |
fix remove_entity method
Diffstat (limited to 'kennel/engine/entities')
| -rw-r--r-- | kennel/engine/entities/entity.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kennel/engine/entities/entity.py b/kennel/engine/entities/entity.py index b72e996..6623512 100644 --- a/kennel/engine/entities/entity.py +++ b/kennel/engine/entities/entity.py @@ -57,11 +57,13 @@ class EntityManager: self.component_entities[component.component_type].add(entity) def remove_entity(self, entity_id: str) -> None: - if entity_id in self.entities: - entity = self.entities[entity_id] - for component in entity.components.values(): - if component.component_type in self.component_entities: - self.component_entities[component.component_type].remove(entity) + if entity_id not in self.entities: + return + entity = self.entities[entity_id] + for component in entity.components.values(): + if component.component_type in self.component_entities: + self.component_entities[component.component_type].remove(entity) + del self.entities[entity_id] def get_entity(self, entity_id: str) -> Optional[Entity]: return self.entities.get(entity_id) |
