ghost-delivery/Collectable/collectable.gd

32 lines
837 B
GDScript

class_name Collectable
extends Area2D
## A delivery item the Ghost can carry. Picking up and dropping is driven by the
## Ghost through the "interact" (E) action, not by automatic collision.
@export var item_id: String = ""
@export var positionLeft: Vector2 = Vector2.ZERO
@export var positionRight: Vector2 = Vector2.ZERO
@export var positionUp: Vector2 = Vector2.ZERO
@export var positionDown: Vector2 = Vector2.ZERO
var is_held: bool = false
var is_delivered: bool = false
func _ready() -> void:
add_to_group("collectable")
func can_pick_up() -> bool:
return not is_held and not is_delivered
func mark_picked_up() -> void:
is_held = true
func mark_dropped() -> void:
is_held = false
func mark_delivered() -> void:
is_held = false
is_delivered = true
set_deferred("monitoring", false)
set_deferred("monitorable", false)