class_name Interactable extends Area2D ## I'm not quite sure what to do with this yet but the idea is having an # area2d that detects not just a body entering a certain zone but triggering an # interract status. For a player this would probably be pressing a button. # the component can perhaps have a prompt of some sort to indicate what they're # supposed to do. Additionaly the interraction could perhaps trigger some # sort of animation when the action is performed. # This may have to be implemented as a bi-directional mediator pattern where # the player node is given some sort of call back upon entering the region and # when it happens it fires off that call back. # This means that whatever entity that is supposed to interract with these # objects should also have a receiver function of some kind. # Declare member variables here. Examples: # var a = 2 # var b = "text" export var type_name :String # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. func trigger_interaction(): # This is something that should maybe be extended for every differant interactible. # They could inherit from this base class and implement this function. # sprite.frame = 1 pass # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass # When a body enters this area # We want to give that body (a player I assume) a callback or a reference to this # Node. func _on_Interactable_Component_body_entered(body): var colliding_node = body if colliding_node.has_node("Interactable_Receiver"): colliding_node.get_node("Interactable_Receiver").register_interactable(self) func _on_Interactable_Component_body_exited(body): var colliding_node = body if colliding_node.has_node("Interactable_Receiver"): colliding_node.get_node("Interactable_Receiver").remove_interactable(self)