mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 08:04:23 +00:00
31 lines
819 B
GDScript
31 lines
819 B
GDScript
extends Node2D
|
|
class_name SacrificeStone
|
|
|
|
|
|
signal sacrifice_changed(entity: PhysicsBody2D, type: Enums.MonsterType)
|
|
|
|
|
|
var current_monster: PhysicsBody2D
|
|
var current_type: Enums.MonsterType = Enums.MonsterType.None
|
|
|
|
|
|
func _on_tracked(body: PhysicsBody2D):
|
|
if current_monster != null:
|
|
Log.w(self, "Captured two entities")
|
|
return
|
|
|
|
var types: Array = body.find_children("*", "Sacrificable", false, false)
|
|
for type in types:
|
|
current_monster = body
|
|
current_type = type.type
|
|
sacrifice_changed.emit(current_monster, current_type)
|
|
break
|
|
|
|
if current_monster == null:
|
|
Log.w(self, "Captured entity with no Sacrificable")
|
|
|
|
func _on_untracked(body: PhysicsBody2D):
|
|
if body == current_monster:
|
|
current_monster = null
|
|
current_type = Enums.MonsterType.None
|
|
sacrifice_changed.emit(current_monster, current_type)
|