mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 08:04:23 +00:00
Rename and document some bits of SacrificeStone
This commit is contained in:
parent
ae83cc0681
commit
c2e77c55c4
2 changed files with 15 additions and 11 deletions
|
@ -1,26 +1,30 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
class_name SacrificeStone
|
class_name SacrificeStone
|
||||||
|
|
||||||
|
## The sacrificial stone where entities can be placed on.
|
||||||
|
##
|
||||||
|
## Entities use [MovementHunter] to move towards the center of the stone.
|
||||||
|
|
||||||
|
|
||||||
## Emitted when the sacrifice on top of the stone changes.
|
## 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)
|
||||||
|
|
||||||
|
## The entity currently on top of the stone.
|
||||||
var current_monster: PhysicsBody2D
|
var entity: PhysicsBody2D
|
||||||
|
|
||||||
|
|
||||||
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 a entity is dragged on top of the SacrificeStone while another entity is already on top of it, ignore the capture and let the collision resolve instead
|
||||||
if current_monster != null:
|
if entity != null:
|
||||||
return
|
return
|
||||||
# Make sure the monster is sacrificable, and if it is, lock it in and emit [signal sacrifice_changed].
|
# Make sure the entity 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
|
entity = body
|
||||||
sacrifice_changed.emit(current_monster)
|
sacrifice_changed.emit(body)
|
||||||
break
|
break
|
||||||
|
|
||||||
func _on_untracked(body: PhysicsBody2D):
|
func _on_untracked(body: PhysicsBody2D):
|
||||||
if body == current_monster:
|
if body == entity:
|
||||||
current_monster = null
|
entity = null
|
||||||
sacrifice_changed.emit(current_monster)
|
sacrifice_changed.emit(null)
|
||||||
|
|
|
@ -41,7 +41,7 @@ func spawn(type: PackedScene) -> void:
|
||||||
spawner.spawn()
|
spawner.spawn()
|
||||||
|
|
||||||
for s in stones:
|
for s in stones:
|
||||||
s.current_monster.queue_free()
|
s.entity.queue_free()
|
||||||
|
|
||||||
func _on_sacrifice_changed(_entity: Node2D, _type: Enums.MonsterType):
|
func _on_sacrifice_changed(_entity: Node2D, _type: Enums.MonsterType):
|
||||||
refresh_sacrifices()
|
refresh_sacrifices()
|
||||||
|
|
Loading…
Reference in a new issue