Skip to content

Commit

Permalink
Fixing some BasicInteraction checks for more generic uses.
Browse files Browse the repository at this point in the history
BasicInteraction.gd:
- Added signal check.
- Added method check for interact.

This now enables the BasicInteraction to be used without any methods on the parent. Useful if one only wants to use the signals.
  • Loading branch information
Phazorknight committed Jul 16, 2024
1 parent bd5b84b commit 21078e3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions COGITO/Components/Interactions/BasicInteraction.gd
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
extends InteractionComponent

@onready var parent_node = get_parent() #Grabbing reference to door
@onready var parent_node = get_parent() #Grabbing reference to parent

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
parent_node.object_state_updated.connect(_on_object_state_change)

if parent_node.has_signal("object_state_updated"):
parent_node.object_state_updated.connect(_on_object_state_change)

func interact(_player_interaction_component):
parent_node.interact(_player_interaction_component)
if parent_node.has_method("interact"):
parent_node.interact(_player_interaction_component)

was_interacted_with.emit(interaction_text,input_map_action)


func _on_object_state_change(_interaction_text: String):
Expand Down

0 comments on commit 21078e3

Please sign in to comment.