Skip to content

Commit

Permalink
Door: Fixes interaction prompt updating when on timer.
Browse files Browse the repository at this point in the history
Also fixed some minor issue where scripts would attempt to connect to signals already connected.
  • Loading branch information
Phazorknight committed Apr 7, 2024
1 parent dd193e8 commit ce3c4d9
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 101 deletions.
14 changes: 11 additions & 3 deletions COGITO/CogitoObjects/Cogito_Door.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var interaction_text
var close_timer : Timer #Used for auto-close

var interaction_nodes : Array[Node]
var player_interaction_component : PlayerInteractionComponent

func _ready():
add_to_group("interactable")
Expand All @@ -90,6 +91,7 @@ func _ready():


func interact(interactor: Node3D):
player_interaction_component = interactor
if !is_locked:
if !is_open:
open_door(interactor)
Expand Down Expand Up @@ -189,7 +191,8 @@ func open_door(interactor: Node3D):


func on_auto_close_time():
close_door(null)
close_door(player_interaction_component)



func close_door(_interactor: Node3D):
Expand All @@ -213,19 +216,24 @@ func close_door(_interactor: Node3D):
tween_door.tween_property(self,"position", closed_position, door_speed)
is_open = false
interaction_text = interaction_text_when_closed
player_interaction_component.interactive_object_exit() #Froces a re-detection of the interaction prompt.
object_state_updated.emit(interaction_text)
door_state_changed.emit(false)

func set_state():
if is_open:
if is_sliding:
position = open_position
interaction_text = interaction_text_when_open
else:
if is_sliding:
position = closed_position
interaction_text = interaction_text_when_closed
if is_locked:
interaction_text = interaction_text_when_locked
object_state_updated.emit(interaction_text)


func save():
var state_dict = {
"node_path" : self.get_path(),
Expand Down
8 changes: 4 additions & 4 deletions COGITO/DemoScenes/COGITO_01_Demo.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ script = ExtResource("16_fg1wi")
inventory_item = ExtResource("17_nl6sa")
quantity = 2

[sub_resource type="Resource" id="Resource_p0hga"]
[sub_resource type="Resource" id="Resource_g6vn6"]
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 +348,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_i0ssc"]
[sub_resource type="Resource" id="Resource_xi0gu"]
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 +1253,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_p0hga")
inventory_data = SubResource("Resource_g6vn6")
uses_animation = true
open_animation = "open"

Expand Down Expand Up @@ -1613,7 +1613,7 @@ transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 2.1480
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_i0ssc")
inventory_data = SubResource("Resource_xi0gu")
step_height_camera_lerp = 1.5

[node name="Player_HUD" parent="." node_paths=PackedStringArray("player") instance=ExtResource("4_1ofwa")]
Expand Down
4 changes: 2 additions & 2 deletions COGITO/DemoScenes/COGITO_04_Demo_Lobby.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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_5m1uy"]
[sub_resource type="Resource" id="Resource_277ed"]
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 @@ -3270,7 +3270,7 @@ material = SubResource("FogMaterial_4avjx")
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_5m1uy")
inventory_data = SubResource("Resource_277ed")
step_height_camera_lerp = 1.5

[node name="Player_HUD" parent="." node_paths=PackedStringArray("player") instance=ExtResource("5_to5tg")]
Expand Down
3 changes: 2 additions & 1 deletion COGITO/InventoryPD/UiScenes/hot_bar_inventory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func _unhandled_input(event):


func set_inventory_data(inventory_data : InventoryPD) -> void:
inventory_data.inventory_updated.connect(populate_hotbar)
if !inventory_data.inventory_updated.is_connected(populate_hotbar):
inventory_data.inventory_updated.connect(populate_hotbar)
populate_hotbar(inventory_data)
hot_bar_use.connect(inventory_data.use_slot_data)

Expand Down
3 changes: 2 additions & 1 deletion COGITO/InventoryPD/UiScenes/inventory_interface.gd
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ func clear_external_inventory():

func set_player_inventory_data(inventory_data : InventoryPD):
# inventory_data.inventory_interact.connect(on_inventory_interact)
inventory_data.inventory_button_press.connect(on_inventory_button_press)
if !inventory_data.inventory_button_press.is_connected(on_inventory_button_press):
inventory_data.inventory_button_press.connect(on_inventory_button_press)
inventory_ui.set_inventory_data(inventory_data)

# Inventory handling on gamepad buttons
Expand Down
Loading

0 comments on commit ce3c4d9

Please sign in to comment.