2023-10-01 01:03:03 +00:00
extends Node
class_name Collectible
2023-10-01 01:20:47 +00:00
## A marker for collectible entities.
##
## Used by [Collector]s to determine which entities to pick up.
2023-10-01 01:03:03 +00:00
2023-10-01 01:20:47 +00:00
## The type of collectible entity the parent entity represents.
@ export var type : StringName
2023-10-01 01:03:03 +00:00
2023-10-01 01:20:47 +00:00
## Emitted when this entity has been collected by a collector.
2023-10-01 01:03:03 +00:00
signal collected
2023-10-01 01:20:47 +00:00
## Mark this entity as collected.
##
## You'll probably want to connect this to an AudioSource2D, which will disable the node and play a sound, and when the sound is over a new signal will queue_free it.
2023-10-01 01:03:03 +00:00
func collect ( ) :
2023-10-03 00:13:20 +00:00
print ( " [Collectible] Collected " , self , " ! " )
2023-10-03 00:09:12 +00:00
collected . emit ( )
2023-10-02 03:31:31 +00:00
func _on_done ( ) :
2023-10-03 00:13:20 +00:00
print ( " [Collectible] Deleting " , self , " ... " )
2023-10-02 03:31:31 +00:00
get_parent ( ) . queue_free ( )