X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=koperkapel%2Fscenes%2Froach_management.py;fp=koperkapel%2Fscenes%2Froach_management.py;h=4e41b9c538608d0dd7df2097335a772556d1331a;hb=e275a42b8cc75a4b3989096171b4dc17939b9de0;hp=6c867fb4f196142b424a7508c063b7bca751026f;hpb=b0e9b722445f62943284044e1b5f9638db89a4e7;p=koperkapel.git diff --git a/koperkapel/scenes/roach_management.py b/koperkapel/scenes/roach_management.py index 6c867fb..4e41b9c 100644 --- a/koperkapel/scenes/roach_management.py +++ b/koperkapel/scenes/roach_management.py @@ -10,7 +10,7 @@ from ..constants import WIDTH, HEIGHT from ..roaches import big_roaches, roach_by_name from ..serums import big_serums, roach_is_serumless, SERUMS from ..vehicles.base import Vehicle -from .base import Scene, ChangeSceneEvent +from .base import Scene, ChangeSceneEvent, defer_to_update TOOLBAR_LEFT_X = WIDTH * 3 // 4 @@ -52,7 +52,6 @@ class RoachesScene(Scene): def enter(self, world): self._vehicle = Vehicle.current(world) - self._update_calls = [] self._init_bg() self._init_seats() self._init_roaches(world) @@ -187,24 +186,18 @@ class RoachesScene(Scene): self._seat_pos = seat_pos self._seat_layer[self._seat_pos].selected = True - def _eject_roach(self, world=None): - if world is None: - self._update_calls.append(self._eject_roach) - return + @defer_to_update + def _eject_roach(self, world): self._vehicle.seat_roach(world, None, self._seat_pos) - def _click_roach_pad(self, world=None): - if world is None: - self._update_calls.append(self._click_roach_pad) - return + @defer_to_update + def _click_roach_pad(self, world): if self._outside_roaches: roach = self._outside_roaches[self._outside_roach_pos] self._vehicle.seat_roach(world, roach, self._seat_pos) - def _click_inventory_pad(self, world=None): - if world is None: - self._update_calls.append(self._click_inventory_pad) - return + @defer_to_update + def _click_inventory_pad(self, world): roach_name = self._vehicle.roach_at(world, self._seat_pos) if roach_name is None: return @@ -218,19 +211,15 @@ class RoachesScene(Scene): if roach_is_serumless(roach): roach[serum] = True world.serums = serums - self._update_calls.append((self._update_roach_actor, roach_name)) + self._update_roach_actor(roach_name) + @defer_to_update def _update_roach_actor(self, world, roach_name): roach = roach_by_name(world, roach_name) self._roach_actors[roach_name] = big_roaches.assemble(roach) def update(self, world, engine, dt): - update_calls, self._update_calls = self._update_calls, [] - while update_calls: - f, args = update_calls.pop(), () - if type(f) is tuple: - f, args = f[0], f[1:] - f(world, *args) + super().update(world, engine, dt) events = world.pop_events() self._update_inventory(world) self._update_roaches(world)