WIP: ECS / Network System #1
|
@ -57,11 +57,13 @@ class EntityManager:
|
||||||
self.component_entities[component.component_type].add(entity)
|
self.component_entities[component.component_type].add(entity)
|
||||||
|
|
||||||
def remove_entity(self, entity_id: str) -> None:
|
def remove_entity(self, entity_id: str) -> None:
|
||||||
if entity_id in self.entities:
|
if entity_id not in self.entities:
|
||||||
entity = self.entities[entity_id]
|
return
|
||||||
for component in entity.components.values():
|
entity = self.entities[entity_id]
|
||||||
if component.component_type in self.component_entities:
|
for component in entity.components.values():
|
||||||
self.component_entities[component.component_type].remove(entity)
|
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]:
|
def get_entity(self, entity_id: str) -> Optional[Entity]:
|
||||||
return self.entities.get(entity_id)
|
return self.entities.get(entity_id)
|
||||||
|
|
|
@ -42,9 +42,9 @@ class Game:
|
||||||
self.last_time = current_time
|
self.last_time = current_time
|
||||||
|
|
||||||
await self.update(delta_time)
|
await self.update(delta_time)
|
||||||
await asyncio.sleep(
|
sleep_time = max(self.min_time_step - (time.time() - current_time), 0)
|
||||||
max(self.min_time_step - (time.time() - current_time), 0)
|
if sleep_time > 0:
|
||||||
)
|
await asyncio.sleep(sleep_time)
|
||||||
|
|
||||||
steps_since_log += 1
|
steps_since_log += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue