1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-22 08:04:23 +00:00

Document SacrificeStone

This commit is contained in:
Steffo 2024-04-28 11:33:18 +02:00
parent 7c3f12cb13
commit a7f00b222d
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -2,6 +2,7 @@ extends Node2D
class_name SacrificeStone class_name SacrificeStone
## Emitted when the sacrifice on top of the stone changes.
signal sacrifice_changed(entity: PhysicsBody2D, type: Enums.MonsterType) signal sacrifice_changed(entity: PhysicsBody2D, type: Enums.MonsterType)
@ -10,10 +11,10 @@ var current_type: Enums.MonsterType = Enums.MonsterType.None
func _on_tracked(body: PhysicsBody2D): func _on_tracked(body: PhysicsBody2D):
# If a monster is dragged on top of the SacrificeStone while another monster is already on top of it, ignore the capture and let the collision resolve instead
if current_monster != null: if current_monster != null:
Log.w(self, "Captured two entities")
return return
# Make sure the monster is sacrificable, and if it is, lock it in and emit [signal sacrifice_changed].
var types: Array = body.find_children("*", "Sacrificable", false, false) var types: Array = body.find_children("*", "Sacrificable", false, false)
for type in types: for type in types:
current_monster = body current_monster = body
@ -21,9 +22,6 @@ func _on_tracked(body: PhysicsBody2D):
sacrifice_changed.emit(current_monster, current_type) sacrifice_changed.emit(current_monster, current_type)
break break
if current_monster == null:
Log.w(self, "Captured entity with no Sacrificable")
func _on_untracked(body: PhysicsBody2D): func _on_untracked(body: PhysicsBody2D):
if body == current_monster: if body == current_monster:
current_monster = null current_monster = null