1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-22 16:14:22 +00:00
hella-farm/entities/summoning_circle.gd

43 lines
876 B
GDScript3
Raw Normal View History

2024-04-27 18:12:03 +00:00
extends Node2D
class_name SummoningCircle
2024-04-27 18:12:03 +00:00
@onready var spawner: Spawner = %"Spawner"
2024-04-27 18:12:03 +00:00
## The scene to spawn.
@export var scene_imp: PackedScene
## The [SacrificeStone]s part of this summoning circle.
var stones: Array[SacrificeStone] = []
2024-04-27 18:12:03 +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:
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()