- print("Cycle inventory right.")
-
- def _eject_roach(self):
- print("Eject roach.")
-
- def update(self, world, dt):
- for i, roach in enumerate(world.roaches):
- if roach.name in self._roach_actors:
- actor = self._roach_actors[roach.name]
- else:
- actor = TextButton("%s [%s]" % (
- roach.name,
- ", ".join("%s=%s" % kv for kv in sorted(
- roach.attributes.items()),
- )))
- self._roach_actors[roach.name] = actor
- self._roaches.add(actor)
- # TODO: remove missing roaches
- actor.pos = (300, 100 + i * 100)
+ self._inventory_pos += 1
+
+ def _select_seat(self, seat_pos):
+ self._seat_layer[self._seat_pos].selected = False
+ 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
+ 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
+ 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
+ roach_name = self._vehicle.roach_at(world, self._seat_pos)
+ if roach_name is None:
+ return
+ roach = roach_by_name(world, roach_name)
+ if roach is None:
+ return
+ serums = list(world.serums)
+ if self._inventory_pos >= len(serums):
+ return
+ serum = serums.pop(self._inventory_pos)
+ if roach_is_serumless(roach):
+ roach[serum] = True
+ world.serums = serums
+ self._update_calls.append((self._update_roach_actor, roach_name))
+
+ 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)
+ events = world.pop_events()
+ self._update_inventory(world)
+ self._update_roaches(world)
+ return events