From 3da2c271f599154904283de864eea0b490715dad Mon Sep 17 00:00:00 2001 From: Valentin Stark Date: Sun, 21 Aug 2022 23:25:40 +0200 Subject: [PATCH] =?UTF-8?q?Nouvelle=20sc=C3=A8ne=20pour=20la=20g=C3=A9n?= =?UTF-8?q?=C3=A9ration=20du=20monde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu/LoadWorld.gd | 2 +- menu/NewWorld.gd | 2 +- ui/map/map.gd | 4 +--- .../world_generation/WorldGeneration.gd | 6 ++---- utils/world_generation/WorldGeneration.tscn | 18 ++++++++++++++++++ world/World3d.gd | 6 +----- world/game.tscn | 6 +----- 7 files changed, 25 insertions(+), 19 deletions(-) rename world/game.gd => utils/world_generation/WorldGeneration.gd (98%) create mode 100644 utils/world_generation/WorldGeneration.tscn diff --git a/menu/LoadWorld.gd b/menu/LoadWorld.gd index 9b434ec..918f03b 100644 --- a/menu/LoadWorld.gd +++ b/menu/LoadWorld.gd @@ -15,4 +15,4 @@ func _on_CancelButton_pressed(): func _button_pressed(name): Global.terrain_name = name - get_tree().change_scene("res://world/game.tscn") + get_tree().change_scene("res://utils/world_generation/WorldGeneration.tscn") diff --git a/menu/NewWorld.gd b/menu/NewWorld.gd index 3f30e31..d747012 100644 --- a/menu/NewWorld.gd +++ b/menu/NewWorld.gd @@ -11,4 +11,4 @@ func _on_CancelButton_pressed(): func _on_CreateButton_pressed(): Global.terrain_name = $VBoxContainer/LineEdit.text - get_tree().change_scene("res://world/game.tscn") + get_tree().change_scene("res://utils/world_generation/WorldGeneration.tscn") diff --git a/ui/map/map.gd b/ui/map/map.gd index 71fefbe..786c358 100644 --- a/ui/map/map.gd +++ b/ui/map/map.gd @@ -3,6 +3,7 @@ extends Node2D signal map_clicked func heightmap(): + print (Global.terrain) for triangle in Global.terrain.get_triangles(): var colors = Gradient.new() colors.add_point(0.999, Color("#9e0142")) # red @@ -97,6 +98,3 @@ func _process(_delta): var new_position = get_viewport().get_mouse_position() / scale if new_position.x <= 2000 and new_position.y <= 2000: emit_signal("map_clicked", new_position) - -func _on_Game_world_loaded(): - update() diff --git a/world/game.gd b/utils/world_generation/WorldGeneration.gd similarity index 98% rename from world/game.gd rename to utils/world_generation/WorldGeneration.gd index 20b8bc9..041ff58 100644 --- a/world/game.gd +++ b/utils/world_generation/WorldGeneration.gd @@ -1,6 +1,4 @@ -extends Node - -signal world_loaded +extends Control export(int) var width = 2000 export(int) var height = 2000 @@ -33,7 +31,7 @@ func _ready(): if Global.terrain.is_created() or Global.terrain.is_loaded(): add_trees() - emit_signal("world_loaded") + get_tree().change_scene("res://world/game.tscn") else: Global.print_debug("Pas de Global.terrain, pas de construction ...") Global.print_debug("Pas de construction ..., pas de palais ...") diff --git a/utils/world_generation/WorldGeneration.tscn b/utils/world_generation/WorldGeneration.tscn new file mode 100644 index 0000000..5314da0 --- /dev/null +++ b/utils/world_generation/WorldGeneration.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://utils/world_generation/WorldGeneration.gd" type="Script" id=1] + +[node name="WorldGeneration" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) + +[node name="ProgressBar" type="ProgressBar" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -82.5 +margin_top = -7.0 +margin_right = 82.5 +margin_bottom = 7.0 diff --git a/world/World3d.gd b/world/World3d.gd index e20a3af..9c2e2cd 100644 --- a/world/World3d.gd +++ b/world/World3d.gd @@ -1,8 +1,7 @@ extends Spatial func _ready(): - pass - + draw_world() func draw_world(): # for i in range(0, 1, 1): @@ -43,6 +42,3 @@ func draw_world(): mi.cast_shadow = GeometryInstance.SHADOW_CASTING_SETTING_ON print(mi) add_child(mi) - -func _on_Game_world_loaded(): - draw_world() diff --git a/world/game.tscn b/world/game.tscn index af1b6c5..a91dc29 100644 --- a/world/game.tscn +++ b/world/game.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://ui/ui.tscn" type="PackedScene" id=1] -[ext_resource path="res://world/game.gd" type="Script" id=2] [ext_resource path="res://world/default_env.tres" type="Environment" id=3] [ext_resource path="res://world/World3d.gd" type="Script" id=4] [ext_resource path="res://utils/camera/CamBase.tscn" type="PackedScene" id=5] @@ -13,7 +12,6 @@ size = Vector2( 2000, 2000 ) albedo_color = Color( 0.054902, 0.533333, 0.741176, 1 ) [node name="Game" type="Node"] -script = ExtResource( 2 ) [node name="UI" parent="." instance=ExtResource( 1 )] @@ -47,8 +45,6 @@ transform = Transform( 0.971628, 0.168947, -0.16552, 0, 0.699825, 0.714314, 0.23 light_energy = 0.1 shadow_enabled = true -[connection signal="world_loaded" from="." to="UI/Map" method="_on_Game_world_loaded"] -[connection signal="world_loaded" from="." to="World3d" method="_on_Game_world_loaded"] [connection signal="map_clicked" from="UI/Map" to="World3d/CamBase/Camera" method="_on_Map_map_clicked"] [connection signal="camera_moved" from="World3d/CamBase/Camera" to="UI/Map/Cursor" method="_on_Camera_camera_moved"]