34 lines
734 B
GDScript
34 lines
734 B
GDScript
extends InspectableEntity
|
|
class_name Interactable
|
|
|
|
signal interacted(p: Player)
|
|
|
|
@export var default_interact_text = ""
|
|
|
|
@export var available : bool = true : set = set_available
|
|
|
|
func interact_text() -> String:
|
|
return default_interact_text
|
|
|
|
func can_interact(_p : Player) -> bool:
|
|
return available
|
|
|
|
func interaction_cost(_p : Player) -> int:
|
|
return 0
|
|
|
|
func interact(_p : Player) -> bool:
|
|
interacted.emit(_p)
|
|
return true
|
|
|
|
func generate_collision(area_width : float) -> CollisionShape2D:
|
|
var collision = CollisionShape2D.new()
|
|
var collision_shape = CircleShape2D.new()
|
|
collision_shape.radius = area_width
|
|
|
|
collision.shape = collision_shape
|
|
add_child(collision)
|
|
|
|
return collision
|
|
|
|
func set_available(v : bool):
|
|
available = v |