def map_covered(self, nodes): """ Args: nodes (list): Contains str. """ self._map_covered = SelectedGrids( [self[node2location(node)] for node in nodes])
def camera_data_spawn_point(self, nodes): """ Args: nodes (list): Contains str. """ self._camera_data_spawn_point = SelectedGrids( [self[node2location(node)] for node in nodes])
def location_ensure(location): if isinstance(location, GridInfo): return location.location elif isinstance(location, str): return node2location(location) else: return location
def shape(self, scale): self._shape = node2location(scale.upper()) for y in range(self._shape[1] + 1): for x in range(self._shape[0] + 1): grid = GridInfo() grid.location = (x, y) self.grids[(x, y)] = grid # camera_data can be generate automatically, but it's better to set it manually. self.camera_data = [location2node(loca) for loca in camera_2d((0, 0, *self._shape), sight=self.camera_sight)] self.camera_data_spawn_point = [] # weight_data set to 10. for grid in self: grid.weight = 10.
def location_ensure(location): """ Args: location: Grid. Returns: tuple(int): Location, such as (4, 3) """ if isinstance(location, GridInfo): return location.location elif isinstance(location, str): return node2location(location) else: return location
def shape(self, scale): self._shape = node2location(scale.upper()) for y in range(self._shape[1] + 1): for x in range(self._shape[0] + 1): grid = GridInfo() grid.location = (x, y) self.grids[(x, y)] = grid # camera_data can be generate automatically, but it's better to set it manually. self.camera_data = [ location2node(loca) for loca in camera_2d(self._shape, sight=self.camera_sight) ] # weight_data set to 10. for grid in self: grid.weight = 10. # Initialize grid connection. self.grid_connection_initial()