procedural map generation v1
title says all.
This commit is contained in:
parent
b164b513d7
commit
b7462b8b9d
18 changed files with 733 additions and 208 deletions
|
|
@ -6,13 +6,24 @@ var toggled: bool = false
|
|||
signal toggle(toggle: bool)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not Console.toggled:
|
||||
if Input.is_action_just_pressed("open_inventory"):
|
||||
if toggled:
|
||||
print("toggle off")
|
||||
UiManager.toggle_inventory_menu(false)
|
||||
toggle.emit(false)
|
||||
else:
|
||||
print("toggle on")
|
||||
UiManager.toggle_inventory_menu(true)
|
||||
toggle.emit(true)
|
||||
toggled = !toggled
|
||||
|
||||
#func _process(delta: float) -> void:
|
||||
#if Input.is_action_just_pressed("open_inventory"):
|
||||
#if toggled:
|
||||
#print("toggle off")
|
||||
#UiManager.toggle_inventory_menu(false)
|
||||
#toggle.emit(false)
|
||||
#else:
|
||||
#print("toggle on")
|
||||
#UiManager.toggle_inventory_menu(true)
|
||||
#toggle.emit(true)
|
||||
#toggled = !toggled
|
||||
|
|
|
|||
|
|
@ -48,14 +48,6 @@ func _ready() -> void:
|
|||
get_tree().create_timer(0.5).timeout.connect(func(): _player_spawned = true)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if Console.toggled or UiManager.in_game_menu.visible or UiManager.inventory_menu.visible:
|
||||
player.velocity.x = lerpf(player.velocity.x, 0, delta * 10)
|
||||
player.velocity.z = lerpf(player.velocity.z, 0, delta * 10)
|
||||
player.move_and_slide()
|
||||
return
|
||||
|
||||
mouse_motion.y = clamp(mouse_motion.y, -1560, 1560)
|
||||
|
||||
player.rotation.y = lerp_angle(player.rotation.y, mouse_motion.x * -0.001 * PlayerConsts.LOOK_SENSITIVITY, delta * 30)
|
||||
|
||||
var target_pitch = mouse_motion.y * -0.001 * PlayerConsts.LOOK_SENSITIVITY
|
||||
|
|
@ -63,6 +55,18 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
handle_joypad_movement()
|
||||
|
||||
if Console.toggled or UiManager.in_game_menu.visible or UiManager.inventory_menu.visible:
|
||||
player.velocity.x = lerpf(player.velocity.x, 0, delta * 10)
|
||||
player.velocity.z = lerpf(player.velocity.z, 0, delta * 10)
|
||||
player.move_and_slide()
|
||||
return
|
||||
|
||||
if %Noclip.is_noclip:
|
||||
%Noclip._process_noclip_movement(delta)
|
||||
return
|
||||
|
||||
mouse_motion.y = clamp(mouse_motion.y, -1560, 1560)
|
||||
|
||||
var was_on_floor: bool = player.is_on_floor()
|
||||
var fall_velocity: float = player.velocity.y
|
||||
|
||||
|
|
|
|||
48
entities/player/noclip.gd
Normal file
48
entities/player/noclip.gd
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
extends Node
|
||||
|
||||
@export_group("Noclip")
|
||||
@export var noclip_speed: float = 15.0
|
||||
@export var noclip_sprint_multiplier: float = 3.0
|
||||
|
||||
var is_noclip: bool = false
|
||||
|
||||
# Make sure these paths match your actual node setup!
|
||||
@export var head_camera: Camera3D
|
||||
@export var player_hitbox: CollisionShape3D
|
||||
@export var player: Player
|
||||
|
||||
func toggle():
|
||||
is_noclip = !is_noclip
|
||||
|
||||
# Disable physics collision so you pass through walls
|
||||
player_hitbox.disabled = is_noclip
|
||||
|
||||
# Reset velocity so you don't carry momentum when toggling it on/off
|
||||
player.velocity = Vector3.ZERO
|
||||
|
||||
print("Noclip: ", "ON" if is_noclip else "OFF")
|
||||
|
||||
func _process_noclip_movement(_delta: float) -> void:
|
||||
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
||||
|
||||
# Optional: Add keys to fly straight up and down (like Space and Ctrl)
|
||||
var vertical_input = Input.get_axis("crouch", "jump")
|
||||
|
||||
# Calculate direction based on the CAMERA'S rotation, not the body's!
|
||||
var cam_basis = head_camera.global_transform.basis
|
||||
var direction = (cam_basis * Vector3(input_dir.x, vertical_input, input_dir.y)).normalized()
|
||||
|
||||
# Calculate speed (allow sprinting while flying)
|
||||
var current_speed = noclip_speed
|
||||
if Input.is_action_pressed("sprint"):
|
||||
current_speed *= noclip_sprint_multiplier
|
||||
|
||||
# Apply movement instantly (no friction/acceleration smoothing)
|
||||
if direction != Vector3.ZERO:
|
||||
player.velocity = direction * current_speed
|
||||
else:
|
||||
player.velocity = Vector3.ZERO
|
||||
|
||||
# move_and_slide() still works perfectly!
|
||||
# Because collision_shape is disabled, it will just glide through everything.
|
||||
player.move_and_slide()
|
||||
1
entities/player/noclip.gd.uid
Normal file
1
entities/player/noclip.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bk20reld17wlp
|
||||
|
|
@ -19,6 +19,9 @@ class_name Player extends CharacterBody3D
|
|||
|
||||
static var player: Player
|
||||
|
||||
func toggle_noclip():
|
||||
%Noclip.toggle()
|
||||
|
||||
func _ready() -> void:
|
||||
Console.context["player"] = self
|
||||
GameState.player = self
|
||||
|
|
@ -47,6 +50,10 @@ func _ready() -> void:
|
|||
|
||||
stamina_component.stamina_changed.connect(ui.set_stamina)
|
||||
|
||||
SignalSniffer.watch(stamina_component)
|
||||
|
||||
# TODO: why is it always called on every frame?????
|
||||
|
||||
flashlight_component.flashlight_charge_changed.connect(ui.set_flashlight)
|
||||
flashlight_component.flashlight_toggled.connect(\
|
||||
func (success):\
|
||||
|
|
@ -65,13 +72,9 @@ func _ready() -> void:
|
|||
stamina_component.run(false))
|
||||
movement_component.state_changed.connect(player_state.handle_state_change)
|
||||
|
||||
SignalSniffer.watch(movement_component)
|
||||
|
||||
#temporary so i can prototype
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("open_inventory"):
|
||||
if UiManager.inventory_menu.visible:
|
||||
UiManager.toggle_inventory_menu(false)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
else:
|
||||
UiManager.toggle_inventory_menu(true)
|
||||
UiManager.inventory_menu.open_inventory(equipped_backpack, hotbar_component)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
UiManager.toggle_inventory_menu(equipped_backpack, hotbar_component)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
[ext_resource type="Script" uid="uid://2mpqfiofksnu" path="res://entities/player/hotbar_component.gd" id="10_ugbui"]
|
||||
[ext_resource type="Script" uid="uid://c32j8acbe3myf" path="res://entities/player/inventory_component.gd" id="11_b2kln"]
|
||||
[ext_resource type="Script" uid="uid://dntoi54g4hqce" path="res://entities/player/flashlight_component.gd" id="11_myrg7"]
|
||||
[ext_resource type="Script" uid="uid://bk20reld17wlp" path="res://entities/player/noclip.gd" id="12_b2kln"]
|
||||
[ext_resource type="Script" uid="uid://cdfis3askl3gb" path="res://entities/player/stamina_component.gd" id="12_kvlxm"]
|
||||
[ext_resource type="PackedScene" uid="uid://bmqm4andgetsd" path="res://entities/backpack/backpack_base.tscn" id="13_b2kln"]
|
||||
[ext_resource type="PackedScene" uid="uid://c02fkimxlbrje" path="res://entities/player/prompt.tscn" id="13_ugbui"]
|
||||
|
|
@ -111,6 +112,15 @@ script = ExtResource("12_kvlxm")
|
|||
unique_name_in_owner = true
|
||||
script = ExtResource("11_b2kln")
|
||||
|
||||
[node name="DevComponents" type="Node" parent="Components" unique_id=382197235]
|
||||
|
||||
[node name="Noclip" type="Node" parent="Components/DevComponents" unique_id=1210144577 node_paths=PackedStringArray("head_camera", "player_hitbox", "player")]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("12_b2kln")
|
||||
head_camera = NodePath("../../../CameraPivot/PlayerCamera")
|
||||
player_hitbox = NodePath("../../../PlayerHitBox")
|
||||
player = NodePath("../../..")
|
||||
|
||||
[node name="PlayerHitBox" type="CollisionShape3D" parent="." unique_id=1513955228]
|
||||
shape = SubResource("CapsuleShape3D_g4v7s")
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ func restart_timer():
|
|||
_timer.start()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if stamina_recharge and stamina <= 100:
|
||||
if stamina_recharge and stamina < 100:
|
||||
add_stamina(10 * delta)
|
||||
|
||||
if running and stamina > 0:
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ script = ExtResource("1_xccyg")
|
|||
|
||||
[node name="StaticBody3D3" type="StaticBody3D" parent="." unique_id=1155377467]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 1, -4.371139e-08, 4.371139e-08, 4.371139e-08, 1, 1.9106855e-15, -1.05, 1, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D3" unique_id=407288997]
|
||||
shape = SubResource("BoxShape3D_2uy16")
|
||||
|
|
@ -34,6 +36,8 @@ mesh = SubResource("BoxMesh_xccyg")
|
|||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="." unique_id=859289845]
|
||||
transform = Transform3D(-4.371139e-08, -4.371139e-08, 1, -1, 1.9106855e-15, -4.371139e-08, 0, -1, -4.371139e-08, 1.05, 1, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D2" unique_id=633037051]
|
||||
shape = SubResource("BoxShape3D_r2fmj")
|
||||
|
|
@ -43,6 +47,8 @@ mesh = SubResource("BoxMesh_t5b2u")
|
|||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=756323465]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 2.55, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=782523]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
|
@ -52,6 +58,8 @@ mesh = SubResource("BoxMesh_xccyg")
|
|||
|
||||
[node name="StaticBody3D4" type="StaticBody3D" parent="." unique_id=1520669484]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D4" unique_id=1344836418]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,178 @@
|
|||
[gd_scene format=3 uid="uid://bv6nflwc0fial"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cbpmudbod58kd" path="res://maps/procedural_map_parts_ver_premade/blocks/corridor_turn_base.gd" id="1_6u82c"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_wc7xr"]
|
||||
size = Vector3(2, 5.0625, 0.2)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_yjdan"]
|
||||
size = Vector3(2, 5.1452637, 0.1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_rq4n7"]
|
||||
size = Vector3(2, 3, 0.2)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_xccyg"]
|
||||
size = Vector3(2, 3, 0.1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_id5ww"]
|
||||
size = Vector3(2, 3.387207, 0.2)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_vav0j"]
|
||||
size = Vector3(2, 3.428955, 0.1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_8qdpf"]
|
||||
size = Vector3(2, 5.5, 0.2)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_wc7xr"]
|
||||
size = Vector3(2, 5.5, 0.1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_yjdan"]
|
||||
size = Vector3(2, 5.5, 0.2)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_eoxma"]
|
||||
size = Vector3(2, 5.5, 0.1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_eoxma"]
|
||||
size = Vector3(2, 5.5, 0.2)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_id5ww"]
|
||||
size = Vector3(2, 5.5, 0.1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_vav0j"]
|
||||
size = Vector3(2.5, 2.5, 5.283081)
|
||||
|
||||
[node name="CorridorBase" type="Node3D" unique_id=1244680281]
|
||||
script = ExtResource("1_6u82c")
|
||||
|
||||
[node name="Corridor1" type="Node3D" parent="." unique_id=1242077746]
|
||||
transform = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2.5)
|
||||
|
||||
[node name="StaticBody3D3" type="StaticBody3D" parent="Corridor1" unique_id=1155377467]
|
||||
transform = Transform3D(-5.4639237e-08, 0, 1, 1.25, -4.371139e-08, 4.371139e-08, 5.4639237e-08, 1, 1.9106855e-15, -1.05, 1.2, -1.25)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D3" unique_id=407288997]
|
||||
transform = Transform3D(1, 0, 8.351872e-23, 0, 1, 0, 8.351872e-23, 0, 1, 2.3841858e-07, 0.21875, 0)
|
||||
shape = SubResource("BoxShape3D_wc7xr")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor1/StaticBody3D3/CollisionShape3D" unique_id=105019814]
|
||||
transform = Transform3D(1, 0, 8.351872e-23, 0, 1, 0, 8.351872e-23, 0, 1, 0, -0.01184082, 0)
|
||||
mesh = SubResource("BoxMesh_yjdan")
|
||||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="Corridor1" unique_id=859289845]
|
||||
transform = Transform3D(-5.4639237e-08, -4.371139e-08, 1, -1.25, 1.9106855e-15, -4.371139e-08, 0, -1, -4.371139e-08, 1.05, 1.2, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D2" unique_id=633037051]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor1/StaticBody3D2/CollisionShape3D" unique_id=1052490442]
|
||||
mesh = SubResource("BoxMesh_xccyg")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="Corridor1" unique_id=756323465]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 2.45, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D" unique_id=782523]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor1/StaticBody3D/CollisionShape3D" unique_id=923270143]
|
||||
mesh = SubResource("BoxMesh_xccyg")
|
||||
|
||||
[node name="StaticBody3D4" type="StaticBody3D" parent="Corridor1" unique_id=1520669484]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D4" unique_id=1344836418]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor1/StaticBody3D4/CollisionShape3D" unique_id=1659980649]
|
||||
mesh = SubResource("BoxMesh_xccyg")
|
||||
|
||||
[node name="Corridor2" type="Node3D" parent="." unique_id=1985861702]
|
||||
transform = Transform3D(-4.3711392e-08, 0, -1, 0, 1, 0, -1.0000001, 0, 4.371139e-08, -3, 0, 0)
|
||||
|
||||
[node name="StaticBody3D3" type="StaticBody3D" parent="Corridor2" unique_id=1681537155]
|
||||
transform = Transform3D(-5.4639234e-08, 0, 1, 1.25, -4.371139e-08, 4.371139e-08, 5.4639237e-08, 1, 3.5527137e-15, -1.05, 1.2, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D3" unique_id=1519415059]
|
||||
transform = Transform3D(1, 1.6420284e-15, 0, 1.6420284e-15, 1, 0, 0, 0, 1, 0, -0.19360352, 0)
|
||||
shape = SubResource("BoxShape3D_id5ww")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor2/StaticBody3D3/CollisionShape3D" unique_id=1141271357]
|
||||
transform = Transform3D(1, 1.6420284e-15, 0, 1.6420284e-15, 1, 0, 0, 0, 1, 0, -0.028198242, 0)
|
||||
mesh = SubResource("BoxMesh_vav0j")
|
||||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="Corridor2" unique_id=1507709423]
|
||||
transform = Transform3D(-5.4639237e-08, -4.371139e-08, 1, -1.25, 1.9106855e-15, -4.371139e-08, -2.1175824e-22, -1, -4.371139e-08, 1.05, 1.2, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D2" unique_id=784288059]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2445676, 0)
|
||||
shape = SubResource("BoxShape3D_8qdpf")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor2/StaticBody3D2/CollisionShape3D" unique_id=2013590247]
|
||||
mesh = SubResource("BoxMesh_wc7xr")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="Corridor2" unique_id=1007808616]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 2.45, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D" unique_id=877001388]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 8.351872e-23, 0, 8.351872e-23, 1, -1.4210855e-14, 1.2611692, 4.7683716e-07)
|
||||
shape = SubResource("BoxShape3D_yjdan")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor2/StaticBody3D/CollisionShape3D" unique_id=1021558265]
|
||||
mesh = SubResource("BoxMesh_eoxma")
|
||||
|
||||
[node name="StaticBody3D4" type="StaticBody3D" parent="Corridor2" unique_id=1418330129]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D4" unique_id=808595951]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 8.351872e-23, 0, 8.351872e-23, 1, 0, 1.25, 0)
|
||||
shape = SubResource("BoxShape3D_eoxma")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Corridor2/StaticBody3D4/CollisionShape3D" unique_id=459119557]
|
||||
mesh = SubResource("BoxMesh_id5ww")
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="." unique_id=219693250]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 1, 0)
|
||||
billboard = 1
|
||||
text = "corridor turn left"
|
||||
|
||||
[node name="Label3D2" type="Label3D" parent="." unique_id=1062586634]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 3, 0)
|
||||
pixel_size = 0.01
|
||||
billboard = 1
|
||||
text = "corridor turn left"
|
||||
|
||||
[node name="Markers" type="Node3D" parent="." unique_id=93966280]
|
||||
|
||||
[node name="ConnectionMarker2" type="Marker3D" parent="Markers" unique_id=1537716366]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1.3113416e-07, 0, 1, 0, 1, 0, -1, 0, 1.3113416e-07, -4.5, 0, 0)
|
||||
|
||||
[node name="ConnectionMarker1" type="Marker3D" parent="Markers" unique_id=1839460414]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4)
|
||||
|
||||
[node name="Volume" type="Area3D" parent="." unique_id=239196824]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Volume" unique_id=1281526055]
|
||||
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 1, 1.1415405)
|
||||
shape = SubResource("BoxShape3D_vav0j")
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Volume" unique_id=334919096]
|
||||
transform = Transform3D(-3.4969112e-08, 0, 0.8, 0, 0.8, 0, -0.8, 0, -3.4969112e-08, -1.2706327, 1, 0.026144028)
|
||||
shape = SubResource("BoxShape3D_vav0j")
|
||||
|
|
@ -49,6 +49,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2.5)
|
|||
|
||||
[node name="StaticBody3D3" type="StaticBody3D" parent="Corridor1" unique_id=1155377467]
|
||||
transform = Transform3D(-5.4639237e-08, 0, 1, 1.25, -4.371139e-08, 4.371139e-08, 5.4639237e-08, 1, 1.9106855e-15, -1.05, 1.2, -1.25)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D3" unique_id=407288997]
|
||||
transform = Transform3D(1, 0, 8.351872e-23, 0, 1, 0, 8.351872e-23, 0, 1, 2.3841858e-07, 0.21875, 0)
|
||||
|
|
@ -60,6 +62,8 @@ mesh = SubResource("BoxMesh_yjdan")
|
|||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="Corridor1" unique_id=859289845]
|
||||
transform = Transform3D(-5.4639237e-08, -4.371139e-08, 1, -1.25, 1.9106855e-15, -4.371139e-08, 0, -1, -4.371139e-08, 1.05, 1.2, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D2" unique_id=633037051]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
|
@ -69,6 +73,8 @@ mesh = SubResource("BoxMesh_xccyg")
|
|||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="Corridor1" unique_id=756323465]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 2.45, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D" unique_id=782523]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
|
@ -78,6 +84,8 @@ mesh = SubResource("BoxMesh_xccyg")
|
|||
|
||||
[node name="StaticBody3D4" type="StaticBody3D" parent="Corridor1" unique_id=1520669484]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor1/StaticBody3D4" unique_id=1344836418]
|
||||
shape = SubResource("BoxShape3D_rq4n7")
|
||||
|
|
@ -90,6 +98,8 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 3, 0
|
|||
|
||||
[node name="StaticBody3D3" type="StaticBody3D" parent="Corridor2" unique_id=1681537155]
|
||||
transform = Transform3D(-5.4639234e-08, 0, 1, 1.25, -4.371139e-08, 4.371139e-08, 5.4639237e-08, 1, 3.5527137e-15, -1.05, 1.2, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D3" unique_id=1519415059]
|
||||
transform = Transform3D(1, 1.6420284e-15, 0, 1.6420284e-15, 1, 0, 0, 0, 1, 0, -0.19360352, 0)
|
||||
|
|
@ -101,6 +111,8 @@ mesh = SubResource("BoxMesh_vav0j")
|
|||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="Corridor2" unique_id=1507709423]
|
||||
transform = Transform3D(-5.4639237e-08, -4.371139e-08, 1, -1.25, 1.9106855e-15, -4.371139e-08, -2.1175824e-22, -1, -4.371139e-08, 1.05, 1.2, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D2" unique_id=784288059]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2445676, 0)
|
||||
|
|
@ -111,6 +123,8 @@ mesh = SubResource("BoxMesh_wc7xr")
|
|||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="Corridor2" unique_id=1007808616]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 2.45, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D" unique_id=877001388]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 8.351872e-23, 0, 8.351872e-23, 1, -1.4210855e-14, 1.2611692, 4.7683716e-07)
|
||||
|
|
@ -121,6 +135,8 @@ mesh = SubResource("BoxMesh_eoxma")
|
|||
|
||||
[node name="StaticBody3D4" type="StaticBody3D" parent="Corridor2" unique_id=1418330129]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Corridor2/StaticBody3D4" unique_id=808595951]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 8.351872e-23, 0, 8.351872e-23, 1, 0, 1.25, 0)
|
||||
|
|
@ -132,13 +148,13 @@ mesh = SubResource("BoxMesh_id5ww")
|
|||
[node name="Label3D" type="Label3D" parent="." unique_id=219693250]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 1, 0)
|
||||
billboard = 1
|
||||
text = "corridor turn"
|
||||
text = "corridor turn right"
|
||||
|
||||
[node name="Label3D2" type="Label3D" parent="." unique_id=1062586634]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 3, 0)
|
||||
pixel_size = 0.01
|
||||
billboard = 1
|
||||
text = "corridor turn"
|
||||
text = "corridor turn right"
|
||||
|
||||
[node name="Markers" type="Node3D" parent="." unique_id=93966280]
|
||||
|
||||
|
|
@ -1,4 +1,9 @@
|
|||
extends Node3D
|
||||
class_name ProceduralMapGenerator
|
||||
|
||||
@export_group("Player")
|
||||
@export var player_scene: PackedScene
|
||||
@export var player_spawn_height: float = 1.5
|
||||
|
||||
@export_group("Map Pieces")
|
||||
@export var start_room_scene: PackedScene
|
||||
|
|
@ -6,10 +11,11 @@ extends Node3D
|
|||
@export var room_scenes: Array[PackedScene]
|
||||
@export var corridor_scenes: Array[PackedScene]
|
||||
|
||||
@export_group("Generation Rules")
|
||||
@export_range(0.0, 1.0) var corridor_chance: float = 0.5
|
||||
@export var room_threshold: int = 15
|
||||
@export_range(0.0, 1.0) var stop_chance_step: float = 0.1
|
||||
@export_group("Vining Rules")
|
||||
@export var max_attempts: int = 2000
|
||||
@export var room_threshold: int = 20
|
||||
@export var min_corridor_chain: int = 1
|
||||
@export var max_corridor_chain: int = 4
|
||||
|
||||
var generated_rooms: Array[Node3D] = []
|
||||
var open_connections: Array[Dictionary] = []
|
||||
|
|
@ -18,32 +24,7 @@ var total_pieces: int = 0
|
|||
func _ready() -> void:
|
||||
generate_map()
|
||||
|
||||
func draw_connection_laser(pos1: Vector3, pos2: Vector3):
|
||||
var mesh_instance = MeshInstance3D.new()
|
||||
var cylinder = CylinderMesh.new()
|
||||
|
||||
# Make a thin, long laser beam
|
||||
cylinder.top_radius = 0.05
|
||||
cylinder.bottom_radius = 0.05
|
||||
cylinder.height = pos1.distance_to(pos2)
|
||||
|
||||
var material = StandardMaterial3D.new()
|
||||
material.albedo_color = Color.GREEN
|
||||
material.emission_enabled = true
|
||||
material.emission = Color.GREEN
|
||||
cylinder.surface_set_material(0, material)
|
||||
|
||||
mesh_instance.mesh = cylinder
|
||||
get_tree().current_scene.add_child(mesh_instance)
|
||||
|
||||
# Position it exactly between the two markers and make it look at the target
|
||||
mesh_instance.global_position = pos1.lerp(pos2, 0.5)
|
||||
mesh_instance.look_at(pos2, Vector3.UP)
|
||||
|
||||
# Cylinder meshes stand up (Y) by default, we need it to point forward (Z)
|
||||
mesh_instance.rotate_object_local(Vector3.RIGHT, PI/2)
|
||||
|
||||
func generate_map():
|
||||
func generate_map() -> void:
|
||||
if not start_room_scene or not cap_scene:
|
||||
push_error("MapGenerator needs both a Start Room Scene and a Cap Scene!")
|
||||
return
|
||||
|
|
@ -51,175 +32,300 @@ func generate_map():
|
|||
var start_room = start_room_scene.instantiate()
|
||||
add_child(start_room)
|
||||
generated_rooms.append(start_room)
|
||||
add_open_connections(start_room, "room")
|
||||
_register_open_connections(start_room, "room", 0, 0)
|
||||
total_pieces += 1
|
||||
|
||||
var attempts = 0
|
||||
|
||||
while open_connections.size() > 0 and attempts < 2000:
|
||||
while open_connections.size() > 0 and attempts < max_attempts:
|
||||
attempts += 1
|
||||
var target_dict = open_connections.pop_back()
|
||||
|
||||
var target_dict = open_connections.pick_random()
|
||||
var target_marker = target_dict["marker"]
|
||||
var target_type = target_dict["type"]
|
||||
|
||||
if is_marker_blocked(target_marker):
|
||||
open_connections.erase(target_dict)
|
||||
var target_marker: Node3D = target_dict["marker"]
|
||||
if _is_marker_blocked(target_marker):
|
||||
continue
|
||||
|
||||
# 1. Decide what category we are TRYING to spawn
|
||||
var spawn_category = "room"
|
||||
var cap_probability = 0.0
|
||||
if total_pieces > room_threshold:
|
||||
cap_probability = (total_pieces - room_threshold) * stop_chance_step
|
||||
var categories_to_try = _get_desired_categories(target_dict)
|
||||
var placed = false
|
||||
|
||||
if randf() < cap_probability:
|
||||
spawn_category = "cap"
|
||||
elif target_type == "room" and randf() < corridor_chance and corridor_scenes.size() > 0:
|
||||
spawn_category = "corridor"
|
||||
|
||||
# 2. Gather all scenes for that category and SHUFFLE them
|
||||
var scenes_to_try = []
|
||||
if spawn_category == "cap":
|
||||
scenes_to_try = [cap_scene]
|
||||
elif spawn_category == "corridor":
|
||||
scenes_to_try = corridor_scenes.duplicate()
|
||||
scenes_to_try.shuffle() # Randomize the order we try the corridors
|
||||
else:
|
||||
scenes_to_try = room_scenes.duplicate()
|
||||
scenes_to_try.shuffle() # Randomize the order we try the rooms
|
||||
|
||||
var placed_successfully = false
|
||||
|
||||
# 3. Try EVERY scene until one fits
|
||||
for scene in scenes_to_try:
|
||||
if placed_successfully:
|
||||
# Try to place pieces cleanly
|
||||
for category in categories_to_try:
|
||||
if _try_place_category(category, target_dict):
|
||||
placed = true
|
||||
break
|
||||
|
||||
var new_room = scene.instantiate()
|
||||
add_child(new_room)
|
||||
# THE ABSOLUTE FAILSAFE:
|
||||
# If it's a dead end and nothing fits cleanly, FORCE a cap so there are no voids!
|
||||
if not placed:
|
||||
_force_cap_on_marker(target_dict)
|
||||
|
||||
var new_room_markers = new_room.connection_markers.duplicate()
|
||||
if new_room_markers.is_empty():
|
||||
new_room.free()
|
||||
continue
|
||||
|
||||
new_room_markers.shuffle() # Try the new room's doors in random order too!
|
||||
|
||||
# 4. Try EVERY door on the chosen scene
|
||||
for incoming_marker in new_room_markers:
|
||||
align_room(new_room, incoming_marker, target_marker)
|
||||
|
||||
var overlaps = false
|
||||
for existing_room in generated_rooms:
|
||||
if do_rooms_overlap(new_room, existing_room):
|
||||
overlaps = true
|
||||
break
|
||||
|
||||
if not overlaps:
|
||||
# IT FITS! Lock it in.
|
||||
generated_rooms.append(new_room)
|
||||
|
||||
# DRAW THE LASER!
|
||||
draw_connection_laser(target_marker.global_position, new_room.global_position)
|
||||
total_pieces += 1
|
||||
|
||||
open_connections.erase(target_dict)
|
||||
new_room_markers.erase(incoming_marker)
|
||||
|
||||
for marker in new_room_markers:
|
||||
open_connections.append({"marker": marker, "type": spawn_category})
|
||||
|
||||
placed_successfully = true
|
||||
break # Break out of the door loop
|
||||
|
||||
if not placed_successfully:
|
||||
new_room.free() # None of the doors on this scene fit, destroy it and try the next scene
|
||||
|
||||
# 5. Failsafe: If literally NO room and NO door fits in this spot, CAP IT instantly!
|
||||
if not placed_successfully and spawn_category != "cap":
|
||||
force_cap_on_marker(target_dict)
|
||||
|
||||
seal_remaining_connections()
|
||||
_seal_remaining_connections()
|
||||
_cull_clipping_caps()
|
||||
print("Map Generation Complete! Total pieces: ", total_pieces)
|
||||
|
||||
# Spawn the Player!
|
||||
if player_scene and generated_rooms.size() > 0:
|
||||
var player = player_scene.instantiate()
|
||||
get_tree().current_scene.add_child(player)
|
||||
player.global_position = generated_rooms[0].global_position + Vector3(0, player_spawn_height, 0)
|
||||
|
||||
func force_cap_on_marker(target_dict: Dictionary):
|
||||
var target_marker = target_dict["marker"]
|
||||
var cap = cap_scene.instantiate()
|
||||
add_child(cap)
|
||||
var incoming_marker = cap.connection_markers[0]
|
||||
align_room(cap, incoming_marker, target_marker)
|
||||
generated_rooms.append(cap)
|
||||
open_connections.erase(target_dict)
|
||||
# --- VINING LOGIC ---
|
||||
|
||||
func _get_desired_categories(target_dict: Dictionary) -> Array[String]:
|
||||
if total_pieces >= room_threshold:
|
||||
return ["cap"]
|
||||
|
||||
func seal_remaining_connections():
|
||||
for i in range(open_connections.size() - 1, -1, -1):
|
||||
var target_dict = open_connections[i]
|
||||
var target_marker = target_dict["marker"]
|
||||
var current = target_dict["current_chain"]
|
||||
var target = target_dict["target_chain"]
|
||||
|
||||
if is_marker_blocked(target_marker):
|
||||
open_connections.remove_at(i)
|
||||
if current < target:
|
||||
return ["corridor", "room", "cap"]
|
||||
else:
|
||||
return ["room", "cap"]
|
||||
|
||||
func _register_open_connections(room: Node3D, type: String, current_chain: int, target_chain: int) -> void:
|
||||
var markers = _get_connection_markers(room)
|
||||
for marker in markers:
|
||||
var next_current = current_chain
|
||||
var next_target = target_chain
|
||||
|
||||
if type == "room":
|
||||
next_current = 0
|
||||
next_target = randi_range(min_corridor_chain, max_corridor_chain)
|
||||
elif type == "corridor":
|
||||
next_current += 1
|
||||
|
||||
open_connections.append({
|
||||
"marker": marker,
|
||||
"type": type,
|
||||
"current_chain": next_current,
|
||||
"target_chain": next_target
|
||||
})
|
||||
|
||||
# --- PLACEMENT LOGIC ---
|
||||
|
||||
func _try_place_category(category: String, target_dict: Dictionary) -> bool:
|
||||
var target_marker: Node3D = target_dict["marker"]
|
||||
var scenes_to_try: Array[PackedScene] = []
|
||||
|
||||
match category:
|
||||
"cap": scenes_to_try = [cap_scene]
|
||||
"corridor": scenes_to_try = corridor_scenes.duplicate()
|
||||
"room": scenes_to_try = room_scenes.duplicate()
|
||||
|
||||
scenes_to_try.shuffle()
|
||||
|
||||
for scene in scenes_to_try:
|
||||
var new_room = scene.instantiate()
|
||||
var new_room_markers = _get_connection_markers(new_room)
|
||||
|
||||
if new_room_markers.is_empty() and category != "cap":
|
||||
new_room.queue_free()
|
||||
continue
|
||||
|
||||
force_cap_on_marker(target_dict)
|
||||
new_room_markers.shuffle()
|
||||
|
||||
if new_room_markers.is_empty() and category == "cap":
|
||||
_align_room(new_room, new_room, target_marker)
|
||||
if not _do_rooms_overlap(new_room):
|
||||
_lock_in_piece(new_room, category, [], target_dict)
|
||||
return true
|
||||
new_room.queue_free()
|
||||
continue
|
||||
|
||||
for incoming_marker in new_room_markers:
|
||||
_align_room(new_room, incoming_marker, target_marker)
|
||||
|
||||
if not _do_rooms_overlap(new_room):
|
||||
if _can_seal_outgoing_doors(new_room, incoming_marker):
|
||||
var remaining_markers = new_room_markers.duplicate()
|
||||
remaining_markers.erase(incoming_marker)
|
||||
_lock_in_piece(new_room, category, remaining_markers, target_dict)
|
||||
return true
|
||||
|
||||
new_room.queue_free()
|
||||
return false
|
||||
|
||||
func _lock_in_piece(new_room: Node3D, category: String, remaining_markers: Array, target_dict: Dictionary) -> void:
|
||||
add_child(new_room)
|
||||
generated_rooms.append(new_room)
|
||||
total_pieces += 1
|
||||
|
||||
if category == "cap":
|
||||
new_room.set_meta("is_cap", true) # TAG THE CAP!
|
||||
else:
|
||||
new_room.set_meta("temp_markers", remaining_markers)
|
||||
_register_open_connections(new_room, category, target_dict["current_chain"], target_dict["target_chain"])
|
||||
new_room.remove_meta("temp_markers")
|
||||
|
||||
func _force_cap_on_marker(target_dict: Dictionary) -> void:
|
||||
var target_marker = target_dict["marker"]
|
||||
var cap = cap_scene.instantiate()
|
||||
var markers = _get_connection_markers(cap)
|
||||
|
||||
if markers.size() > 0:
|
||||
_align_room(cap, markers[0], target_marker)
|
||||
else:
|
||||
_align_room(cap, cap, target_marker)
|
||||
|
||||
add_child(cap)
|
||||
cap.set_meta("is_cap", true) # TAG THE FORCED CAP!
|
||||
generated_rooms.append(cap)
|
||||
total_pieces += 1
|
||||
|
||||
func _can_seal_outgoing_doors(new_room: Node3D, incoming_marker: Node3D) -> bool:
|
||||
var markers = _get_connection_markers(new_room)
|
||||
for out_marker in markers:
|
||||
if out_marker == incoming_marker: continue
|
||||
|
||||
var test_cap = cap_scene.instantiate()
|
||||
var cap_markers = _get_connection_markers(test_cap)
|
||||
var cap_fits = false
|
||||
|
||||
if cap_markers.size() > 0:
|
||||
_align_room(test_cap, cap_markers[0], out_marker)
|
||||
if not _do_rooms_overlap(test_cap): cap_fits = true
|
||||
else:
|
||||
_align_room(test_cap, test_cap, out_marker)
|
||||
if not _do_rooms_overlap(test_cap): cap_fits = true
|
||||
|
||||
test_cap.queue_free()
|
||||
if not cap_fits: return false
|
||||
return true
|
||||
|
||||
func _seal_remaining_connections() -> void:
|
||||
for i in range(open_connections.size() - 1, -1, -1):
|
||||
var target_dict = open_connections[i]
|
||||
if not _is_marker_blocked(target_dict["marker"]):
|
||||
if not _try_place_category("cap", target_dict):
|
||||
_force_cap_on_marker(target_dict)
|
||||
open_connections.clear()
|
||||
|
||||
# --- MATH & BOUNDS ---
|
||||
|
||||
func add_open_connections(room: Node3D, type: String):
|
||||
if room.connection_markers != null:
|
||||
for marker in room.connection_markers:
|
||||
open_connections.append({"marker": marker, "type": type})
|
||||
func _align_room(new_room: Node3D, incoming_marker: Node3D, target_marker: Node3D) -> void:
|
||||
var target_global = _get_safe_global_transform(target_marker)
|
||||
var desired_incoming_transform = target_global.rotated_local(Vector3.UP, PI)
|
||||
|
||||
var room_to_marker = incoming_marker.transform
|
||||
var parent = incoming_marker.get_parent()
|
||||
while parent and parent is Node3D and parent != new_room:
|
||||
room_to_marker = parent.transform * room_to_marker
|
||||
parent = parent.get_parent()
|
||||
|
||||
func is_marker_blocked(marker: Marker3D) -> bool:
|
||||
for room in generated_rooms:
|
||||
var aabb = get_room_global_aabb(room)
|
||||
aabb.position += Vector3(0.1, 0.1, 0.1)
|
||||
aabb.size -= Vector3(0.2, 0.2, 0.2)
|
||||
new_room.transform = desired_incoming_transform * room_to_marker.affine_inverse()
|
||||
|
||||
if aabb.has_point(marker.global_position):
|
||||
func _do_rooms_overlap(new_room: Node3D) -> bool:
|
||||
var aabb_new = _get_room_global_aabb(new_room)
|
||||
if aabb_new.size == Vector3.ZERO: return false
|
||||
|
||||
aabb_new = _safe_shrink_aabb(aabb_new, 0.1)
|
||||
if aabb_new.size == Vector3.ZERO: return false
|
||||
|
||||
for existing_room in generated_rooms:
|
||||
var aabb_existing = _get_room_global_aabb(existing_room)
|
||||
if aabb_existing.size != Vector3.ZERO:
|
||||
aabb_existing = _safe_shrink_aabb(aabb_existing, 0.1)
|
||||
if aabb_new.intersects(aabb_existing):
|
||||
return true
|
||||
return false
|
||||
|
||||
# Godot 4 native bounding box shrinking
|
||||
func _safe_shrink_aabb(aabb: AABB, shrink_by: float) -> AABB:
|
||||
var new_aabb = aabb.grow(-shrink_by)
|
||||
# Prevent negative sizes which break overlap physics
|
||||
if new_aabb.size.x <= 0 or new_aabb.size.y <= 0 or new_aabb.size.z <= 0:
|
||||
return AABB(aabb.position, Vector3.ZERO)
|
||||
return new_aabb
|
||||
|
||||
func align_room(new_room: Node3D, incoming_marker: Marker3D, target_marker: Marker3D):
|
||||
var desired_incoming_transform = target_marker.global_transform.rotated_local(Vector3.UP, PI)
|
||||
var room_to_marker = new_room.global_transform.affine_inverse() * incoming_marker.global_transform
|
||||
new_room.global_transform = desired_incoming_transform * room_to_marker.affine_inverse()
|
||||
|
||||
|
||||
func do_rooms_overlap(room_a: Node3D, room_b: Node3D) -> bool:
|
||||
var aabb_a = get_room_global_aabb(room_a)
|
||||
var aabb_b = get_room_global_aabb(room_b)
|
||||
|
||||
if aabb_a.size == Vector3.ZERO or aabb_b.size == Vector3.ZERO:
|
||||
return false
|
||||
|
||||
# Increased the margin slightly to ensure corridors pass smoothly
|
||||
var shrink_margin = Vector3(0.2, 0.2, 0.2)
|
||||
aabb_a.position += shrink_margin / 2.0
|
||||
aabb_a.size -= shrink_margin
|
||||
|
||||
return aabb_a.intersects(aabb_b)
|
||||
|
||||
|
||||
func get_room_global_aabb(room: Node3D) -> AABB:
|
||||
func _get_room_global_aabb(room: Node3D) -> AABB:
|
||||
var combined_aabb := AABB()
|
||||
var is_first_shape = true
|
||||
var volume_node = room.get_node_or_null("Volume")
|
||||
if not volume_node: return combined_aabb
|
||||
|
||||
for child in room.volume.get_children():
|
||||
for child in volume_node.get_children():
|
||||
if child is CollisionShape3D and child.shape is BoxShape3D:
|
||||
var shape = child.shape as BoxShape3D
|
||||
var local_aabb = AABB(-shape.size / 2.0, shape.size)
|
||||
var global_aabb = child.global_transform * local_aabb
|
||||
var child_global_t = _get_safe_global_transform(child)
|
||||
var global_aabb = child_global_t * local_aabb
|
||||
|
||||
if is_first_shape:
|
||||
combined_aabb = global_aabb
|
||||
is_first_shape = false
|
||||
else:
|
||||
combined_aabb = combined_aabb.merge(global_aabb)
|
||||
|
||||
return combined_aabb
|
||||
|
||||
func _is_marker_blocked(marker: Node3D) -> bool:
|
||||
for room in generated_rooms:
|
||||
var aabb = _get_room_global_aabb(room)
|
||||
if aabb.size != Vector3.ZERO:
|
||||
aabb = _safe_shrink_aabb(aabb, 0.1)
|
||||
if aabb.has_point(marker.global_position): return true
|
||||
return false
|
||||
|
||||
func _get_connection_markers(room: Node3D) -> Array:
|
||||
if room.has_meta("temp_markers"): return room.get_meta("temp_markers")
|
||||
var markers = []
|
||||
_find_markers_recursive(room, markers)
|
||||
return markers
|
||||
|
||||
func _find_markers_recursive(node: Node, markers: Array) -> void:
|
||||
var is_valid_door = false
|
||||
if node is Marker3D:
|
||||
is_valid_door = true
|
||||
elif node is Node3D and ("Marker" in node.name or "WallHole" in node.name):
|
||||
is_valid_door = true
|
||||
|
||||
if is_valid_door and not markers.has(node):
|
||||
markers.append(node)
|
||||
return # Prevents doubling-up if a WallHole contains a Marker inside it!
|
||||
|
||||
for child in node.get_children():
|
||||
_find_markers_recursive(child, markers)
|
||||
|
||||
func _get_safe_global_transform(node: Node3D) -> Transform3D:
|
||||
if node.is_inside_tree(): return node.global_transform
|
||||
var t = node.transform
|
||||
var parent = node.get_parent()
|
||||
while parent and parent is Node3D:
|
||||
t = parent.transform * t
|
||||
parent = parent.get_parent()
|
||||
return t
|
||||
|
||||
func _cull_clipping_caps() -> void:
|
||||
# Loop backward so we can safely delete items from the array while iterating
|
||||
for i in range(generated_rooms.size() - 1, -1, -1):
|
||||
var room = generated_rooms[i]
|
||||
|
||||
# Only check the pieces we explicitly tagged as caps
|
||||
if room.has_meta("is_cap"):
|
||||
var cap_aabb = _get_room_global_aabb(room)
|
||||
if cap_aabb.size == Vector3.ZERO: continue
|
||||
|
||||
var is_clipping = false
|
||||
|
||||
# Check this cap against every other room in the map
|
||||
for j in range(generated_rooms.size()):
|
||||
if i == j: continue
|
||||
|
||||
var other_room = generated_rooms[j]
|
||||
var other_aabb = _get_room_global_aabb(other_room)
|
||||
|
||||
if other_aabb.size != Vector3.ZERO:
|
||||
# Shrink the other room's AABB.
|
||||
# This ensures caps sitting perfectly on the edge are ignored,
|
||||
# but caps shoved through the wall are caught!
|
||||
other_aabb = _safe_shrink_aabb(other_aabb, 0.4)
|
||||
|
||||
if other_aabb.size != Vector3.ZERO and cap_aabb.intersects(other_aabb):
|
||||
is_clipping = true
|
||||
break
|
||||
|
||||
# If it's inside another room, destroy it!
|
||||
if is_clipping:
|
||||
room.queue_free()
|
||||
generated_rooms.remove_at(i)
|
||||
total_pieces -= 1
|
||||
|
|
|
|||
|
|
@ -2,25 +2,33 @@
|
|||
|
||||
[ext_resource type="Script" uid="uid://dqddq642yha0o" path="res://maps/procedural_map_parts_ver_premade/map_generator.gd" id="1_oa821"]
|
||||
[ext_resource type="PackedScene" uid="uid://cm24rsfnjw4ok" path="res://maps/procedural_map_parts_ver_premade/parts/big_part.tscn" id="1_ywphk"]
|
||||
[ext_resource type="PackedScene" uid="uid://kqq30y24c6kd" path="res://entities/player/player.tscn" id="2_hajlu"]
|
||||
[ext_resource type="PackedScene" uid="uid://doddrjiew6eov" path="res://maps/procedural_map_parts_ver_premade/parts/end_part.tscn" id="3_dpdkl"]
|
||||
[ext_resource type="PackedScene" uid="uid://do7paidwkyx2e" path="res://maps/procedural_map_parts_ver_premade/parts/medium_part.tscn" id="4_vnae6"]
|
||||
[ext_resource type="PackedScene" uid="uid://tap7imlv8vb0" path="res://maps/procedural_map_parts_ver_premade/parts/small_part.tscn" id="5_s0fpg"]
|
||||
[ext_resource type="PackedScene" uid="uid://bqi71jcv228ha" path="res://maps/procedural_map_parts_ver_premade/blocks/corridor_base.tscn" id="6_nd2uf"]
|
||||
[ext_resource type="PackedScene" uid="uid://72meffei7m1x" path="res://maps/procedural_map_parts_ver_premade/blocks/corridor_turn_base.tscn" id="7_l0kyl"]
|
||||
[ext_resource type="PackedScene" uid="uid://72meffei7m1x" path="res://maps/procedural_map_parts_ver_premade/blocks/corridor_turn_right_base.tscn" id="7_l0kyl"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_b5l5s"]
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_hajlu"]
|
||||
sky_energy_multiplier = 0.0
|
||||
|
||||
[sub_resource type="Sky" id="Sky_tk8is"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_hajlu")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_bxagf"]
|
||||
background_mode = 5
|
||||
sky = SubResource("Sky_tk8is")
|
||||
reflected_light_source = 1
|
||||
sdfgi_use_occlusion = true
|
||||
|
||||
[node name="MapGenerator" type="Node3D" unique_id=1303087176]
|
||||
script = ExtResource("1_oa821")
|
||||
start_room_scene = ExtResource("1_ywphk")
|
||||
player_scene = ExtResource("2_hajlu")
|
||||
player_spawn_height = 3.0
|
||||
start_room_scene = ExtResource("4_vnae6")
|
||||
cap_scene = ExtResource("3_dpdkl")
|
||||
room_scenes = Array[PackedScene]([ExtResource("1_ywphk"), ExtResource("4_vnae6"), ExtResource("5_s0fpg")])
|
||||
corridor_scenes = Array[PackedScene]([ExtResource("6_nd2uf"), ExtResource("7_l0kyl")])
|
||||
corridor_chance = 0.523
|
||||
stop_chance_step = 0.3
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1248557197]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 53.35144, 0)
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="Camera3D" unique_id=1308284335]
|
||||
environment = SubResource("Environment_b5l5s")
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1308284335]
|
||||
environment = SubResource("Environment_bxagf")
|
||||
|
|
|
|||
|
|
@ -31,18 +31,28 @@ transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 10.4
|
|||
|
||||
[node name="WallBase7" parent="Walls/BiiigWall" unique_id=156284319 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 3.9600003, 0, 3.496911e-07, 0, 0.9999998, 15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase14" parent="Walls/BiiigWall" unique_id=1808172169 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, 10.498831, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase28" parent="Walls/BiiigWall" unique_id=1713653384 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 4.0035005, 0, 3.496911e-07, 0, 0.9999998, -15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase32" parent="Walls/BiiigWall" unique_id=934204351 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(6.16, 0, -1.7484541e-07, 0, 4.05, 0, 1.0770486e-06, 0, 0.9999992, 0, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase36" parent="Walls/BiiigWall" unique_id=1235068910 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, -10.501167, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="BiiigWall2" type="Node3D" parent="Walls" unique_id=650435345]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0.5, 0)
|
||||
|
|
@ -57,18 +67,28 @@ transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 10.4
|
|||
|
||||
[node name="WallBase7" parent="Walls/BiiigWall2" unique_id=1490575404 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 3.9600003, 0, 3.496911e-07, 0, 0.9999998, 15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase14" parent="Walls/BiiigWall2" unique_id=1414730758 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, 10.498831, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase28" parent="Walls/BiiigWall2" unique_id=398712345 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 4.0035005, 0, 3.496911e-07, 0, 0.9999998, -15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase32" parent="Walls/BiiigWall2" unique_id=393456469 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(6.16, 0, -1.7484541e-07, 0, 4.05, 0, 1.0770486e-06, 0, 0.9999992, 0, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase36" parent="Walls/BiiigWall2" unique_id=1856153119 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, -10.501167, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="BiiigWall3" type="Node3D" parent="Walls" unique_id=1154496094]
|
||||
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0.5, 0)
|
||||
|
|
@ -83,18 +103,28 @@ transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 10.4
|
|||
|
||||
[node name="WallBase7" parent="Walls/BiiigWall3" unique_id=1764650462 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 3.9600003, 0, 3.496911e-07, 0, 0.9999998, 15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase14" parent="Walls/BiiigWall3" unique_id=1912856173 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, 10.498831, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase28" parent="Walls/BiiigWall3" unique_id=622765899 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 4.0035005, 0, 3.496911e-07, 0, 0.9999998, -15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase32" parent="Walls/BiiigWall3" unique_id=569931776 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(6.16, 0, -1.7484541e-07, 0, 4.05, 0, 1.0770486e-06, 0, 0.9999992, 0, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase36" parent="Walls/BiiigWall3" unique_id=1424457871 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, -10.501167, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="BiiigWall4" type="Node3D" parent="Walls" unique_id=2106150262]
|
||||
transform = Transform3D(1.3113416e-07, 0, 1, 0, 1, 0, -1, 0, 1.3113416e-07, 0, 0.5, 0)
|
||||
|
|
@ -109,20 +139,32 @@ transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 10.4
|
|||
|
||||
[node name="WallBase7" parent="Walls/BiiigWall4" unique_id=38896772 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 3.9600003, 0, 3.496911e-07, 0, 0.9999998, 15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase14" parent="Walls/BiiigWall4" unique_id=1588817707 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, 10.498831, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase28" parent="Walls/BiiigWall4" unique_id=1844881760 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(2, 0, -1.7484552e-07, 0, 4.0035005, 0, 3.496911e-07, 0, 0.9999998, -15, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase32" parent="Walls/BiiigWall4" unique_id=1280563607 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(6.16, 0, -1.7484541e-07, 0, 4.05, 0, 1.0770486e-06, 0, 0.9999992, 0, 5.5, 18)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase36" parent="Walls/BiiigWall4" unique_id=535457386 instance=ExtResource("1_3yqjc")]
|
||||
transform = Transform3D(1, 0, -1.7484555e-07, 0, 3.0069256, 0, 1.7484555e-07, 0, 1, -10.501167, 7, 17.999584)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="Walls" unique_id=627574478]
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/StaticBody3D" unique_id=1587727920]
|
||||
shape = SubResource("BoxShape3D_b5l5s")
|
||||
|
|
@ -148,6 +190,26 @@ pixel_size = 0.1
|
|||
billboard = 1
|
||||
text = "Big part"
|
||||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="." unique_id=1680502971]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, -10, 11.499046, 9)
|
||||
spot_range = 18.55306
|
||||
spot_angle = 73.125
|
||||
|
||||
[node name="SpotLight3D2" type="SpotLight3D" parent="." unique_id=2020319668]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 9, 11.095684, 9)
|
||||
spot_range = 18.55306
|
||||
spot_angle = 73.125
|
||||
|
||||
[node name="SpotLight3D3" type="SpotLight3D" parent="." unique_id=299944414]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 9, 11.095684, -9)
|
||||
spot_range = 18.55306
|
||||
spot_angle = 73.125
|
||||
|
||||
[node name="SpotLight3D4" type="SpotLight3D" parent="." unique_id=1550519126]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, -6, 11.095684, -9)
|
||||
spot_range = 18.55306
|
||||
spot_angle = 73.125
|
||||
|
||||
[node name="Volume" type="Area3D" parent="." unique_id=2146805842]
|
||||
unique_name_in_owner = true
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ script = ExtResource("1_rm6ay")
|
|||
|
||||
[node name="Wall" type="StaticBody3D" parent="Walls" unique_id=1096881998]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Wall" unique_id=1704959952]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1.5)
|
||||
|
|
@ -29,6 +31,8 @@ mesh = SubResource("BoxMesh_b5l5s")
|
|||
|
||||
[node name="Wall2" type="StaticBody3D" parent="Walls" unique_id=1708831491]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Wall2" unique_id=2076268913]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1.5)
|
||||
|
|
@ -39,6 +43,8 @@ mesh = SubResource("BoxMesh_b5l5s")
|
|||
|
||||
[node name="Wall3" type="StaticBody3D" parent="Walls" unique_id=1464090892]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Wall3" unique_id=813882010]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 2.5, 0)
|
||||
|
|
@ -48,6 +54,8 @@ shape = SubResource("BoxShape3D_60a4j")
|
|||
mesh = SubResource("BoxMesh_b5l5s")
|
||||
|
||||
[node name="Wall5" type="StaticBody3D" parent="Walls" unique_id=597577595]
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Wall5" unique_id=885758063]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||
|
|
@ -58,6 +66,8 @@ mesh = SubResource("BoxMesh_b5l5s")
|
|||
|
||||
[node name="Wall4" type="StaticBody3D" parent="Walls" unique_id=1177443253]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Wall4" unique_id=854664258]
|
||||
transform = Transform3D(-4.371139e-08, 4.371139e-08, -1, 1, 1.9106855e-15, -4.371139e-08, 0, -1, -4.371139e-08, -1.5, 1, 0)
|
||||
|
|
|
|||
|
|
@ -40,12 +40,18 @@ transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -1.5
|
|||
|
||||
[node name="WallBase" parent="Walls/Bigwall1" unique_id=1490575404 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -1.5, 4.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase5" parent="Walls/Bigwall1" unique_id=1568037655 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 2, 0, 1, 0, -4.371139e-08, -1.5, 3, -3)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase14" parent="Walls/Bigwall1" unique_id=78975883 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-1.7484555e-07, 0, -0.9999999, 0, 2, 0, 4, 0, -4.3711385e-08, -1.5, 3, 7.5)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="Bigwall2" type="Node3D" parent="Walls" unique_id=826907750]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 4.498831, 0, -7.500418)
|
||||
|
|
@ -60,18 +66,28 @@ transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -1.5
|
|||
|
||||
[node name="WallBase5" parent="Walls/Bigwall2" unique_id=2118713508 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 2, 0, 1, 0, -4.371139e-08, -1.4999995, 3, -3)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase7" parent="Walls/Bigwall2" unique_id=1874271673 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 2, 0, 1, 0, -4.371139e-08, -1.5000014, 3, 12)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase10" parent="Walls/Bigwall2" unique_id=196260154 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -1.5, 4.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase12" parent="Walls/Bigwall2" unique_id=917303298 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-8.742278e-08, 0, -0.99999994, 0, 2, 0, 2, 0, -4.3711385e-08, -1.5000005, 3, 4.5)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase13" parent="Walls/Bigwall2" unique_id=438748995 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -1.5, 4.5, 9)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="Bigwall3" type="Node3D" parent="Walls" unique_id=933519333]
|
||||
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 7.498831, 0, 4.499582)
|
||||
|
|
@ -82,21 +98,31 @@ transform = Transform3D(-4.371138e-08, 0, -1, 0, 1, 0, 1, 0, -4.371138e-08, -1.4
|
|||
|
||||
[node name="WallBase5" parent="Walls/Bigwall3" unique_id=894275908 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371138e-08, 0, -1, 0, 2, 0, 1, 0, -4.371138e-08, -1.5000005, 3, -2.999999)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase9" parent="Walls/Bigwall3" unique_id=2070677842 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-1.792167e-07, 0, -0.9999996, 0, 2.0400002, 0, 4.1000004, 0, -4.371136e-08, -1.5000005, 3, 7.5)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase10" parent="Walls/Bigwall3" unique_id=1020605827 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -1.5, 4.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="Bigwall4" type="Node3D" parent="Walls" unique_id=505150141]
|
||||
transform = Transform3D(1.3113416e-07, 0, 1, 0, 1, 0, -1, 0, 1.3113416e-07, -4.501169, 0, 7.499582)
|
||||
|
||||
[node name="WallBase5" parent="Walls/Bigwall4" unique_id=2116321947 instance=ExtResource("1_uhbr2")]
|
||||
transform = Transform3D(-2.6226832e-07, 0, -0.9999991, 0, 2, 0, 6, 0, -4.3711353e-08, -1.5, 3, 4.5)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="Ceiling" type="StaticBody3D" parent="Walls" unique_id=48906640]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Ceiling" unique_id=719217371]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 5.5, 0)
|
||||
|
|
@ -107,6 +133,8 @@ mesh = SubResource("BoxMesh_lljjn")
|
|||
|
||||
[node name="Floor" type="StaticBody3D" parent="Walls" unique_id=42562663]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -5.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/Floor" unique_id=1790086579]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 5.5, 0)
|
||||
|
|
@ -117,6 +145,8 @@ mesh = SubResource("BoxMesh_lljjn")
|
|||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1256542062]
|
||||
transform = Transform3D(-4.3711385e-08, -3.2555902e-15, -1, -0.5224327, 0.8526805, 2.283626e-08, 0.8526805, 0.5224327, -3.7271846e-08, -7.9658985, 1.6422927, 0.31512594)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=450792456]
|
||||
transform = Transform3D(0.9981775, -0.060490817, 8.0049745e-11, 0.060490817, 0.9981775, -2.6441462e-09, 7.990053e-11, 2.644299e-09, 1, 0.9831743, 0.36734676, 0)
|
||||
|
|
@ -128,6 +158,8 @@ mesh = SubResource("BoxMesh_b0it3")
|
|||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="." unique_id=878315782]
|
||||
transform = Transform3D(-4.371138e-08, 0, -1, 5.9604645e-08, 1, 8.881784e-16, 1, -5.9604645e-08, -4.3711385e-08, -7.965729, 2.9630294, -4.5)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D2" unique_id=264240136]
|
||||
shape = SubResource("BoxShape3D_b5l5s")
|
||||
|
|
@ -137,19 +169,27 @@ mesh = SubResource("BoxMesh_b5l5s")
|
|||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="." unique_id=1345223811]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 4, 5, -5)
|
||||
spot_range = 16.504
|
||||
spot_angle = 49.19
|
||||
spot_angle_attenuation = 0.5358873
|
||||
|
||||
[node name="SpotLight3D2" type="SpotLight3D" parent="." unique_id=903847514]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, -4, 5, -5)
|
||||
spot_range = 16.504
|
||||
spot_angle = 49.19
|
||||
spot_angle_attenuation = 0.5358873
|
||||
|
||||
[node name="SpotLight3D3" type="SpotLight3D" parent="." unique_id=2133169158]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 4, 5, 5)
|
||||
spot_range = 16.504
|
||||
spot_angle = 49.19
|
||||
spot_angle_attenuation = 0.5358873
|
||||
|
||||
[node name="SpotLight3D4" type="SpotLight3D" parent="." unique_id=626724313]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, -4, 5, 5)
|
||||
spot_range = 16.504
|
||||
spot_angle = 49.19
|
||||
spot_angle_attenuation = 0.5358873
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="." unique_id=2021504335]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
|
|
|
|||
|
|
@ -14,15 +14,23 @@ script = ExtResource("1_u3woj")
|
|||
|
||||
[node name="WallBase2" parent="Walls" unique_id=1947232728 instance=ExtResource("2_nyrt0")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 1.5, 1.5, -3)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase3" parent="Walls" unique_id=657146167 instance=ExtResource("2_nyrt0")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 1.5, 1.5, 3)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallBase4" parent="Walls" unique_id=1353383013 instance=ExtResource("2_nyrt0")]
|
||||
transform = Transform3D(-1.3113416e-07, 0, -0.99999994, 0, 1, 0, 3, 0, -4.3711385e-08, -1.5, 1.5, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="Ceiling7" parent="Walls" unique_id=1993669613 instance=ExtResource("2_nyrt0")]
|
||||
transform = Transform3D(5.7320566e-15, -1, 4.3711385e-08, -1.3113416e-07, -4.371139e-08, -0.99999994, 3, 0, -4.3711385e-08, 0, 3, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="Walls" unique_id=301965768]
|
||||
transform = Transform3D(1.9106855e-15, -1, 4.371139e-08, -4.371139e-08, 4.371139e-08, 1, -1, -3.821371e-15, -4.371139e-08, 0, 3, -3)
|
||||
|
|
@ -32,6 +40,8 @@ transform = Transform3D(1.9106855e-15, -1, 4.371139e-08, -4.371139e-08, 4.371139
|
|||
|
||||
[node name="Floor10" parent="Walls" unique_id=1490575404 instance=ExtResource("2_nyrt0")]
|
||||
transform = Transform3D(5.7320566e-15, -1, 4.3711385e-08, -1.3113416e-07, -4.371139e-08, -0.99999994, 3, 0, -4.3711385e-08, 0, 0, 0)
|
||||
collision_layer = 17
|
||||
collision_mask = 17
|
||||
|
||||
[node name="WallHoleBase" parent="Walls" unique_id=116609943 instance=ExtResource("3_kp5l2")]
|
||||
unique_name_in_owner = true
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ var spaces: Dictionary = {"player" : "everything that is to do with the player",
|
|||
var player_commands: Dictionary = {
|
||||
"add_inventory_slot" : "add a slot to your inventory. max inv slots = 5",
|
||||
"remove_inventory_slot" : "remove a slot from your inventory. min inv slots = 2",
|
||||
"speed": "Change the base speed of the player"}
|
||||
"speed": "Change the base speed of the player",
|
||||
"noclip": "Turn off all collision physics on player, and fly."}
|
||||
var level_commands: Dictionary = {"reset": "resets the current level"}
|
||||
var avaliable_commands: Dictionary = {
|
||||
"help" : "print the available commands. \"help player\" prints the available commands for the player",
|
||||
|
|
@ -147,13 +148,13 @@ func parsed_command(command:String):
|
|||
"player":
|
||||
match space[1]:
|
||||
"add_inventory_slot":
|
||||
var success = Player.player.inventory_component.add_inventory_slot()
|
||||
var success = Player.player.hotbar_component.add_inventory_slot()
|
||||
if success:
|
||||
print_to_console_from_console("Added inventory slot.")
|
||||
else:
|
||||
print_to_console_from_console("Failed to add inventory slot.")
|
||||
"remove_inventory_slot":
|
||||
var success = Player.player.inventory_component.remove_inventory_slot()
|
||||
var success = Player.player.hotbar_component.remove_inventory_slot()
|
||||
if success:
|
||||
print_to_console_from_console("Removed inventory slot.")
|
||||
else:
|
||||
|
|
@ -165,6 +166,8 @@ func parsed_command(command:String):
|
|||
else:
|
||||
print_to_console_from_console("Player speed set to ", str(new_speed), " from ", str(PlayerConsts.SPEED))
|
||||
PlayerConsts.SPEED = float(args[1])
|
||||
"noclip":
|
||||
Player.player.toggle_noclip()
|
||||
_:
|
||||
print_command_not_found(command)
|
||||
"level":
|
||||
|
|
|
|||
|
|
@ -7,8 +7,15 @@ extends Control
|
|||
func toggle_debug_menu():
|
||||
debug_menu.visible = !debug_menu.visible
|
||||
|
||||
func toggle_inventory_menu(on:bool):
|
||||
inventory_menu.visible = on
|
||||
func toggle_inventory_menu(equipped_backpack, hotbar_component):
|
||||
if not Console.toggled:
|
||||
if inventory_menu.visible:
|
||||
inventory_menu.hide()
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
else:
|
||||
inventory_menu.show()
|
||||
inventory_menu.open_inventory(equipped_backpack, hotbar_component)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
func toggle_in_game_menu():
|
||||
if not Console.toggled:
|
||||
|
|
|
|||
Loading…
Reference in a new issue