Name layer attributes more clearly.
authorSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 10:48:09 +0000 (12:48 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 10:48:09 +0000 (12:48 +0200)
koperkapel/scenes/roach_management.py

index 0d10e21f5078e1f8b23a0fecc61dcbbf09811a00..cb939f80d999dc442014f6ba983713c123fea2d8 100644 (file)
@@ -30,15 +30,16 @@ class RoachesScene(Scene):
 
     def __init__(self):
         super().__init__()
+        self._vehicle = None
+        self._seat_pos = None
         self._outside_roach_pos = 0
         self._inventory_pos = 0
         self._inventory_item = None
-        self._selected_seat = None
-        self._roaches = self.actors.add_layer("roaches", level=10)
-        self._inventory = self.actors.add_layer("inventory", level=10)
-        self._pads = self.actors.add_layer("pads", level=5)
-        self._seats = self.actors.add_layer("seats", level=5)
-        self._buttons = self.actors.add_layer("buttons", level=6)
+        self._roach_layer = self.actors.add_layer("roaches", level=10)
+        self._inventory_layer = self.actors.add_layer("inventory", level=10)
+        self._pad_layer = self.actors.add_layer("pads", level=5)
+        self._seat_layer = self.actors.add_layer("seats", level=5)
+        self._button_layer = self.actors.add_layer("buttons", level=6)
         self._init_pads()
         self._init_buttons()
         self._init_serums()
@@ -51,28 +52,31 @@ class RoachesScene(Scene):
         self._update_inventory(world)
 
     def _init_bg(self):
+        self.actors.default.clear()
         self.actors.default.add(self._vehicle.roach_management_overlay())
 
     def _init_seats(self):
+        self._seat_layer.clear()
         for seat in self._vehicle.seats:
-            seat_actor = self._seats.add(seat.actor())
+            seat_actor = self._seat_layer.add(seat.actor())
             seat_actor.pos = (
                 seat.vehicle_pos[0] + VEHICLE_MID_X,
                 seat.vehicle_pos[1] + VEHICLE_MID_Y)
 
     def _init_roaches(self, roaches):
+        self._roach_layer.clear()
         for i, roach in enumerate(roaches):
-            roach_actor = self._roaches.add(big_roaches.assemble(roach))
+            roach_actor = self._roach_layer.add(big_roaches.assemble(roach))
             # TODO: less hacky seat assignment
-            if i < len(self._seats):
-                roach_actor.pos = self._seats[i].pos
+            if i < len(self._seat_layer):
+                roach_actor.pos = self._seat_layer[i].pos
 
     def _init_serums(self):
         self._serum_actors = {
             serum: big_serums.assemble(serum) for serum in SERUMS}
 
     def _update_inventory(self, world):
-        self._inventory.clear()
+        self._inventory_layer.clear()
         serums = world.serums
         if not serums:
             return
@@ -82,23 +86,24 @@ class RoachesScene(Scene):
         serum_actor.pos = (
             inv_pad_centre[0] + SERUM_OFFSET[0],
             inv_pad_centre[1] + SERUM_OFFSET[1])
-        self._inventory.add(serum_actor)
+        self._inventory_layer.add(serum_actor)
 
     def _init_pads(self):
-        self._roach_pad = self._pads.add(
+        self._roach_pad = self._pad_layer.add(
             Actor("roach_management/roach_pad", anchor=("left", "bottom")))
         self._roach_pad.pos = (TOOLBAR_LEFT_X, TOOLBAR_MID_Y)
-        self._inventory_pad = self._pads.add(
+        self._inventory_pad = self._pad_layer.add(
             Actor("roach_management/inventory_pad", anchor=("left", "top")))
         self._inventory_pad.pos = (TOOLBAR_LEFT_X, TOOLBAR_MID_Y)
 
     def _add_button(self, name, anchor, inset, pos, action):
-        button = self._buttons.add(
+        button = self._button_layer.add(
             ImageButton(name, anchor=anchor, action=action))
         button.pos = inset_button(pos, inset)
         return button
 
     def _init_buttons(self):
+        self._button_layer.clear()
         self._add_button(
             "roach_management/left_button", ("left", "bottom"), (1, -1),
             self._roach_pad.bottomleft, self._roach_left)