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

32 lines
819 B
GDScript3
Raw Normal View History

2024-04-27 18:12:03 +00:00
extends Node2D
class_name SacrificeStone
signal sacrifice_changed(entity: PhysicsBody2D, type: Enums.MonsterType)
2024-04-27 18:12:03 +00:00
var current_monster: PhysicsBody2D
2024-04-27 18:12:03 +00:00
var current_type: Enums.MonsterType = Enums.MonsterType.None
func _on_tracked(body: PhysicsBody2D):
2024-04-27 18:12:03 +00:00
if current_monster != null:
Log.w(self, "Captured two entities")
return
2024-04-28 09:23:07 +00:00
var types: Array = body.find_children("*", "Sacrificable", false, false)
2024-04-27 18:12:03 +00:00
for type in types:
current_monster = body
current_type = type.type
sacrifice_changed.emit(current_monster, current_type)
break
if current_monster == null:
2024-04-28 09:23:07 +00:00
Log.w(self, "Captured entity with no Sacrificable")
2024-04-27 18:12:03 +00:00
func _on_untracked(body: PhysicsBody2D):
2024-04-27 18:12:03 +00:00
if body == current_monster:
current_monster = null
current_type = Enums.MonsterType.None
sacrifice_changed.emit(current_monster, current_type)