Package horizons :: Package world :: Package buildability :: Module partialbinarycache :: Class PartialBinaryBuildabilityCache
[hide private]
[frames] | no frames]

Class PartialBinaryBuildabilityCache

source code

A cache that knows where rectangles can be placed such that they are entirely inside the area.

This cache can be used to keep track of building buildability in case the buildability depends on the building being at least partly within a certain area. The binary part of the name refers to the fact that a node either is or isn't part of the area that the instance is about.

A query of the form (x, y) in instance.cache[(width, height)] is a very cheap way of finding out whether a rectangle of size (width, height) can be placed on origin (x, y) such that at least some part of it is within the given area.

All elements of instance.cache[(width, height)] can be iterated to get a complete list of all such coordinates.

Instance Methods [hide private]
__init__(self, terrain_cache) source code
add_area(self, new_coords_list)
Add a list of new coordinates to the area.
source code
remove_area(self, removed_coords_list)
Remove a list of existing coordinates from the area.
source code
Class Methods [hide private]
_extend_set(cls, cur_set, prev_set_additions, dx, dy) source code
_reduce_set(cls, cur_set, prev_set, prev_set_removals, dx, dy) source code