Renames World to BaseWorld
This commit is contained in:
1 parent
8ad4106b36
commit
ce5eedbea2
1 file changed
+3
-2
@@ -10,7 +10,7 @@ type EntityComponentStorage = dict[Entity, ComponentMap]
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class World:
|
class BaseWorld:
|
||||||
registry: dict[Archetype, EntityComponentStorage] = field(default_factory=dict)
|
registry: dict[Archetype, EntityComponentStorage] = field(default_factory=dict)
|
||||||
next_entity_index: int = 0
|
next_entity_index: int = 0
|
||||||
systems: list[type[System]] = field(default_factory=list)
|
systems: list[type[System]] = field(default_factory=list)
|
||||||
@@ -40,13 +40,14 @@ class World:
|
|||||||
for entity, component_storage in entity_component_storage.items():
|
for entity, component_storage in entity_component_storage.items():
|
||||||
yield entity, component_storage
|
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():
|
for archetype in self.registry.values():
|
||||||
if entity in archetype:
|
if entity in archetype:
|
||||||
if pop:
|
if pop:
|
||||||
return archetype.pop(entity, None)
|
return archetype.pop(entity, None)
|
||||||
else:
|
else:
|
||||||
return archetype[entity]
|
return archetype[entity]
|
||||||
|
return None
|
||||||
|
|
||||||
def tick(self, *args, **kwargs):
|
def tick(self, *args, **kwargs):
|
||||||
for system in self.systems:
|
for system in self.systems:
|
||||||
|
|||||||
Reference in new issue
Block a user