Fix crash on game restart

This commit is contained in:
Kanewersa 2021-06-20 16:41:41 +02:00
parent fd0d532350
commit ceb948587a

View File

@ -30,7 +30,7 @@ class WorldGenerator:
def __init__(self, win, callback):
self.win = win
self.callback = callback
self.world: World = esper.World()
self.world: World = esper.World(timed=True)
self.game_map: GameMap = GameMap(int(SCREEN_WIDTH / 32) * 2, 2 * int(SCREEN_HEIGHT / 32) + 1)
self.camera = Camera(self.game_map.width * 32, self.game_map.height * 32, self.win)
self.resource_generator: ResourceGenerator = ResourceGenerator(self.world, self.game_map)
@ -84,7 +84,7 @@ class WorldGenerator:
if self.world.has_component(self.player, ConsumptionComponent):
self.world.remove_component(self.player, ConsumptionComponent)
self.world.add_component(self.player, ConsumptionComponent(inv.total_items_count()))
self.world.add_component(self.player, ConsumptionComponent())
pos = self.world.component_for_entity(self.player, PositionComponent)
old_pos = pos.grid_position