2024-04-27 18:12:03 +00:00
|
|
|
extends Node2D
|
2024-04-28 15:42:54 +00:00
|
|
|
class_name SummoningCircle
|
2024-04-27 18:12:03 +00:00
|
|
|
|
2024-04-28 15:43:28 +00:00
|
|
|
@onready var spawner: Spawner = %"Spawner"
|
2024-04-27 18:12:03 +00:00
|
|
|
|
|
|
|
## The scene to spawn.
|
|
|
|
@export var scene_imp: PackedScene
|
|
|
|
|
|
|
|
|
2024-04-28 15:42:35 +00:00
|
|
|
## The [SacrificeStone]s part of this summoning circle.
|
|
|
|
var stones: Array[SacrificeStone] = []
|
2024-04-27 18:12:03 +00:00
|
|
|
|
|
|
|
|
2024-04-28 15:42:35 +00:00
|
|
|
## Refresh the value of [field stones].
|
|
|
|
func refresh_stones() -> void:
|
|
|
|
stones.assign(
|
|
|
|
find_children("*", "SacrificeStone", false, false)
|
|
|
|
)
|
2024-04-27 18:12:03 +00:00
|
|
|
|
|
|
|
func try_sacrifice() -> void:
|
|
|
|
var first_monster = sacrifices[0]
|
|
|
|
var all_same = true
|
|
|
|
for m in sacrifices:
|
|
|
|
if m != first_monster:
|
|
|
|
all_same = false
|
|
|
|
break
|
|
|
|
if not all_same:
|
|
|
|
return
|
|
|
|
|
|
|
|
if first_monster == Enums.MonsterType.Sheep:
|
|
|
|
spawn(scene_imp)
|
|
|
|
|
|
|
|
func spawn(type: PackedScene) -> void:
|
|
|
|
spawner.scene = type
|
|
|
|
spawner.spawn()
|
|
|
|
|
|
|
|
for s in stones:
|
2024-04-28 15:06:44 +00:00
|
|
|
s.entity.queue_free()
|
2024-04-27 18:12:03 +00:00
|
|
|
|
|
|
|
func _on_sacrifice_changed(_entity: Node2D, _type: Enums.MonsterType):
|
|
|
|
refresh_sacrifices()
|
|
|
|
try_sacrifice()
|