Now the dungeon can have multiple levels.

This commit is contained in:
Relintai 2020-07-23 19:44:15 +02:00
parent 7b5712a996
commit 949f186928
6 changed files with 72 additions and 11 deletions

View File

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

View File

@ -22,6 +22,8 @@ extends Biome
var terrarin_gen : BiomeTerrarinGenerator = BiomeTerrarinGenerator.new()
var voxel_scale : float = -1
func _setup():
terrarin_gen.set_current_seed(current_seed)
@ -34,6 +36,22 @@ func _generate_chunk(chunk: VoxelChunk, spawn_mobs: bool) -> void:
# generate_terrarin(chunk, spawn_mobs)\
if voxel_scale < 0:
voxel_scale = chunk.voxel_scale
#todo generate this properly
var entrance_position : Vector3 = Vector3(7, 5, 7)
for i in range(get_dungeon_count()):
var d : Dungeon = get_dungeon(i)
d.entrance_position.origin = entrance_position
# print(entrance_position)
entrance_position = d.next_level_teleporter_position_data_space
entrance_position *= voxel_scale
terrarin_gen.generate_simple_terrarin(chunk, spawn_mobs)
for i in range(get_dungeon_count()):

View File

@ -51,6 +51,9 @@ var inner_entrance_position : Vector3 = Vector3()
var player_inner_entrance_position_x : int = 0
var player_inner_entrance_position_z : int = 0
var entrance_position_data_space : Vector3 = Vector3()
var next_level_teleporter_position_data_space : Vector3 = Vector3()
var enemy_data : Array = []
# in binary: WallXP = 00001, WallXN = 0010, WallZP = 0100, WallZN = 1000
@ -88,7 +91,7 @@ func _setup():
print("Dungeon size is 0!")
return
entrance_position.origin = Vector3(7, 5, 7)
# entrance_position.origin = Vector3(7, 5, 7)
# if data.get_dungeon_start_room_data_count() == 0:
# return
@ -117,8 +120,8 @@ func _setup_library(library):
library.get_prop_packer().add_texture(ceiling_texture)
func _generate_chunk(chunk, spawn_mobs):
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), Vector3(chunk.size_x, chunk.size_y, chunk.size_z))
var aabb : AABB = AABB(Vector3(posx - 1, posy - 1, posz - 1) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale), Vector3(sizex + 2, sizey + 2, sizez + 2) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale))
var chunk_aabb : AABB = AABB(chunk.get_position() * Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale), Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale))
if dung_entrance_scene && chunk_aabb.has_point(entrance_position.origin):
inner_entrance_position = Vector3(player_inner_entrance_position_x * chunk.voxel_scale, (posy + 4) * chunk.voxel_scale + 0.3, player_inner_entrance_position_z * chunk.voxel_scale)
@ -198,13 +201,11 @@ func _generate_chunk(chunk, spawn_mobs):
zz = 0
if spawn_mobs:
var chunk_world_aabb : AABB = AABB(chunk.get_position() * Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale), Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale))
for enemy in enemy_data:
var bp = enemy[0]
var pos : Vector3 = Vector3(bp.x * chunk.voxel_scale, (posy + 4) * chunk.voxel_scale, bp.y * chunk.voxel_scale)
if chunk_world_aabb.has_point(pos):
if chunk_aabb.has_point(pos):
ESS.entity_spawner.spawn_mob(enemy[1], enemy[2], pos)
# entities.app
@ -220,6 +221,8 @@ func spawn_teleporter_scene(scene : PackedScene, transform : Transform, chunk :
chunk.get_voxel_world().add_child(s)
s.transform = transform
s.teleport_to = teleports_to
print("spawn_teleporter_scene at: " + str(transform.origin) + " points to: " + str(teleports_to))
func build():
# randomize()
@ -236,6 +239,11 @@ func build():
# _player = ESS.entity_spawner.load_player(_player_file_name, pos, 1) as Entity
#Server.sset_seed(_player.sseed)
var end_room = rooms[rooms.size() - 1]
var erx = start_room.position.x + 1 + randi() % int(start_room.size.x - 2)
var erz = start_room.position.y + 1 + randi() % int(start_room.size.y - 2)
next_level_teleporter_position_data_space = Vector3(erx, posy, erz)
#Place enemies
if spawn_mobs:
for i in range(enemy_count):

View File

@ -0,0 +1,36 @@
[gd_resource type="Dungeon" load_steps=12 format=2]
[ext_resource path="res://modules/planets/test_planet/dungeons/dungeon.gd" type="Script" id=1]
[ext_resource path="res://modules/species/Human/Female/character_models/huf_calf_left.gltf" type="MeshDataResource" id=2]
[ext_resource path="res://modules/planets/test_planet/dungeons/dung_teleporter.tscn" type="PackedScene" id=3]
[ext_resource path="res://modules/core_models/ceiling.gltf" type="MeshDataResource" id=4]
[ext_resource path="res://modules/core_models/wall_xp.gltf" type="MeshDataResource" id=5]
[ext_resource path="res://modules/core_models/wall_xn.gltf" type="MeshDataResource" id=6]
[ext_resource path="res://modules/core_models/floor.gltf" type="MeshDataResource" id=7]
[ext_resource path="res://modules/core_models/wall_zn.gltf" type="MeshDataResource" id=8]
[ext_resource path="res://modules/core_models/wall_zp.gltf" type="MeshDataResource" id=9]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_1_albedo.png" type="Texture" id=10]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_dungeon_1_albedo.png" type="Texture" id=11]
[resource]
posy = -79
sizex = 40
sizey = 3
sizez = 40
script = ExtResource( 1 )
level_room_count = 9
min_room_dimension = 5
max_room_dimension = 8
enemy_count = 14
spawn_mobs = true
dung_floor = ExtResource( 7 )
dung_ceiling = ExtResource( 4 )
dung_wall_xp = ExtResource( 5 )
dung_wall_xn = ExtResource( 6 )
dung_wall_zp = ExtResource( 9 )
dung_wall_zn = ExtResource( 8 )
wall_texture = ExtResource( 11 )
floor_texture = ExtResource( 10 )
ceiling_texture = ExtResource( 10 )
dung_entrance_mdr = ExtResource( 2 )
dung_entrance_scene = ExtResource( 3 )

View File

@ -21,8 +21,6 @@ extends Planet
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
func _setup():
if get_biome_count() == 0:
return

View File

@ -385,7 +385,7 @@ func process_movement_mob(delta : float) -> void:
if vel.length_squared() < 0.12:
sleep = true
if translation.y < -200.0:
if translation.y < -2000.0:
print("killed mob with fall damage")
var sdi : SpellDamageInfo = SpellDamageInfo.new()
sdi.damage_source_type = SpellDamageInfo.DAMAGE_SOURCE_UNKNOWN