ci/woodpecker/push/woodpecker Pipeline was successful
We probably could have special-cased that check in Interactable now that I think about it
44 lines
835 B
GDScript
44 lines
835 B
GDScript
class_name Interactable
|
|
extends Node2D
|
|
|
|
signal interacted
|
|
|
|
var checked_teleport
|
|
var telecam_speed_mult = 4
|
|
var enabled = true
|
|
var cooldown = 2
|
|
var _is_interactable = false
|
|
|
|
func disable():
|
|
enabled = false
|
|
$Sprite2D.modulate = Color.DARK_ORANGE
|
|
|
|
func enable():
|
|
enabled = true
|
|
$Sprite2D.modulate = Color.WHITE
|
|
|
|
func is_interactable() -> bool:
|
|
return _is_interactable
|
|
|
|
func interact() -> void:
|
|
if not is_interactable():
|
|
return
|
|
interacted.emit()
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
pass
|
|
|
|
func _on_approach(body) -> void:
|
|
if body!=%Player2D:
|
|
return
|
|
_is_interactable = true
|
|
self.add_to_group("nearby_interactables")
|
|
$Sprite2D/ButtonPrompt.show()
|
|
|
|
func _on_abandon(body) -> void:
|
|
if body!=%Player2D:
|
|
return
|
|
_is_interactable = false
|
|
self.remove_from_group("nearby_interactables")
|
|
$Sprite2D/ButtonPrompt.hide()
|