From fee3ba9137382ecc7f4042495864cdf5f8a3911f Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 26 Apr 2020 10:59:22 +0200 Subject: [PATCH] Grouped the files of my current test planet together, and made the planet loading code use the new folder structure. --- game/data/biomes/2_tdungb.tres | 9 ----- .../data/dungeon_rooms/2_test_start_room.tres | 6 --- game/data/dungeons/1_test.tres | 8 ---- game/data/planets/1_tdungeon.tres | 9 ----- game/data/planets/test_planet/1_tdungeon.tres | 9 +++++ .../test_planet}/biomes/1_test.tres | 4 +- .../planets/test_planet/biomes/2_tdungb.tres | 9 +++++ .../test_planet}/biomes/simple_biome.gd | 0 .../test_planet}/dungeon_rooms/1_test.tres | 0 .../dungeon_rooms/2_test_start_room.tres | 6 +++ .../dungeon_start_rooms/start_room.gd | 0 .../planets/test_planet/dungeons/1_test.tres | 8 ++++ .../planets/test_planet}/dungeons/dungeon.gd | 0 .../planets/dung_simple_planet.gd | 0 .../test_planet}/planets/simple_planet.gd | 0 game/scenes/Menu.tscn | 3 ++ game/scenes/World.tscn | 3 ++ .../world_generators/MainPlanetGenerator.gd | 37 ++++++++++++------- game/voxelman/world/TVTestScene.tscn | 3 ++ 19 files changed, 68 insertions(+), 46 deletions(-) delete mode 100644 game/data/biomes/2_tdungb.tres delete mode 100644 game/data/dungeon_rooms/2_test_start_room.tres delete mode 100644 game/data/dungeons/1_test.tres delete mode 100644 game/data/planets/1_tdungeon.tres create mode 100644 game/data/planets/test_planet/1_tdungeon.tres rename game/data/{ => planets/test_planet}/biomes/1_test.tres (59%) create mode 100644 game/data/planets/test_planet/biomes/2_tdungb.tres rename game/{scripts => data/planets/test_planet}/biomes/simple_biome.gd (100%) rename game/data/{ => planets/test_planet}/dungeon_rooms/1_test.tres (100%) create mode 100644 game/data/planets/test_planet/dungeon_rooms/2_test_start_room.tres rename game/{scripts => data/planets/test_planet}/dungeon_start_rooms/start_room.gd (100%) create mode 100644 game/data/planets/test_planet/dungeons/1_test.tres rename game/{scripts => data/planets/test_planet}/dungeons/dungeon.gd (100%) rename game/{scripts => data/planets/test_planet}/planets/dung_simple_planet.gd (100%) rename game/{scripts => data/planets/test_planet}/planets/simple_planet.gd (100%) diff --git a/game/data/biomes/2_tdungb.tres b/game/data/biomes/2_tdungb.tres deleted file mode 100644 index d1f66421..00000000 --- a/game/data/biomes/2_tdungb.tres +++ /dev/null @@ -1,9 +0,0 @@ -[gd_resource type="BiomeData" load_steps=3 format=2] - -[ext_resource path="res://scripts/biomes/simple_biome.gd" type="Script" id=1] -[ext_resource path="res://data/dungeons/1_test.tres" type="DungeonData" id=2] - -[resource] -target_script = ExtResource( 1 ) -dungeon_datas = [ ExtResource( 2 ) ] -voxel_surfaces = [ null, null, null, null ] diff --git a/game/data/dungeon_rooms/2_test_start_room.tres b/game/data/dungeon_rooms/2_test_start_room.tres deleted file mode 100644 index bb0fe8fd..00000000 --- a/game/data/dungeon_rooms/2_test_start_room.tres +++ /dev/null @@ -1,6 +0,0 @@ -[gd_resource type="DungeonRoomData" load_steps=2 format=2] - -[ext_resource path="res://scripts/dungeon_start_rooms/start_room.gd" type="Script" id=1] - -[resource] -target_script = ExtResource( 1 ) diff --git a/game/data/dungeons/1_test.tres b/game/data/dungeons/1_test.tres deleted file mode 100644 index b3dfbff5..00000000 --- a/game/data/dungeons/1_test.tres +++ /dev/null @@ -1,8 +0,0 @@ -[gd_resource type="DungeonData" load_steps=3 format=2] - -[ext_resource path="res://scripts/dungeons/dungeon.gd" type="Script" id=1] -[ext_resource path="res://data/dungeon_rooms/2_test_start_room.tres" type="DungeonRoomData" id=2] - -[resource] -target_script = ExtResource( 1 ) -dungeon_start_room_datas = [ ExtResource( 2 ) ] diff --git a/game/data/planets/1_tdungeon.tres b/game/data/planets/1_tdungeon.tres deleted file mode 100644 index e82b9e8b..00000000 --- a/game/data/planets/1_tdungeon.tres +++ /dev/null @@ -1,9 +0,0 @@ -[gd_resource type="PlanetData" load_steps=3 format=2] - -[ext_resource path="res://scripts/planets/dung_simple_planet.gd" type="Script" id=1] -[ext_resource path="res://data/biomes/2_tdungb.tres" type="BiomeData" id=2] - -[resource] -id = 1 -target_script = ExtResource( 1 ) -biome_datas = [ ExtResource( 2 ) ] diff --git a/game/data/planets/test_planet/1_tdungeon.tres b/game/data/planets/test_planet/1_tdungeon.tres new file mode 100644 index 00000000..61655042 --- /dev/null +++ b/game/data/planets/test_planet/1_tdungeon.tres @@ -0,0 +1,9 @@ +[gd_resource type="PlanetData" load_steps=3 format=2] + +[ext_resource path="res://data/planets/test_planet/biomes/2_tdungb.tres" type="BiomeData" id=1] +[ext_resource path="res://data/planets/test_planet/planets/dung_simple_planet.gd" type="Script" id=2] + +[resource] +id = 1 +target_script = ExtResource( 2 ) +biome_datas = [ ExtResource( 1 ) ] diff --git a/game/data/biomes/1_test.tres b/game/data/planets/test_planet/biomes/1_test.tres similarity index 59% rename from game/data/biomes/1_test.tres rename to game/data/planets/test_planet/biomes/1_test.tres index dfbcdcaa..77ab75aa 100644 --- a/game/data/biomes/1_test.tres +++ b/game/data/planets/test_planet/biomes/1_test.tres @@ -1,6 +1,8 @@ [gd_resource type="BiomeData" load_steps=2 format=2] -[ext_resource path="res://scripts/biomes/simple_biome.gd" type="Script" id=1] +[ext_resource path="res://data/planets/test_planet/biomes/simple_biome.gd" type="Script" id=1] + + [resource] target_script = ExtResource( 1 ) diff --git a/game/data/planets/test_planet/biomes/2_tdungb.tres b/game/data/planets/test_planet/biomes/2_tdungb.tres new file mode 100644 index 00000000..ac55e426 --- /dev/null +++ b/game/data/planets/test_planet/biomes/2_tdungb.tres @@ -0,0 +1,9 @@ +[gd_resource type="BiomeData" load_steps=3 format=2] + +[ext_resource path="res://data/planets/test_planet/dungeons/1_test.tres" type="DungeonData" id=1] +[ext_resource path="res://data/planets/test_planet/biomes/simple_biome.gd" type="Script" id=2] + +[resource] +target_script = ExtResource( 2 ) +dungeon_datas = [ ExtResource( 1 ) ] +voxel_surfaces = [ null, null, null, null ] diff --git a/game/scripts/biomes/simple_biome.gd b/game/data/planets/test_planet/biomes/simple_biome.gd similarity index 100% rename from game/scripts/biomes/simple_biome.gd rename to game/data/planets/test_planet/biomes/simple_biome.gd diff --git a/game/data/dungeon_rooms/1_test.tres b/game/data/planets/test_planet/dungeon_rooms/1_test.tres similarity index 100% rename from game/data/dungeon_rooms/1_test.tres rename to game/data/planets/test_planet/dungeon_rooms/1_test.tres diff --git a/game/data/planets/test_planet/dungeon_rooms/2_test_start_room.tres b/game/data/planets/test_planet/dungeon_rooms/2_test_start_room.tres new file mode 100644 index 00000000..01ef9268 --- /dev/null +++ b/game/data/planets/test_planet/dungeon_rooms/2_test_start_room.tres @@ -0,0 +1,6 @@ +[gd_resource type="DungeonRoomData" load_steps=2 format=2] + +[ext_resource path="res://data/planets/test_planet/dungeon_start_rooms/start_room.gd" type="Script" id=1] + +[resource] +target_script = ExtResource( 1 ) diff --git a/game/scripts/dungeon_start_rooms/start_room.gd b/game/data/planets/test_planet/dungeon_start_rooms/start_room.gd similarity index 100% rename from game/scripts/dungeon_start_rooms/start_room.gd rename to game/data/planets/test_planet/dungeon_start_rooms/start_room.gd diff --git a/game/data/planets/test_planet/dungeons/1_test.tres b/game/data/planets/test_planet/dungeons/1_test.tres new file mode 100644 index 00000000..987f5bc0 --- /dev/null +++ b/game/data/planets/test_planet/dungeons/1_test.tres @@ -0,0 +1,8 @@ +[gd_resource type="DungeonData" load_steps=3 format=2] + +[ext_resource path="res://data/planets/test_planet/dungeons/dungeon.gd" type="Script" id=1] +[ext_resource path="res://data/planets/test_planet/dungeon_rooms/2_test_start_room.tres" type="DungeonRoomData" id=2] + +[resource] +target_script = ExtResource( 1 ) +dungeon_start_room_datas = [ ExtResource( 2 ) ] diff --git a/game/scripts/dungeons/dungeon.gd b/game/data/planets/test_planet/dungeons/dungeon.gd similarity index 100% rename from game/scripts/dungeons/dungeon.gd rename to game/data/planets/test_planet/dungeons/dungeon.gd diff --git a/game/scripts/planets/dung_simple_planet.gd b/game/data/planets/test_planet/planets/dung_simple_planet.gd similarity index 100% rename from game/scripts/planets/dung_simple_planet.gd rename to game/data/planets/test_planet/planets/dung_simple_planet.gd diff --git a/game/scripts/planets/simple_planet.gd b/game/data/planets/test_planet/planets/simple_planet.gd similarity index 100% rename from game/scripts/planets/simple_planet.gd rename to game/data/planets/test_planet/planets/simple_planet.gd diff --git a/game/scenes/Menu.tscn b/game/scenes/Menu.tscn index 81d16c08..75d217c4 100644 --- a/game/scenes/Menu.tscn +++ b/game/scenes/Menu.tscn @@ -21,6 +21,9 @@ [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=19] + + + [sub_resource type="VoxelmanLevelGenerator" id=1] script = ExtResource( 18 ) _force_planet = -1 diff --git a/game/scenes/World.tscn b/game/scenes/World.tscn index 430f91f2..cb3504b2 100644 --- a/game/scenes/World.tscn +++ b/game/scenes/World.tscn @@ -5,6 +5,9 @@ [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=3] [ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=8] + + + [sub_resource type="VoxelmanLevelGenerator" id=1] script = ExtResource( 1 ) _force_planet = -1 diff --git a/game/scripts/world_generators/MainPlanetGenerator.gd b/game/scripts/world_generators/MainPlanetGenerator.gd index c282e0cd..b7b73cb3 100644 --- a/game/scripts/world_generators/MainPlanetGenerator.gd +++ b/game/scripts/world_generators/MainPlanetGenerator.gd @@ -22,7 +22,7 @@ class_name MainPlanetGenerator # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -const planet_folder : String = "res://data/planets/" +const planet_folder : String = "res://data/planets" export(int) var _force_planet : int = -1 export(int) var _level_seed : int @@ -47,17 +47,7 @@ func _generate_chunk(chunk : VoxelChunk) -> void: _planet.generate_chunk(chunk, _spawn_mobs) func create_planet(): - var planet_files : Array = Array() - - var dir = Directory.new() - if dir.open(planet_folder) == OK: - dir.list_dir_begin() - var file_name = dir.get_next() - while (file_name != ""): - if not dir.current_is_dir(): - planet_files.append(file_name) - - file_name = dir.get_next() + var planet_files : Array = get_planets(planet_folder) if planet_files.size() == 0: return @@ -69,7 +59,7 @@ func create_planet(): else: ind = _force_planet - var planet_data : PlanetData = ResourceLoader.load(planet_folder + planet_files[ind], "PlanetData") + var planet_data : PlanetData = ResourceLoader.load(planet_files[ind], "PlanetData") if planet_data == null: print("planet_data is null!") @@ -96,3 +86,24 @@ func create_planet(): _planet.data = planet_data _planet.setup() _planet.setup_library(_library) + +func get_planets(path : String, root : bool = true) -> Array: + var planet_files : Array = Array() + + var dir = Directory.new() + if dir.open(path) == OK: + dir.list_dir_begin(true) + var file_name = dir.get_next() + while (file_name != ""): + if not dir.current_is_dir(): + planet_files.append(path + "/" + file_name) + else: + if root: + var l : Array = get_planets(path + "/" + file_name, false) + + for i in l: + planet_files.append(i) + + file_name = dir.get_next() + + return planet_files diff --git a/game/voxelman/world/TVTestScene.tscn b/game/voxelman/world/TVTestScene.tscn index f3e22f9f..2d4a5b77 100644 --- a/game/voxelman/world/TVTestScene.tscn +++ b/game/voxelman/world/TVTestScene.tscn @@ -10,6 +10,9 @@ + + + [sub_resource type="Environment" id=1] ambient_light_color = Color( 1, 1, 1, 1 )