Basic Dungeon generation implementation

This commit is contained in:
2024-08-22 22:09:58 -07:00
parent 23ecd3a866
commit 8b3d1bed8a
16 changed files with 382 additions and 3 deletions

View File

@@ -0,0 +1,11 @@
[gd_scene load_steps=4 format=3 uid="uid://wg25dg65ksgg"]
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonGenerator3D.gd" id="1_l4et8"]
[ext_resource type="PackedScene" uid="uid://dhpwwqow1ahrc" path="res://src/map/dungeon/rooms/Room1.tscn" id="2_tghss"]
[ext_resource type="PackedScene" uid="uid://bn4gslp2gk8ds" path="res://src/map/dungeon/corridor/Corridor.tscn" id="3_ujbm3"]
[node name="DungeonGenerator3D" type="Node3D"]
script = ExtResource("1_l4et8")
room_scenes = Array[PackedScene]([ExtResource("2_tghss")])
corridor_room_scene = ExtResource("3_ujbm3")
dungeon_size = Vector3i(10, 1, 10)

View File

@@ -0,0 +1,59 @@
[gd_scene load_steps=12 format=3 uid="uid://bn4gslp2gk8ds"]
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_y0rqi"]
[ext_resource type="Texture2D" uid="uid://n4ds85jp0aq0" path="res://src/map/dungeon/textures/map_ceiling.jpg" id="2_6scux"]
[ext_resource type="PackedScene" uid="uid://ckaw6wjmi0fom" path="res://src/map/dungeon/door/Door.tscn" id="2_vpnlr"]
[ext_resource type="Script" path="res://src/map/dungeon/corridor/remove_unused_doors.gd" id="3_8i1ij"]
[ext_resource type="Texture2D" uid="uid://bidlc5a6lft6" path="res://src/map/dungeon/textures/map_brickwall.jpg" id="4_6qf87"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nsah4"]
transparency = 1
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_18cgv"]
albedo_texture = ExtResource("2_6scux")
uv1_scale = Vector3(0.23, 0.23, 0.23)
uv1_triplanar = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cquyy"]
albedo_texture = ExtResource("4_6qf87")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_67t3u"]
albedo_texture = ExtResource("4_6qf87")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ej8w2"]
albedo_texture = ExtResource("4_6qf87")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_oy7nu"]
albedo_texture = ExtResource("4_6qf87")
[node name="Corridor" type="Node3D"]
script = ExtResource("1_y0rqi")
[node name="CSGBox3D" type="CSGBox3D" parent="."]
use_collision = true
size = Vector3(10, 10, 10)
material = SubResource("StandardMaterial3D_nsah4")
[node name="CSGBox3D" type="CSGBox3D" parent="CSGBox3D"]
operation = 2
size = Vector3(9, 9, 9)
material = SubResource("StandardMaterial3D_18cgv")
[node name="DOOR?" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -5, -3.5, 0)
material = SubResource("StandardMaterial3D_cquyy")
[node name="DOOR?3" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 5, -3.5, 0)
material = SubResource("StandardMaterial3D_67t3u")
[node name="DOOR?4" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.5, 5)
material = SubResource("StandardMaterial3D_ej8w2")
[node name="DOOR?2" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.5, -5)
material = SubResource("StandardMaterial3D_oy7nu")
[node name="RemoveUnusedDoors" type="Node" parent="."]
script = ExtResource("3_8i1ij")

View File

@@ -0,0 +1,11 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$"..".connect("dungeon_done_generating", remove_unused_doors)
func remove_unused_doors():
for door in $"..".get_doors():
if door.get_room_leads_to() == null:
door.door_node.queue_free()

View File

@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://ckaw6wjmi0fom"]
[node name="DOOR" type="CSGBox3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.01493, 0)
operation = 2
size = Vector3(2, 2, 1)

View File

@@ -0,0 +1,30 @@
[gd_scene load_steps=5 format=3 uid="uid://dhpwwqow1ahrc"]
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_0tfda"]
[ext_resource type="PackedScene" uid="uid://ckaw6wjmi0fom" path="res://src/map/dungeon/door/Door.tscn" id="2_mdawx"]
[ext_resource type="Texture2D" uid="uid://bidlc5a6lft6" path="res://src/map/dungeon/textures/map_brickwall.jpg" id="2_rw3uc"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gt3ar"]
albedo_texture = ExtResource("2_rw3uc")
uv1_scale = Vector3(0.105, 0.105, 0.105)
uv1_triplanar = true
[node name="DungeonRoom3D" type="Node3D"]
script = ExtResource("1_0tfda")
[node name="CSGBox3D" type="CSGBox3D" parent="."]
material_override = SubResource("StandardMaterial3D_gt3ar")
use_collision = true
size = Vector3(10, 10, 10)
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGBox3D"]
material_override = SubResource("StandardMaterial3D_gt3ar")
operation = 2
use_collision = true
size = Vector3(9, 9, 9)
[node name="DOOR" parent="CSGBox3D" instance=ExtResource("2_mdawx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.47376, 4.74571)
[node name="DOOR2" parent="CSGBox3D" instance=ExtResource("2_mdawx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.51619, -4.73548)

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://baddk1soq2ske"]
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_o02dd"]
[node name="DungeonRoom3D" type="Node3D"]
script = ExtResource("1_o02dd")

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bidlc5a6lft6"
path.s3tc="res://.godot/imported/map_brickwall.jpg-769eb620c593a0c2aec11a51d3375aec.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://src/map/dungeon/textures/map_brickwall.jpg"
dest_files=["res://.godot/imported/map_brickwall.jpg-769eb620c593a0c2aec11a51d3375aec.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://n4ds85jp0aq0"
path.s3tc="res://.godot/imported/map_ceiling.jpg-206aba6e11eacf4f5f6696b3ba8e351a.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://src/map/dungeon/textures/map_ceiling.jpg"
dest_files=["res://.godot/imported/map_ceiling.jpg-206aba6e11eacf4f5f6696b3ba8e351a.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0