X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=plomrogue%2Fmapping.py;fp=plomrogue%2Fmapping.py;h=d3baba67527e1f83f4d548071c2033eb86c27d85;hb=9c9475a01bbbd18b69056a9564768df6bff36539;hp=e3c071f85251ae9e947183a474fe69d78294e2bf;hpb=4a49836086c55c2736bcc7def243f6c4a72ae690;p=plomrogue2 diff --git a/plomrogue/mapping.py b/plomrogue/mapping.py index e3c071f..d3baba6 100644 --- a/plomrogue/mapping.py +++ b/plomrogue/mapping.py @@ -210,8 +210,8 @@ class Map(): class SourcedMap(Map): - def __init__(self, block_chars, things, source_maps, source_center, radius, - get_map): + def __init__(self, block_chars, obstacle_positions, source_maps, + source_center, radius, get_map): self.block_chars = block_chars self.radius = radius example_map = get_map(YX(0, 0)) @@ -219,20 +219,13 @@ class SourcedMap(Map): size, self.offset, self.center = \ self.source_geometry.define_segment(source_center, radius) self.geometry = self.source_geometry.__class__(size) - for yx in self: - big_yx, _ = self.source_yxyx(yx) - get_map(big_yx) self.source_map_segment = '' - obstacles = {} - for yxyx in [t.position for t in things if t.blocking]: - if yxyx == source_center: - continue - if yxyx[0] not in obstacles: - obstacles[yxyx[0]] = [] - obstacles[yxyx[0]] += [yxyx[1]] - for yx in self: # TODO: iter and source_yxyx expensive, cache earlier? + if source_center in obstacle_positions: + obstacle_positions.remove(source_center) + for yx in self: big_yx, little_yx = self.source_yxyx(yx) - if big_yx in obstacles and little_yx in obstacles[big_yx]: + get_map(big_yx) + if (big_yx, little_yx) in obstacle_positions: self.source_map_segment += self.block_chars[0] else: self.source_map_segment += source_maps[big_yx][little_yx]