diff --git a/world.py b/world.py index 0b4fc05..27df910 100644 --- a/world.py +++ b/world.py @@ -10,7 +10,7 @@ type EntityComponentStorage = dict[Entity, ComponentMap] @dataclass -class World: +class BaseWorld: registry: dict[Archetype, EntityComponentStorage] = field(default_factory=dict) next_entity_index: int = 0 systems: list[type[System]] = field(default_factory=list) @@ -40,13 +40,14 @@ class World: for entity, component_storage in entity_component_storage.items(): yield entity, component_storage - def get_components(self, entity: int, pop=False): + def get_components(self, entity: int, pop=False) -> dict[type, Any] | None: for archetype in self.registry.values(): if entity in archetype: if pop: return archetype.pop(entity, None) else: return archetype[entity] + return None def tick(self, *args, **kwargs): for system in self.systems: