The dungeon will now spawn plugs.

This commit is contained in:
Relintai 2021-08-27 19:30:27 +02:00
parent d6ba00be37
commit 4b5f6253db
6 changed files with 50 additions and 13 deletions

View File

@ -4,6 +4,7 @@ extends Spatial
export(bool) var generate_on_ready : bool = true export(bool) var generate_on_ready : bool = true
export(PropData) var start_room : PropData export(PropData) var start_room : PropData
export(Array, PropData) var rooms : Array export(Array, PropData) var rooms : Array
export(PropData) var plug : PropData
export(bool) var generate : bool setget set_generate, get_generate export(bool) var generate : bool setget set_generate, get_generate
#todo calc aabbs and store in PropData during prop conversion #todo calc aabbs and store in PropData during prop conversion
@ -121,15 +122,17 @@ func generate() -> void:
spawn_room(Transform(), start_room) spawn_room(Transform(), start_room)
func spawn_room(room_lworld_transform : Transform, room : PropData, level : int = 0, current_portal : PropDataPortal = null) -> void: func spawn_room(room_lworld_transform : Transform, room : PropData, level : int = 0, current_portal : PropDataPortal = null) -> void:
if level > 4: if level > 4:
var plugi : PropInstanceMerger = PropInstanceMerger.new()
plugi.prop_data = plug
add_child(plugi)
plugi.transform = room_lworld_transform
#test_spawn_pos(room_lworld_transform)
return return
var sr : PropInstanceMerger = PropInstanceMerger.new()
sr.prop_data = room
add_child(sr)
var orig_room_lworld_transform : Transform = room_lworld_transform var orig_room_lworld_transform : Transform = room_lworld_transform
if current_portal: if current_portal:
@ -140,6 +143,9 @@ func spawn_room(room_lworld_transform : Transform, room : PropData, level : int
lworld_curr_portal.basis = lworld_curr_portal.basis.rotated(Vector3(0, 1, 0), PI) lworld_curr_portal.basis = lworld_curr_portal.basis.rotated(Vector3(0, 1, 0), PI)
room_lworld_transform = room_lworld_transform * lworld_curr_portal.inverse() room_lworld_transform = room_lworld_transform * lworld_curr_portal.inverse()
var sr : PropInstanceMerger = PropInstanceMerger.new()
sr.prop_data = room
add_child(sr)
sr.transform = room_lworld_transform sr.transform = room_lworld_transform
var cab : PoolVector2Array = room_hulls[room] var cab : PoolVector2Array = room_hulls[room]
@ -154,8 +160,8 @@ func spawn_room(room_lworld_transform : Transform, room : PropData, level : int
current_aabbs.push_back(ctfab) current_aabbs.push_back(ctfab)
if Engine.editor_hint and debug: #if Engine.editor_hint and debug:
sr.owner = get_tree().edited_scene_root # sr.owner = get_tree().edited_scene_root
for pe in room.props: for pe in room.props:
if pe is PropDataPortal: if pe is PropDataPortal:
@ -236,6 +242,12 @@ func spawn_room(room_lworld_transform : Transform, room : PropData, level : int
if can_spawn: if can_spawn:
spawn_room(offset_current_portal_lworld_position, new_room, level + 1, new_room_portal) spawn_room(offset_current_portal_lworld_position, new_room, level + 1, new_room_portal)
else:
var plugi : PropInstanceMerger = PropInstanceMerger.new()
plugi.prop_data = plug
add_child(plugi)
plugi.transform = offset_current_portal_lworld_position
#test_spawn_pos(offset_current_portal_lworld_position)
func clear() -> void: func clear() -> void:
if Engine.editor_hint and debug: if Engine.editor_hint and debug:

View File

@ -1,12 +1,14 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://scripts/dungeons/dungeon.gd" type="Script" id=1] [ext_resource path="res://scripts/dungeons/dungeon.gd" type="Script" id=1]
[ext_resource path="res://test_rooms/Room5.tres" type="PropData" id=2] [ext_resource path="res://test_rooms/Room5.tres" type="PropData" id=2]
[ext_resource path="res://test_rooms/Room4.tres" type="PropData" id=3] [ext_resource path="res://test_rooms/Room4.tres" type="PropData" id=3]
[ext_resource path="res://test_rooms/Room3.tres" type="PropData" id=4] [ext_resource path="res://test_rooms/Room3.tres" type="PropData" id=4]
[ext_resource path="res://test_rooms/Room1.tres" type="PropData" id=5] [ext_resource path="res://test_rooms/Room1.tres" type="PropData" id=5]
[ext_resource path="res://test_rooms/RoomPlug.tres" type="PropData" id=6]
[node name="Dungeon" type="Spatial"] [node name="Dungeon" type="Spatial"]
script = ExtResource( 1 ) script = ExtResource( 1 )
start_room = ExtResource( 5 ) start_room = ExtResource( 5 )
rooms = [ ExtResource( 4 ), ExtResource( 3 ), ExtResource( 2 ) ] rooms = [ ExtResource( 4 ), ExtResource( 3 ), ExtResource( 2 ) ]
plug = ExtResource( 6 )

View File

@ -0,0 +1,11 @@
[gd_resource type="PropData" load_steps=3 format=2]
[ext_resource path="res://test_rooms/test2_tiledwalldata.tres" type="TiledWallData" id=1]
[sub_resource type="PropDataTiledWall" id=1]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0.5, -1, 0 )
heigth = 2
data = ExtResource( 1 )
[resource]
props = [ SubResource( 1 ) ]

View File

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://test_rooms/test2_tiledwalldata.tres" type="TiledWallData" id=10]
[node name="RoomPLug" type="Spatial"]
[node name="Floor" type="TiledWall" parent="."]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0.5, -1, 0 )
heigth = 2
data = ExtResource( 10 )

View File

@ -1,9 +1,7 @@
[gd_resource type="TiledWallData" load_steps=3 format=2] [gd_resource type="TiledWallData" load_steps=2 format=2]
[ext_resource path="res://modules/core/materials/6_standard_material_prop_nouv2.tres" type="Material" id=5]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_dungeon_1_albedo.png" type="Texture" id=6] [ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_dungeon_1_albedo.png" type="Texture" id=6]
[resource] [resource]
tiling_type = 3 tiling_type = 3
textures = [ ExtResource( 6 ) ] textures = [ ExtResource( 6 ) ]
materials = [ ExtResource( 5 ) ]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://tw/new_terramanlibrarymergerpcm.tres" type="TerramanLibraryMergerPCM" id=1] [ext_resource path="res://tw/new_terramanlibrarymergerpcm.tres" type="TerramanLibraryMergerPCM" id=1]
[ext_resource path="res://tw/TerraWorldBlocky.gd" type="Script" id=2] [ext_resource path="res://tw/TerraWorldBlocky.gd" type="Script" id=2]
@ -6,6 +6,7 @@
[ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=4] [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=4]
[ext_resource path="res://test_props/MeshDataInstance.tres" type="PropData" id=5] [ext_resource path="res://test_props/MeshDataInstance.tres" type="PropData" id=5]
[ext_resource path="res://modules/planets/test_planet/DungeonPlanetData.tres" type="Planet" id=6] [ext_resource path="res://modules/planets/test_planet/DungeonPlanetData.tres" type="Planet" id=6]
[ext_resource path="res://test_dungeon/Dungeon.tscn" type="PackedScene" id=7]
[sub_resource type="TerramanLevelGenerator" id=1] [sub_resource type="TerramanLevelGenerator" id=1]
script = ExtResource( 3 ) script = ExtResource( 3 )
@ -79,3 +80,6 @@ light_energy = 0.87
light_specular = 0.65 light_specular = 0.65
shadow_bias = 0.07 shadow_bias = 0.07
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="Dungeon" parent="." instance=ExtResource( 7 )]
transform = Transform( 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 99, 0 )