Fix crash on game restart
This commit is contained in:
parent
fd0d532350
commit
ceb948587a
@ -30,7 +30,7 @@ class WorldGenerator:
|
|||||||
def __init__(self, win, callback):
|
def __init__(self, win, callback):
|
||||||
self.win = win
|
self.win = win
|
||||||
self.callback = callback
|
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.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.camera = Camera(self.game_map.width * 32, self.game_map.height * 32, self.win)
|
||||||
self.resource_generator: ResourceGenerator = ResourceGenerator(self.world, self.game_map)
|
self.resource_generator: ResourceGenerator = ResourceGenerator(self.world, self.game_map)
|
||||||
@ -84,7 +84,7 @@ class WorldGenerator:
|
|||||||
|
|
||||||
if self.world.has_component(self.player, ConsumptionComponent):
|
if self.world.has_component(self.player, ConsumptionComponent):
|
||||||
self.world.remove_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)
|
pos = self.world.component_for_entity(self.player, PositionComponent)
|
||||||
old_pos = pos.grid_position
|
old_pos = pos.grid_position
|
||||||
|
Loading…
Reference in New Issue
Block a user