class_name PlayManager extends Resource
## Abstract base type for strategies to manage the flow of gameplay

## Emitted when a player should be spawned in the world
@warning_ignore("unused_signal")
signal spawning(player: WorldPlayer)

## Emitted at the start of each new turn
@warning_ignore("unused_signal")
signal turn_started(player: WorldPlayer)

## Emitted when a player has won the game
@warning_ignore("unused_signal")
signal winner(player: WorldPlayer)

## List of game player instances
@export var players: Array[WorldPlayer] = []


func initialize() -> void:
	for player: WorldPlayer in players:
		player.shot_setup.finished.connect(_on_turn_finished)
		player.on_death.connect(_on_player_death)
	on_initialization()


func on_initialization() -> void:
	pass  # Implemented in derived type


func on_turn_finished(_shot_setup: ShotSetup) -> void:
	pass  # Implemented in derived type


func _on_turn_finished(shot_setup: ShotSetup) -> void:
	on_turn_finished(shot_setup)


func on_player_death(_player: WorldPlayer) -> void:
	pass  # Implemented in derived type


func _on_player_death(player: WorldPlayer) -> void:
	on_player_death(player)
