Update the world generator module to get the generator structure rework, and broken seals module, and the engine. The constant editor crashing is fixed now, it was caused by BiomeBase, because it was inherited from a class in an another module, and apparently that doesn't work. As a bonus the editor also feels a lot snappier now.

This commit is contained in:
Relintai 2020-07-21 23:02:06 +02:00
parent 7770879003
commit 45534fa29b
17 changed files with 83 additions and 86 deletions

2
HEADS
View File

@ -1 +1 @@
{"engine": {"3.2": "c79ec3951b44df4d794c3076e10c67a35b9d662d", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "59dde526b9d10079ca61b50ee2b619db31bfb32d"}, "entity_spell_system": {"master": "af1bd74fbf38d0ac42d3cf203feb3c7212d01849"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "e9dc7d18dd65b699781c383305fb45efbfb9d53c"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "85417ebee9198be3cd7cc643e0e0e934db64a620"}, "procedural_animations": {"master": "9226d21781ea05828570e592874aa319df0dc53d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "544654f49b13af2d25ac14152c8a5014474e6333"}, "mesh_utils": {"master": "4f69ec67b861ce4475cfd17946dfaa586c888d94"}, "broken_seals_module": {"master": "0e5c54a70f8e90f95cbf11419b959a5f67562d48"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}} {"engine": {"3.2": "af35d0d3c83161848fad952f24d42592b1a9b932", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "eed7f40e51fb8aceb032a909adb08a2f9366bf13"}, "entity_spell_system": {"master": "af1bd74fbf38d0ac42d3cf203feb3c7212d01849"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "e9dc7d18dd65b699781c383305fb45efbfb9d53c"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "85417ebee9198be3cd7cc643e0e0e934db64a620"}, "procedural_animations": {"master": "9226d21781ea05828570e592874aa319df0dc53d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "544654f49b13af2d25ac14152c8a5014474e6333"}, "mesh_utils": {"master": "4f69ec67b861ce4475cfd17946dfaa586c888d94"}, "broken_seals_module": {"master": "8c4b32d3932ccb043b8f6c92c1277547750fe391"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}}

View File

@ -20,7 +20,7 @@
[ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=18] [ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=18]
[ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=19] [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=19]
[ext_resource path="res://ui/about/About.tscn" type="PackedScene" id=20] [ext_resource path="res://ui/about/About.tscn" type="PackedScene" id=20]
[ext_resource path="res://modules/planets/test_planet/SimplePlanetData.tres" type="PlanetData" id=21] [ext_resource path="res://modules/planets/test_planet/SimplePlanetData.tres" type="Planet" id=21]
[sub_resource type="VoxelmanLevelGenerator" id=1] [sub_resource type="VoxelmanLevelGenerator" id=1]
script = ExtResource( 18 ) script = ExtResource( 18 )

View File

@ -1,9 +1,9 @@
[gd_resource type="PlanetData" load_steps=3 format=2] [gd_resource type="Planet" load_steps=3 format=2]
[ext_resource path="res://modules/planets/test_planet/planets/simple_planet.tres" type="Planet" id=1] [ext_resource path="res://modules/planets/test_planet/planets/dung_simple_planet.gd" type="Script" id=1]
[ext_resource path="res://modules/planets/test_planet/biomes/2_tdungb.tres" type="BiomeData" id=2] [ext_resource path="res://modules/planets/test_planet/biomes/2_tdungb.tres" type="Biome" id=2]
[resource] [resource]
id = 1 id = 1
planet = ExtResource( 1 ) biomes = [ ExtResource( 2 ) ]
biome_datas = [ ExtResource( 2 ) ] script = ExtResource( 1 )

View File

@ -1,9 +1,9 @@
[gd_resource type="PlanetData" load_steps=3 format=2] [gd_resource type="Planet" load_steps=3 format=2]
[ext_resource path="res://modules/planets/test_planet/planets/simple_planet.tres" type="Planet" id=1] [ext_resource path="res://modules/planets/test_planet/planets/dung_simple_planet.gd" type="Script" id=1]
[ext_resource path="res://modules/planets/test_planet/biomes/1_test.tres" type="BiomeData" id=2] [ext_resource path="res://modules/planets/test_planet/biomes/1_test.tres" type="Biome" id=2]
[resource] [resource]
id = 1 id = 1
planet = ExtResource( 1 ) biomes = [ ExtResource( 2 ) ]
biome_datas = [ ExtResource( 2 ) ] script = ExtResource( 1 )

View File

