1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-24 17:14:23 +00:00
hella-farm/entities/gold.gd

25 lines
558 B
GDScript3
Raw Normal View History

2024-04-13 17:07:26 +00:00
extends Node2D
class_name Gold
2024-04-13 17:07:26 +00:00
@onready var game: MainGame = MainGame.get_via_group(self)
@onready var move_towards: MoveTowards = %"MoveTowards"
@onready var collect_sound_spawner: Spawner = %"CollectSoundSpawner"
@onready var collectible: Collectible = %"Collectible"
2024-04-14 02:39:45 +00:00
2024-04-21 21:20:02 +00:00
func magnetize(cursor: Cursor) -> void:
move_towards.target = cursor
2024-04-14 02:39:45 +00:00
2024-04-21 21:20:02 +00:00
func demagnetize() -> void:
move_towards.target = null
func collect() -> void:
collectible.apply()
2024-04-21 21:20:02 +00:00
collect_sound_spawner.spawn()
2024-04-14 02:39:45 +00:00
queue_free()
2024-04-21 21:20:02 +00:00
func _on_move(movement: Vector2) -> void:
position += movement