extends Node class_name World var heightmap: Array var width: int var height: int func get_neighbours_8_at_same_height(point: Vector2): var neighbours = 0 var current_bloc = heightmap[point.x][point.y] if heightmap[point.x-1][point.y-1] == current_bloc: neighbours += Global.directions_8.TOP_LEFT if heightmap[point.x][point.y-1] == current_bloc: neighbours += Global.directions_8.TOP if heightmap[point.x+1][point.y-1] == current_bloc: neighbours += Global.directions_8.TOP_RIGHT if heightmap[point.x+1][point.y] == current_bloc: neighbours += Global.directions_8.RIGHT if heightmap[point.x+1][point.y+1] == current_bloc: neighbours += Global.directions_8.BOTTOM_RIGHT if heightmap[point.x][point.y+1] == current_bloc: neighbours += Global.directions_8.BOTTOM if heightmap[point.x-1][point.y+1] == current_bloc: neighbours += Global.directions_8.BOTTOM_LEFT if heightmap[point.x-1][point.y] == current_bloc: neighbours += Global.directions_8.LEFT return neighbours func get_neighbours_4_at_same_height(point: Vector2): var neighbours = 0 var current_bloc = heightmap[point.x][point.y] if heightmap[point.x][point.y-1] == current_bloc: neighbours += Global.directions_4.TOP if heightmap[point.x+1][point.y] == current_bloc: neighbours += Global.directions_4.RIGHT if heightmap[point.x][point.y+1] == current_bloc: neighbours += Global.directions_4.BOTTOM if heightmap[point.x-1][point.y] == current_bloc: neighbours += Global.directions_4.LEFT return neighbours func find_elevation(point: Vector2): return heightmap[point.x][point.y]