@ -1,7 +1,6 @@
[gd_resource type="BiomeData" load_steps=2 format=2] [gd_resource type="Biome" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/biomes/biome1.tres" type="BiomeBase" id=1] [ext_resource path="res://modules/planets/test_planet/biomes/simple_biome.gd" type="Script" id=1]
[resource] [resource]
biome = ExtResource( 1 ) script = ExtResource( 1 )
voxel_surfaces = [ null, null, null, null ]

View File

@ -1,8 +1,8 @@
[gd_resource type="BiomeData" load_steps=3 format=2] [gd_resource type="Biome" load_steps=3 format=2]
[ext_resource path="res://modules/planets/test_planet/dungeons/1_test.tres" type="DungeonData" id=1] [ext_resource path="res://modules/planets/test_planet/biomes/simple_biome.gd" type="Script" id=1]
[ext_resource path="res://modules/planets/test_planet/biomes/biome1.tres" type="BiomeBase" id=2] [ext_resource path="res://modules/planets/test_planet/dungeons/dungeon.tres" type="Dungeon" id=2]
[resource] [resource]
biome = ExtResource( 2 ) dungeons = [ ExtResource( 2 ) ]
dungeon_datas = [ ExtResource( 1 ) ] script = ExtResource( 1 )

View File

@ -1,6 +0,0 @@
[gd_resource type="BiomeBase" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/biomes/simple_biome.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )

View File

@ -1,4 +1,4 @@
extends BiomeBase extends Biome
# Copyright (c) 2019-2020 Péter Magyar # Copyright (c) 2019-2020 Péter Magyar
# #
@ -20,34 +20,25 @@ extends BiomeBase
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
func _setup(): var terrarin_gen : BiomeTerrarinGenerator = BiomeTerrarinGenerator.new()
if !data:
return
for i in range(data.get_dungeon_data_count()):
var dd : DungeonData = data.get_dungeon_data(i)
if !dd:
continue
var d : Dungeon = dd.instance() func _setup():
d.posx = 0 terrarin_gen.set_current_seed(current_seed)
d.posz = 0
d.posy = -20 for i in range(get_dungeon_count()):
d.current_seed = current_seed var d : Dungeon = get_dungeon(i)
d.setup() d.setup()
add_dungeon(d)
func _generate_chunk(chunk: VoxelChunk, spawn_mobs: bool) -> void: func _generate_chunk(chunk: VoxelChunk, spawn_mobs: bool) -> void:
# var chunk : VoxelChunk = chunk.get_chunk() # var chunk : VoxelChunk = chunk.get_chunk()
# generate_terrarin(chunk, spawn_mobs) # generate_terrarin(chunk, spawn_mobs)\
terrarin_gen.generate_simple_terrarin(chunk, spawn_mobs)
for i in range(get_dungeon_count()): for i in range(get_dungeon_count()):
get_dungeon(i).generate_chunk(chunk, spawn_mobs) get_dungeon(i).generate_chunk(chunk, spawn_mobs)
generate_simple_terrarin(chunk, spawn_mobs)
if not Engine.editor_hint and chunk.position_y == 0 and spawn_mobs and randi() % 4 == 0: if not Engine.editor_hint and chunk.position_y == 0 and spawn_mobs and randi() % 4 == 0:
ESS.entity_spawner.spawn_mob(0, randi() % 3, Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\ ESS.entity_spawner.spawn_mob(0, randi() % 3, Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
(chunk.position_y + 1) * chunk.size_y * chunk.voxel_scale, \ (chunk.position_y + 1) * chunk.size_y * chunk.voxel_scale, \

View File

@ -1,4 +1,4 @@
[gd_resource type="DungeonRoomData" load_steps=2 format=2] [gd_resource type="DungeonRoom" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/dungeon_rooms/dungeon_room.tres" type="DungeonRoom" id=1] [ext_resource path="res://modules/planets/test_planet/dungeon_rooms/dungeon_room.tres" type="DungeonRoom" id=1]

View File

@ -1,4 +1,4 @@
[gd_resource type="DungeonRoomData" load_steps=2 format=2] [gd_resource type="DungeonRoom" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/dungeon_rooms/dungeon_room.tres" type="DungeonRoom" id=1] [ext_resource path="res://modules/planets/test_planet/dungeon_rooms/dungeon_room.tres" type="DungeonRoom" id=1]

View File

@ -1,8 +1,3 @@
[gd_resource type="DungeonData" load_steps=3 format=2] [gd_resource type="Dungeon" format=2]
[ext_resource path="res://modules/planets/test_planet/dungeons/dungeon.tres" type="Dungeon" id=1]
[ext_resource path="res://modules/planets/test_planet/dungeon_rooms/2_test_start_room.tres" type="DungeonRoomData" id=2]
[resource] [resource]
dungeon = ExtResource( 1 )
dungeon_start_room_datas = [ ExtResource( 2 ) ]

View File

@ -57,6 +57,33 @@ var enemy_data : Array = []
enum NeighbourCaseCodeFlags { WallXP = 1, WallXN = 2, WallZP = 4, WallZN = 8 } enum NeighbourCaseCodeFlags { WallXP = 1, WallXN = 2, WallZP = 4, WallZN = 8 }
enum Tile { Wall, Floor, Door, Empty } enum Tile { Wall, Floor, Door, Empty }
func _instance(p_seed, p_instance):
if !p_instance:
p_instance = ._instance(p_seed, p_instance)
p_instance.level_room_count = level_room_count
p_instance.min_room_dimension = min_room_dimension
p_instance.max_room_dimension = max_room_dimension
p_instance.enemy_count = enemy_count
p_instance.spawn_mobs = spawn_mobs
p_instance.dung_floor = dung_floor
p_instance.dung_ceiling = dung_ceiling
p_instance.dung_wall_xp = dung_wall_xp
p_instance.dung_wall_xn = dung_wall_xn
p_instance.dung_wall_zp = dung_wall_zp
p_instance.dung_wall_zn = dung_wall_zn
p_instance.wall_texture = wall_texture
p_instance.floor_texture = floor_texture
p_instance.ceiling_texture = ceiling_texture
p_instance.dung_entrance_mdr = dung_entrance_mdr
p_instance.dung_entrance_scene = dung_entrance_scene
return p_instance
func _setup(): func _setup():
if sizex == 0 || sizey == 0 || sizez == 0: if sizex == 0 || sizey == 0 || sizez == 0:
print("Dungeon size is 0!") print("Dungeon size is 0!")
@ -67,7 +94,7 @@ func _setup():
# if data.get_dungeon_start_room_data_count() == 0: # if data.get_dungeon_start_room_data_count() == 0:
# return # return
# #
# var drd : DungeonRoomData = data.get_dungeon_start_room_data(0) # var drd : DungeonRoom = data.get_dungeon_start_room_data(0)
# #
# var dung : DungeonRoom = drd.instance() # var dung : DungeonRoom = drd.instance()
# #
@ -80,7 +107,7 @@ func _setup():
# #
# add_dungeon_start_room(dung) # add_dungeon_start_room(dung)
posy = 7 posy = 5
build() build()
@ -93,8 +120,8 @@ func _setup_library(library):
library.get_prop_packer().add_texture(ceiling_texture) library.get_prop_packer().add_texture(ceiling_texture)
func _generate_chunk(chunk, spawn_mobs): func _generate_chunk(chunk, spawn_mobs):
var aabb : AABB = AABB(Vector3(posx, posy, posz) * chunk.get_voxel_scale(), Vector3(sizex, sizey, sizez) * chunk.get_voxel_scale()) var aabb : AABB = AABB(Vector3(posx - 1, posy - 1, posz - 1), Vector3(sizex + 2, sizey + 2, sizez + 2))
var chunk_aabb : AABB = AABB(chunk.get_position() * Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * chunk.get_voxel_scale(), Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * chunk.get_voxel_scale()) var chunk_aabb : AABB = AABB(chunk.get_position() * Vector3(chunk.size_x, chunk.size_y, chunk.size_z), Vector3(chunk.size_x, chunk.size_y, chunk.size_z))
if dung_entrance_scene && chunk_aabb.has_point(entrance_position.origin): if dung_entrance_scene && chunk_aabb.has_point(entrance_position.origin):
inner_entrance_position = Vector3(player_inner_entrance_position_x * chunk.voxel_scale, (posy + 2) * chunk.voxel_scale + 0.3, player_inner_entrance_position_z * chunk.voxel_scale) inner_entrance_position = Vector3(player_inner_entrance_position_x * chunk.voxel_scale, (posy + 2) * chunk.voxel_scale + 0.3, player_inner_entrance_position_z * chunk.voxel_scale)
@ -102,7 +129,10 @@ func _generate_chunk(chunk, spawn_mobs):
if !aabb.intersects(chunk_aabb): if !aabb.intersects(chunk_aabb):
return return
if chunk.position_y != 0:
return
var px : int = chunk.position_x * chunk.size_x - posx var px : int = chunk.position_x * chunk.size_x - posx
var pz : int = chunk.position_z * chunk.size_z - posz var pz : int = chunk.position_z * chunk.size_z - posz
@ -115,7 +145,7 @@ func _generate_chunk(chunk, spawn_mobs):
if toz > sizez: if toz > sizez:
toz = sizez toz = sizez
var floor_pos : int = chunk.position_y * chunk.size_y - posy var floor_pos : int = posy - chunk.position_y * chunk.size_y
var ceiling_pos : int = floor_pos + sizey var ceiling_pos : int = floor_pos + sizey
var draw_floor : bool = true var draw_floor : bool = true

View File

@ -21,27 +21,24 @@ extends Planet
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
func _setup(): func _setup():
if data == null: if get_biome_count() == 0:
return
if data.get_biome_data_count() == 0:
return return
var bdata : BiomeData = data.get_biome_data(0) var b : Biome = get_biome(0)
if !bdata: if !b:
return return
var b : Biome = bdata.instance()
b.current_seed = current_seed b.current_seed = current_seed
b.setup() b.setup()
add_biome(b)
# if bdata.get_dungeon_data_count() == 0: # if bdata.get_dungeon_data_count() == 0:
# return # return
# #
# var dd : DungeonData = bdata.get_dungeon_data(0) # var dd : Dungeon = bdata.get_dungeon_data(0)
# #
# var dung : Dungeon = dd.instance() # var dung : Dungeon = dd.instance()
# #
@ -56,7 +53,7 @@ func _setup():
func _generate_chunk(chunk, spawn_mobs): func _generate_chunk(chunk, spawn_mobs):
if (get_biome_count() == 0): if (get_biome_count() == 0):
return return
var b : Biome = get_biome(0) var b : Biome = get_biome(0)
b.generate_chunk(chunk, spawn_mobs) b.generate_chunk(chunk, spawn_mobs)

View File

@ -22,19 +22,11 @@ extends Planet
# SOFTWARE. # SOFTWARE.
func _setup(): func _setup():
if data == null: if get_biome_count() == 0:
return return
if data.get_biome_data_count() == 0: var b : Biome = get_biome(0)
return
var bdata : BiomeData = data.get_biome_data(0)
var b : Biome = bdata.instance()
b.current_seed = current_seed
b.setup() b.setup()
add_biome(b)
#func _setup_library(library): #func _setup_library(library):
# ._setup_library(library) # ._setup_library(library)

View File

@ -4,7 +4,7 @@
[ext_resource path="res://modules/planets/test_planet/voxel_library/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=2] [ext_resource path="res://modules/planets/test_planet/voxel_library/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=2]
[ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=3] [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=3]
[ext_resource path="res://test_props/MeshDataInstance.tres" type="PropData" id=4] [ext_resource path="res://test_props/MeshDataInstance.tres" type="PropData" id=4]
[ext_resource path="res://modules/planets/test_planet/DungeonPlanetData.tres" type="PlanetData" id=5] [ext_resource path="res://modules/planets/test_planet/DungeonPlanetData.tres" type="Planet" id=5]
[ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=8] [ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=8]
[sub_resource type="VoxelmanLevelGenerator" id=1] [sub_resource type="VoxelmanLevelGenerator" id=1]

View File

@ -27,7 +27,7 @@ const planet_folder : String = "res://modules/planets"
export(int) var _force_planet : int = -1 export(int) var _force_planet : int = -1
export(int) var _level_seed : int export(int) var _level_seed : int
export(bool) var _spawn_mobs : bool export(bool) var _spawn_mobs : bool
export(PlanetData) var planet : PlanetData = null export(Planet) var planet : Planet = null
var _world : VoxelWorld var _world : VoxelWorld
var _planet : Planet var _planet : Planet
@ -40,7 +40,7 @@ func setup(world : VoxelWorld, level_seed : int, spawn_mobs : bool, library: Vox
_library = library _library = library
if planet != null: if planet != null:
_planet = planet.instance() _planet = planet.instance(_level_seed)
_planet.current_seed = _level_seed _planet.current_seed = _level_seed
_planet.setup() _planet.setup()
_planet.setup_library(_library) _planet.setup_library(_library)
@ -67,7 +67,7 @@ func create_planet():
else: else:
ind = _force_planet ind = _force_planet
var planet_data : PlanetData = ResourceLoader.load(planet_files[ind], "PlanetData") var planet_data : Planet = ResourceLoader.load(planet_files[ind], "Planet")
if planet_data == null: if planet_data == null:
print("planet_data is null!") print("planet_data is null!")
@ -75,7 +75,7 @@ func create_planet():
print("planet loaded: " + planet_data.resource_path) print("planet loaded: " + planet_data.resource_path)
_planet = planet_data.instance() _planet = planet_data.instance(_level_seed)
_planet.current_seed = _level_seed _planet.current_seed = _level_seed
_planet.data = planet_data _planet.data = planet_data

View File

@ -49,7 +49,6 @@ var rc : int = 0
func _enter_tree(): func _enter_tree():
if generate_on_ready and not Engine.is_editor_hint(): if generate_on_ready and not Engine.is_editor_hint():
# This crashes pretty reliably, when duplicatiog BiomeBase, not yet sure why exactly
# call_deferred("generate") # call_deferred("generate")
generate() generate()