1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-22 15:44:21 +00:00
swear-jar/collector/collectible.gd

25 lines
695 B
GDScript3
Raw Normal View History

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():
print("[Collectible] Collected ", self, "!")
collected.emit()
2023-10-02 03:31:31 +00:00
func _on_done():
print("[Collectible] Deleting ", self, "...")
2023-10-02 03:31:31 +00:00
get_parent().queue_free()