Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds dynamic HUD insertion to scenes #180

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions COGITO/DemoScenes/COGITO_01_Demo.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[gd_scene load_steps=146 format=3 uid="uid://cud7jwvomj24d"]
[gd_scene load_steps=144 format=3 uid="uid://cud7jwvomj24d"]

[ext_resource type="PackedScene" uid="uid://kicjwmh02uwf" path="res://COGITO/PrefabScenes/player.tscn" id="1_7d2n7"]
[ext_resource type="Script" path="res://COGITO/SceneManagement/cogito_scene.gd" id="1_b15oo"]
[ext_resource type="Material" uid="uid://dkbgl3p3ffd1" path="res://COGITO/Assets/Materials/Prototype_DarkGrey.tres" id="1_lsda4"]
[ext_resource type="PackedScene" uid="uid://cwd3g16ep0idw" path="res://COGITO/PrefabScenes/Pickups/pickup_flashlight.tscn" id="1_oweej"]
[ext_resource type="Material" uid="uid://hhhudvarh7gk" path="res://COGITO/Assets/Materials/Prototype_Orange.tres" id="2_4ig6i"]
[ext_resource type="Script" path="res://COGITO/InventoryPD/InventoryPD.gd" id="2_chxar"]
[ext_resource type="PackedScene" uid="uid://0c32kepv0ahx" path="res://COGITO/PrefabScenes/Player_HUD.tscn" id="4_1ofwa"]
[ext_resource type="PackedScene" uid="uid://d3m4ni301eso7" path="res://COGITO/PrefabScenes/carriable_box.tscn" id="6_cy1m6"]
[ext_resource type="PackedScene" uid="uid://lsun1f1wjfxl" path="res://COGITO/PrefabScenes/ceiling_lamp.tscn" id="7_3y6g2"]
[ext_resource type="PackedScene" uid="uid://bho0nwh5rlnua" path="res://COGITO/PrefabScenes/target_destructable.tscn" id="8_tk621"]
Expand Down Expand Up @@ -40,7 +39,6 @@
[ext_resource type="Texture2D" uid="uid://cg5knuav7df4o" path="res://COGITO/Assets/Graphics/HintIcons/Hint_X.png" id="36_7nev7"]
[ext_resource type="AudioStream" uid="uid://b6wdy2102jymr" path="res://COGITO/Assets/Audio/Kenney/UiAudio/switch2.ogg" id="36_42jeg"]
[ext_resource type="Material" uid="uid://dhg1uhiq7ywn2" path="res://COGITO/Assets/Materials/Prototype_Green.tres" id="38_l5vpp"]
[ext_resource type="PackedScene" uid="uid://dkie3md1cmsip" path="res://COGITO/EasyMenus/Scenes/PauseMenu.tscn" id="40_6m7mg"]
[ext_resource type="PackedScene" uid="uid://i7fum2jx3ac3" path="res://COGITO/PrefabScenes/ladder.tscn" id="41_q27ev"]
[ext_resource type="Script" path="res://COGITO/Scripts/scene_transition_zone.gd" id="43_bchdf"]
[ext_resource type="Script" path="res://COGITO/CogitoObjects/Cogito_Object.gd" id="45_ubu8v"]
Expand Down Expand Up @@ -270,7 +268,7 @@ script = ExtResource("16_fg1wi")
inventory_item = ExtResource("17_nl6sa")
quantity = 2

[sub_resource type="Resource" id="Resource_6ni2c"]
[sub_resource type="Resource" id="Resource_hsjs6"]
resource_local_to_scene = true
script = ExtResource("2_chxar")
inventory_slots = Array[ExtResource("16_fg1wi")]([SubResource("Resource_v7b11"), SubResource("Resource_eku8j"), null, null])
Expand Down Expand Up @@ -348,7 +346,7 @@ size = Vector3(1.5, 0.01, 1.5)
[sub_resource type="BoxShape3D" id="BoxShape3D_ht4uj"]
size = Vector3(100, 3, 100)

