X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=new%2Fplomrogue%2Fthings.py;h=13384fc76935d14e328287a34a0716805b75fe6d;hb=52cf6eee2b83be0fedd0df716395eb715ffddebb;hp=07c626525cf4ca2c94dcfe4011bcf219837665bf;hpb=e3992a6473984ae21445b1ab9e28976ace474a0c;p=plomrogue2-experiments diff --git a/new/plomrogue/things.py b/new/plomrogue/things.py index 07c6265..13384fc 100644 --- a/new/plomrogue/things.py +++ b/new/plomrogue/things.py @@ -13,6 +13,26 @@ class ThingBase: else: self.id_ = id_ + @property + def position(self): + return self._position + + def _position_set(self, pos): + """Set self._position to pos. + + We use this setter as core to the @position.setter property + method due to property setter subclassing not yet working + properly, see . We will + therefore super() _position_set instead of @position.setter in + subclasses. + + """ + self._position = pos + + @position.setter + def position(self, pos): + self._position_set(pos) + class Thing(ThingBase): @@ -20,12 +40,18 @@ class Thing(ThingBase): in_inventory = False def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) self.inventory = [] + super().__init__(*args, **kwargs) def proceed(self): pass + def _position_set(self, pos): + super()._position_set(pos) + for t_id in self.inventory: + t = self.world.get_thing(t_id) + t.position = self.position + class ThingItem(Thing): @@ -220,7 +246,7 @@ class ThingAnimate(Thing): self._surrounding_map = self.world.game.\ map_type(size=(self._radius*2+1+int(add_line), self._radius*2+1)) - size = self.world.maps[(0,0)].size + size = self.world.map_size offset = self.get_surroundings_offset() for pos in self._surrounding_map: big_y, small_y = pan_and_scan(size[0], pos[0], offset[0]) @@ -265,7 +291,7 @@ class ThingAnimate(Thing): stencil = self.get_stencil() offset = self.get_surroundings_offset() visible_things = [] - size = self.world.maps[(0,0)].size + size = self.world.map_size fov_size = self.get_surrounding_map().size for thing in self.world.things: big_pos = thing.position[0]