diff --git a/game/addons/world_generator/resources/world_gen_base_resource.gd b/game/addons/world_generator/resources/world_gen_base_resource.gd index 204f4446..bd09fc8e 100644 --- a/game/addons/world_generator/resources/world_gen_base_resource.gd +++ b/game/addons/world_generator/resources/world_gen_base_resource.gd @@ -198,10 +198,10 @@ func get_editor_class() -> String: func get_editor_additional_text() -> String: return "" -func eitor_draw_additional(rect_view_node : MarginContainer) -> void: - _eitor_draw_additional(rect_view_node) +func eitor_draw_additional(control : Control) -> void: + _eitor_draw_additional(control) -func _eitor_draw_additional(rect_view_node : MarginContainer) -> void: +func _eitor_draw_additional(control : Control) -> void: pass func setup_property_inspector(inspector) -> void: diff --git a/game/scripts/world_generator/continents/test_continent.gd b/game/scripts/world_generator/continents/test_continent.gd index 8a329ac7..98a77a39 100644 --- a/game/scripts/world_generator/continents/test_continent.gd +++ b/game/scripts/world_generator/continents/test_continent.gd @@ -8,6 +8,45 @@ export(float) var continent_base : float = 0 var voxel_scale : float = 1 var current_seed : int = 0 +func _eitor_draw_additional(control : Control) -> void: + gui_draw_continent_radius(control, Color(0.6, 0.6, 0.6, 1)) + gui_draw_continent_bevel(control, Color(1, 1, 1, 1)) + +func gui_draw_continent_radius(control : Control, color : Color) -> void: + var s : Vector2 = control.get_size() + + var points : PoolVector2Array + var ofsx : float = (1 - (continent_radius * 2)) * s.x / 2.0 + var ofsy : float = (1 - (continent_radius * 2)) * s.y / 2.0 + + for i in range(16): + var ifl : float = float(i) + var n : float = ifl / 16.0 * 2 * PI + var n1 : float = (ifl + 1.0) / 16.0 * 2 * PI + + points.push_back(Vector2((sin(n) + 1.0) * 0.5 * continent_radius * 2 * s.x + ofsx, (cos(n) + 1.0) * 0.5 * continent_radius * 2 * s.y + ofsy)) + points.push_back(Vector2((sin(n1) + 1.0) * 0.5 * continent_radius * 2 * s.x + ofsx, (cos(n1) + 1.0) * 0.5 * continent_radius * 2 * s.y + ofsy)) + + control.draw_polyline(points, color, 1) + +func gui_draw_continent_bevel(control : Control, color : Color) -> void: + var s : Vector2 = control.get_size() + + var points : PoolVector2Array + var bevel_radius : float = (min(continent_radius, continent_bevel) / continent_radius) / 2.0 + var ofsx : float = (1 - (bevel_radius * 2)) * s.x / 2.0 + var ofsy : float = (1 - (bevel_radius * 2)) * s.y / 2.0 + + for i in range(16): + var ifl : float = float(i) + var n : float = ifl / 16.0 * 2 * PI + var n1 : float = (ifl + 1.0) / 16.0 * 2 * PI + + points.push_back(Vector2((sin(n) + 1.0) * 0.5 * bevel_radius * 2 * s.x + ofsx, (cos(n) + 1.0) * 0.5 * bevel_radius * 2 * s.y + ofsy)) + points.push_back(Vector2((sin(n1) + 1.0) * 0.5 * bevel_radius * 2 * s.x + ofsx, (cos(n1) + 1.0) * 0.5 * bevel_radius * 2 * s.y + ofsy)) + + control.draw_polyline(points, color, 1) + func get_continent_radius() -> float: return continent_radius diff --git a/game/worlds/test_world/test_world.tres b/game/worlds/test_world/test_world.tres index eb96ed2d..e16188d3 100644 --- a/game/worlds/test_world/test_world.tres +++ b/game/worlds/test_world/test_world.tres @@ -44,7 +44,7 @@ subzone_props = [ SubResource( 5 ), SubResource( 6 ) ] [sub_resource type="Resource" id=3] resource_name = "TestForest" script = ExtResource( 7 ) -rect = Rect2( 8.75557, 6.875, 21.9944, 11.2839 ) +rect = Rect2( 8.85557, 6.975, 21.9944, 11.2839 ) min_size = Vector2i( 1, 1 ) max_size = Vector2i( 1e+06, 1e+06 ) locked = false