class_name RoomState extends State


const STARTING = "Starting"
const PLAYING = "Playing"
const EXITING = "Exiting"

var room: Room


func _ready() -> void:
	await owner.ready
	room = owner as Room
	assert(room != null, "The RoomState state type must be used only in the room scene. It needs the owner's parent to be a Room node.")


func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
	pass


func _exit() -> void:
	pass


func _handle_input(_event: InputEvent) -> void:
	pass


func _state_update(_delta: float) -> void:
	pass


func _state_physics_update(_delta: float) -> void:
	pass


func match_state(exclude: Array[StringName] = []) -> StringName:
	
	return ""


func watch_state(exclude: Array[StringName] = [], data: Dictionary[StringName, Variant] = {}) -> bool:
	var next_state: StringName = match_state(exclude)
	if next_state != "":
		finished.emit(next_state, data)
		return true
	
	return false
