class_name MeetSpook extends Marker3D
## Source for a "meet-spook" event.
##
## When the event conditions are met, the MeetSpook closest to the player prepares contextual
## resources for the event.

const GROUP := "MeetSpookSource"

@export var mob_scene: PackedScene
@export var spawners: Array[MeetSpookSpawner] = []

var event_prepared := false


func prepare() -> void:
	if event_prepared:
		return

	for spawner: MeetSpookSpawner in spawners:
		var instance: MeetSpookMob = mob_scene.instantiate()
		instance.source = self
		spawner.spawn(instance)
	event_prepared = true


func resolve() -> void:
	for spawner: MeetSpookSpawner in spawners:
		spawner.resolve()
	event_prepared = false