[sub_resource type="Resource" id="Resource_u4vu3"]
[sub_resource type="Resource" id="Resource_il648"]
resource_local_to_scene = true
script = ExtResource("2_chxar")
inventory_slots = Array[ExtResource("16_fg1wi")]([null, null, null, null, null, null, null, null])
Expand Down Expand Up @@ -1253,7 +1251,7 @@ transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107,
[node name="Chest" parent="INTERACTIVE_OBJECTS" groups=["external_inventory"] instance=ExtResource("14_d7sxi")]
transform = Transform3D(0.686504, 0, -0.727126, 0, 1, 0, 0.727126, 0, 0.686504, -4.38933, 0.0425703, 5.97176)
inventory_name = "Chest"
inventory_data = SubResource("Resource_6ni2c")
inventory_data = SubResource("Resource_hsjs6")
uses_animation = true
open_animation = "open"

Expand Down Expand Up @@ -1611,17 +1609,9 @@ transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 2.1480

[node name="Player" parent="." instance=ExtResource("1_7d2n7")]
transform = Transform3D(-1, 0, 7.45058e-07, 0, 1, 0, -7.45058e-07, 0, -1, -7.5375, 0.905039, -3.30884)
pause_menu = NodePath("../TabMenu")
player_hud = NodePath("../Player_HUD")
inventory_data = SubResource("Resource_u4vu3")
inventory_data = SubResource("Resource_il648")
step_height_camera_lerp = 1.5

[node name="Player_HUD" parent="." node_paths=PackedStringArray("player") instance=ExtResource("4_1ofwa")]
player = NodePath("../Player")

[node name="TabMenu" parent="." node_paths=PackedStringArray("nodes_to_focus") instance=ExtResource("40_6m7mg")]
nodes_to_focus = [null, null, null, null, null]

[node name="Ladder" parent="." instance=ExtResource("41_q27ev")]

[node name="Stairs" type="Node3D" parent="."]
Expand Down
15 changes: 3 additions & 12 deletions COGITO/DemoScenes/COGITO_02_SceneTransitionsA.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[gd_scene load_steps=18 format=3 uid="uid://dty7vjg3hp68b"]
[gd_scene load_steps=16 format=3 uid="uid://dty7vjg3hp68b"]

[ext_resource type="PackedScene" uid="uid://kicjwmh02uwf" path="res://COGITO/PrefabScenes/player.tscn" id="1_8f7tt"]
[ext_resource type="Script" path="res://COGITO/SceneManagement/cogito_scene.gd" id="1_8th5t"]
[ext_resource type="Script" path="res://COGITO/InventoryPD/InventoryPD.gd" id="2_w4txe"]
[ext_resource type="PackedScene" uid="uid://0c32kepv0ahx" path="res://COGITO/PrefabScenes/Player_HUD.tscn" id="3_ha28r"]
[ext_resource type="Material" uid="uid://dkbgl3p3ffd1" path="res://COGITO/Assets/Materials/Prototype_DarkGrey.tres" id="5_5tohn"]
[ext_resource type="PackedScene" uid="uid://dkie3md1cmsip" path="res://COGITO/EasyMenus/Scenes/PauseMenu.tscn" id="5_gcqc7"]
[ext_resource type="Material" uid="uid://dhg1uhiq7ywn2" path="res://COGITO/Assets/Materials/Prototype_Green.tres" id="6_jn18d"]
[ext_resource type="Script" path="res://COGITO/Scripts/scene_transition_zone.gd" id="7_34j8q"]
[ext_resource type="PackedScene" uid="uid://d3m4ni301eso7" path="res://COGITO/PrefabScenes/carriable_box.tscn" id="8_4hlpp"]
Expand All @@ -31,7 +29,7 @@ tonemap_mode = 2
ssao_enabled = true
glow_enabled = true

[sub_resource type="Resource" id="Resource_ffs5j"]
[sub_resource type="Resource" id="Resource_lu3pe"]
resource_local_to_scene = true
script = ExtResource("2_w4txe")
inventory_slots = Array[Resource("res://COGITO/InventoryPD/CustomResources/InventorySlotPD.gd")]([null, null, null, null, null, null, null, null])
Expand Down Expand Up @@ -62,16 +60,9 @@ environment = SubResource("Environment_ai7l5")

[node name="Player" parent="." instance=ExtResource("1_8f7tt")]
transform = Transform3D(-1, 0, 7.45058e-07, 0, 1, 0, -7.45058e-07, 0, -1, 3.63987, 1.19987, 3.00969)
pause_menu = NodePath("../PauseMenu")
player_hud = NodePath("../Player_HUD")
inventory_data = SubResource("Resource_ffs5j")
inventory_data = SubResource("Resource_lu3pe")
step_height_camera_lerp = 1.5

