def update_tile_mat(self, tile_coords, top_material): chunk = self.chunks[tile_coords[0][0]][tile_coords[0][1]] tile = chunk.tiles[tile_coords[1][0]][tile_coords[1][1]] if chunk.materials[tile.top_mat_idx] != top_material: chunk.materials[tile.top_mat_idx].refcount -= 1 mat_deleted = chunk.materials[tile.top_mat_idx].refcount == 0 if mat_deleted: chunk.materials[tile.top_mat_idx] = None mat_idx = chunk.index_for_mat(top_material) if mat_idx is None and chunk.free_material_slots() == 0: print("Only {0} materials allowed per chunk!".format( pf.MATERIALS_PER_CHUNK)) return mat_added = chunk.free_material_slots() > 0 and mat_idx is None if mat_added: mat_idx = chunk.free_material_slot_idx() chunk.materials[mat_idx] = copy.deepcopy(top_material) assert mat_idx is not None assert mat_idx >= 0 and mat_idx < pf.MATERIALS_PER_CHUNK chunk.materials[mat_idx].refcount += 1 tile.top_mat_idx = mat_idx pf.update_tile(tile_coords[0], tile_coords[1], tile) if mat_deleted or mat_added: pf.update_chunk_materials(tile_coords[0], chunk.materials_str())
def update_tile(self, tile_coords, newheight, newtype, new_side_mat, new_ramp_height, new_blend_mode, new_blend_normals): chunk = self.chunks[tile_coords[0][0]][tile_coords[0][1]] tile = chunk.tiles[tile_coords[1][0]][tile_coords[1][1]] tile.base_height = newheight tile.type = newtype tile.sides_mat_idx = self.materials.index(new_side_mat) tile.ramp_height = new_ramp_height tile.blend_mode = new_blend_mode tile.blend_normals = new_blend_normals pf.update_tile(tile_coords[0], tile_coords[1], tile)
def update_tile_mat(self, tile_coords, top_material, blend_mode, blend_normals): chunk = self.chunks[tile_coords[0][0]][tile_coords[0][1]] tile = chunk.tiles[tile_coords[1][0]][tile_coords[1][1]] tile.top_mat_idx = self.materials.index(top_material) tile.blend_mode = blend_mode tile.blend_normals = blend_normals pf.update_tile(tile_coords[0], tile_coords[1], tile)
def update_tile(self, tile_coords, newheight=None, newtype=None, new_ramp_height=None): chunk = self.chunks[tile_coords[0][0]][tile_coords[0][1]] tile = chunk.tiles[tile_coords[1][0]][tile_coords[1][1]] if newheight is not None: tile.base_height = newheight if newtype is not None: tile.type = newtype if new_ramp_height is not None: tile.ramp_height = new_ramp_height pf.update_tile(tile_coords[0], tile_coords[1], tile)