+ def unset_surroundings(self):
+ self._stencil = None
+ self._surrounding_map = None
+ self._surroundings_offset = None
+
+ def must_fix_indentation(self):
+ return self._radius % 2 != self.position[1][0] % 2
+
+ def get_surroundings_offset(self):
+ if self._surroundings_offset is not None:
+ return self._surroundings_offset
+ add_line = self.must_fix_indentation()
+ offset_y = self.position[1][0] - self._radius - int(add_line)
+ offset_x = self.position[1][1] - self._radius
+ self._surroundings_offset = (offset_y, offset_x)
+ return self._surroundings_offset
+
+ def get_surrounding_map(self):
+ if self._surrounding_map is not None:
+ return self._surrounding_map
+ offset = self.get_surroundings_offset()
+ add_line = self.must_fix_indentation()
+ self._surrounding_map = self.world.game.\
+ map_type(size=(self._radius*2+1+int(add_line),
+ self._radius*2+1))
+ for pos in self._surrounding_map:
+ offset_pos = (pos[0] + offset[0], pos[1] + offset[1])
+ if offset_pos[0] >= 0 and \
+ offset_pos[0] < self.world.maps[(0,0)].size[0] and \
+ offset_pos[1] >= 0 and \
+ offset_pos[1] < self.world.maps[(0,0)].size[1]:
+ self._surrounding_map[pos] = self.world.maps[(0,0)][offset_pos]
+ return self._surrounding_map
+