29 lines
802 B
GDScript
29 lines
802 B
GDScript
extends Area2D
|
|
class_name InteractScanner
|
|
|
|
signal InteractionActionTriggered()
|
|
|
|
@export var parent: Node2D
|
|
@export var direction_component: FacingDirectionComponent
|
|
@export var disable_interactions := false
|
|
|
|
# Public Methods
|
|
func OnDirectionChanged() -> void:
|
|
var direction := direction_component.GetCurrentDirection()
|
|
if direction == Enums.Directions.LEFT:
|
|
parent.rotation = deg_to_rad(90)
|
|
elif direction == Enums.Directions.RIGHT:
|
|
parent.rotation = deg_to_rad(-90)
|
|
elif direction == Enums.Directions.UP:
|
|
parent.rotation = deg_to_rad(180)
|
|
else:
|
|
parent.rotation = deg_to_rad(0)
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
if disable_interactions:
|
|
return
|
|
if Input.is_action_just_pressed("player_interact"):
|
|
InputManager.IgnoreAction("player_interact")
|
|
InteractionActionTriggered.emit()
|