[node name="Player_HUD" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_ha28r")]
player = NodePath("../Player")

[node name="PauseMenu" parent="." instance=ExtResource("5_gcqc7")]

[node name="STATIC ENVIRONMENT" type="Node3D" parent="."]

[node name="Floor" type="CSGBox3D" parent="STATIC ENVIRONMENT"]
Expand Down
15 changes: 3 additions & 12 deletions COGITO/DemoScenes/COGITO_03_SceneTransitionsB.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[gd_scene load_steps=22 format=3 uid="uid://c1rwpd0k7ov8"]
[gd_scene load_steps=20 format=3 uid="uid://c1rwpd0k7ov8"]

[ext_resource type="Script" path="res://COGITO/SceneManagement/cogito_scene.gd" id="1_2xpg1"]
[ext_resource type="PackedScene" uid="uid://kicjwmh02uwf" path="res://COGITO/PrefabScenes/player.tscn" id="1_3gycq"]
[ext_resource type="Script" path="res://COGITO/InventoryPD/InventoryPD.gd" id="2_l0t74"]
[ext_resource type="PackedScene" uid="uid://0c32kepv0ahx" path="res://COGITO/PrefabScenes/Player_HUD.tscn" id="3_20bm3"]
[ext_resource type="PackedScene" uid="uid://dkie3md1cmsip" path="res://COGITO/EasyMenus/Scenes/PauseMenu.tscn" id="4_3maio"]
[ext_resource type="Material" uid="uid://dkbgl3p3ffd1" path="res://COGITO/Assets/Materials/Prototype_DarkGrey.tres" id="5_ioaac"]
[ext_resource type="Material" uid="uid://dhg1uhiq7ywn2" path="res://COGITO/Assets/Materials/Prototype_Green.tres" id="6_1emu1"]
[ext_resource type="Material" uid="uid://hhhudvarh7gk" path="res://COGITO/Assets/Materials/Prototype_Orange.tres" id="6_v67yj"]
Expand Down Expand Up @@ -33,7 +31,7 @@ tonemap_mode = 2
ssao_enabled = true
glow_enabled = true

[sub_resource type="Resource" id="Resource_ebnyt"]
[sub_resource type="Resource" id="Resource_030uy"]
resource_local_to_scene = true
script = ExtResource("2_l0t74")
inventory_slots = Array[Resource("res://COGITO/InventoryPD/CustomResources/InventorySlotPD.gd")]([null, null, null, null, null, null, null, null])
Expand Down Expand Up @@ -70,16 +68,9 @@ environment = SubResource("Environment_ai7l5")

[node name="Player" parent="." instance=ExtResource("1_3gycq")]
transform = Transform3D(-1, 0, 7.45058e-07, 0, 1, 0, -7.45058e-07, 0, -1, -7.5375, 0.905039, -3.30884)
pause_menu = NodePath("../PauseMenu")
player_hud = NodePath("../Player_HUD")
inventory_data = SubResource("Resource_ebnyt")
inventory_data = SubResource("Resource_030uy")
step_height_camera_lerp = 1.5

[node name="Player_HUD" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_20bm3")]
player = NodePath("../Player")

[node name="PauseMenu" parent="." instance=ExtResource("4_3maio")]

[node name="STATIC ENVIRONMENT" type="Node3D" parent="."]

[node name="Floor" type="CSGBox3D" parent="STATIC ENVIRONMENT"]
Expand Down
16 changes: 3 additions & 13 deletions COGITO/DemoScenes/COGITO_04_Demo_Lobby.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[gd_scene load_steps=367 format=3 uid="uid://e31n36p8i6an"]
[gd_scene load_steps=365 format=3 uid="uid://e31n36p8i6an"]

[ext_resource type="Script" path="res://COGITO/SceneManagement/cogito_scene.gd" id="1_dracg"]
[ext_resource type="Texture2D" uid="uid://sdcljx8f5dhj" path="res://COGITO/Assets/hdris/kloofendal_48d_partly_cloudy_puresky_2k.hdr" id="2_a8imk"]
[ext_resource type="PackedScene" uid="uid://kicjwmh02uwf" path="res://COGITO/PrefabScenes/player.tscn" id="3_mgle8"]
[ext_resource type="Script" path="res://COGITO/InventoryPD/InventoryPD.gd" id="4_0kggm"]
[ext_resource type="PackedScene" uid="uid://0c32kepv0ahx" path="res://COGITO/PrefabScenes/Player_HUD.tscn" id="5_to5tg"]
[ext_resource type="PackedScene" uid="uid://dkie3md1cmsip" path="res://COGITO/EasyMenus/Scenes/PauseMenu.tscn" id="6_vlp8l"]
[ext_resource type="Script" path="res://COGITO/QuestSystemPD/Components/QuestUpdater.gd" id="7_a40bd"]
[ext_resource type="Resource" uid="uid://drmtc0tqmwquk" path="res://COGITO/QuestSystemPD/Quests/DemoSceneQuests/Demo_AccessArchive.tres" id="8_5xvfv"]
[ext_resource type="PackedScene" uid="uid://p3f16jxrcxdt" path="res://COGITO/Assets/Models/Kenney/Furniture/GLTF format/floorFull.glb" id="9_ec70c"]
Expand Down Expand Up @@ -124,7 +122,7 @@ volumetric_fog_temporal_reprojection_amount = 0.85
density = 0.04
albedo = Color(0.694118, 0.694118, 0.694118, 1)

[sub_resource type="Resource" id="Resource_8g6xp"]
[sub_resource type="Resource" id="Resource_oq6sg"]
resource_local_to_scene = true
script = ExtResource("4_0kggm")
inventory_slots = Array[Resource("res://COGITO/InventoryPD/CustomResources/InventorySlotPD.gd")]([null, null, null, null, null, null, null, null])
Expand Down Expand Up @@ -3289,17 +3287,9 @@ material = SubResource("FogMaterial_4avjx")

[node name="Player" parent="." instance=ExtResource("3_mgle8")]
transform = Transform3D(-1, 0, 7.45058e-07, 0, 1, 0, -7.45058e-07, 0, -1, 3.03073, 0.905039, -17.9321)
pause_menu = NodePath("../PauseMenu")
player_hud = NodePath("../Player_HUD")
inventory_data = SubResource("Resource_8g6xp")
inventory_data = SubResource("Resource_oq6sg")
step_height_camera_lerp = 1.5

[node name="Player_HUD" parent="." node_paths=PackedStringArray("player") instance=ExtResource("5_to5tg")]
player = NodePath("../Player")

[node name="PauseMenu" parent="." node_paths=PackedStringArray("nodes_to_focus") instance=ExtResource("6_vlp8l")]
nodes_to_focus = [null, null, null, null, null]

[node name="QUESTS" type="Node3D" parent="."]

[node name="Archive_QuestStarter" type="Area3D" parent="QUESTS"]
Expand Down
12 changes: 1 addition & 11 deletions COGITO/DemoScenes/COGITO_05_Demo_Laboratory.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[gd_scene load_steps=104 format=3 uid="uid://6hh7o77unixk"]
[gd_scene load_steps=102 format=3 uid="uid://6hh7o77unixk"]

[ext_resource type="Script" path="res://COGITO/SceneManagement/cogito_scene.gd" id="1_4dqq6"]
[ext_resource type="Texture2D" uid="uid://sdcljx8f5dhj" path="res://COGITO/Assets/hdris/kloofendal_48d_partly_cloudy_puresky_2k.hdr" id="1_ponqc"]
[ext_resource type="PackedScene" uid="uid://kicjwmh02uwf" path="res://COGITO/PrefabScenes/player.tscn" id="2_7qwrr"]
[ext_resource type="PackedScene" uid="uid://0c32kepv0ahx" path="res://COGITO/PrefabScenes/Player_HUD.tscn" id="3_0c7yw"]
[ext_resource type="PackedScene" uid="uid://dkie3md1cmsip" path="res://COGITO/EasyMenus/Scenes/PauseMenu.tscn" id="4_vc32u"]
[ext_resource type="PackedScene" uid="uid://p3f16jxrcxdt" path="res://COGITO/Assets/Models/Kenney/Furniture/GLTF format/floorFull.glb" id="5_ihscj"]
[ext_resource type="PackedScene" uid="uid://b6yj5prtsl7hy" path="res://COGITO/DemoScenes/DemoPrefabs/floor_3x_3_00.tscn" id="6_bedlu"]
[ext_resource type="PackedScene" uid="uid://bavlamv6h43uw" path="res://COGITO/DemoScenes/DemoPrefabs/ksi_wall_painted.tscn" id="6_yj0h7"]
Expand Down Expand Up @@ -935,14 +933,6 @@ environment = SubResource("Environment_obnk3")

[node name="Player" parent="." instance=ExtResource("2_7qwrr")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 5.13854, 0.8, -5.43073)
pause_menu = NodePath("../PauseMenu")
player_hud = NodePath("../Player_HUD")

[node name="Player_HUD" parent="." node_paths=PackedStringArray("player") instance=ExtResource("3_0c7yw")]
player = NodePath("../Player")

[node name="PauseMenu" parent="." node_paths=PackedStringArray("nodes_to_focus") instance=ExtResource("4_vc32u")]
nodes_to_focus = [null, null, null, null, null]

[node name="CONNECTOR_TO_LOBBY" type="Node3D" parent="."]

Expand Down
12 changes: 12 additions & 0 deletions COGITO/SceneManagement/cogito_scene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ extends Node
## List of connector nodes. These are used to place the Player in the correct position when they transition to this scene from a different scene. The Node name needs to match the passed string for this to work.
@export var connectors : Array[Node3D]


func _ready() -> void:
var player_hud = UserInterface.player_hud_scene.instantiate()
var pause_menu = UserInterface.pause_menu_scene.instantiate()
add_child(player_hud)
add_child(pause_menu)
CogitoSceneManager._current_player_node.player_hud = player_hud.get_path()
CogitoSceneManager._current_player_node.pause_menu = pause_menu.get_path()
pause_menu.resume.connect(CogitoSceneManager._current_player_node._on_pause_menu_resume) # Hookup resume signal from Pause Menu
pause_menu.close_pause_menu() # Making sure pause menu is closed on player scene load


func move_player_to_connector(connector_name:String):
for node in connectors:
if node.get_name() == connector_name:
Expand Down
1 change: 0 additions & 1 deletion COGITO/SceneManagement/loading_screen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ func _process(_delta):
if connector_name != "": #If a connector name has been passed, move the player to it. This requires the target scene to have a cogito scene script attached to it's root scene node.
new_scene_node.move_player_to_connector(connector_name)
current_scene.queue_free() # Removing previous scene.

3 changes: 2 additions & 1 deletion COGITO/Scripts/Player_Hud_Manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ signal hide_inventory
#region Variables

## Reference to the Node that has the player.gd script.
@export var player : Node
var player: Node

## Used to reset icons etc, useful to have.
@export var empty_texture : Texture2D
Expand Down Expand Up @@ -42,6 +42,7 @@ var interaction_texture : Texture2D


func _ready():
player = CogitoSceneManager._current_player_node
# Connect to signal that detects change of input device
InputHelper.device_changed.connect(_on_input_device_change)
# Calling this function once to set proper input icons
Expand Down
12 changes: 2 additions & 10 deletions COGITO/Scripts/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ signal toggled_interface(is_showing_ui:bool) #Used to hide UI elements like the

#region Variables
## Reference to Pause menu node
@export var pause_menu : NodePath
var pause_menu: NodePath
## Refereence to Player HUD node
@export var player_hud : NodePath
var player_hud: NodePath
# Used for handling input when UI is open/displayed
var is_showing_ui : bool

Expand Down Expand Up @@ -197,14 +197,6 @@ func _ready():
if sanity_attribute and visibility_attribute:
visibility_attribute.attribute_changed.connect(sanity_attribute.on_visibility_changed)
visibility_attribute.check_current_visibility()

# Pause Menu setup
if pause_menu:
var pause_menu_node = get_node(pause_menu)
pause_menu_node.resume.connect(_on_pause_menu_resume) # Hookup resume signal from Pause Menu
pause_menu_node.close_pause_menu() # Making sure pause menu is closed on player scene load
else:
print("Player has no reference to pause menu.")

initial_carryable_height = carryable_position.position.y #DEPRECATED

Expand Down
5 changes: 5 additions & 0 deletions COGITO/Scripts/user_interface_singleton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends Node


var player_hud_scene: PackedScene = preload("res://COGITO/PrefabScenes/Player_HUD.tscn")
var pause_menu_scene: PackedScene = preload("res://COGITO/EasyMenus/Scenes/PauseMenu.tscn")
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ InputHelper="*res://addons/input_helper/input_helper.gd"
Audio="*res://addons/quick_audio/./Audio.gd"
CogitoSceneManager="*res://COGITO/SceneManagement/cogito_scene_manager.gd"
CogitoQuestManager="*res://COGITO/QuestSystemPD/CogitoQuestManager.gd"
UserInterface="*res://COGITO/Scripts/user_interface_singleton.gd"

[display]

Expand Down