extends Node

signal paused
signal unpaused

signal changed_scene_to(scene : Utils.GAME_SCENES)

signal alerted_enemies(player_position : Vector2, enemy_group : String)

signal set_anchor
signal reload_anchor
signal anchor_ran_out

signal boss_set_anchor
signal boss_reload_anchor
signal boss_fight_ended
signal boss_changed_health_relative(delta_health : int)
signal boss_changed_health_absolute(abs_health : int)

signal changed_time

signal changed_input_type(input_type : Utils.INPUT_TYPE)

signal changed_remnant_timeline(timeline_index : int)

signal changed_player_position

signal setting_remnant_countdown_max(countdown : float)
signal changed_remnant_countdown_absolute(countdown_new : float)
signal setting_timeshift_countdown_max(countdown : float)
signal changed_timeshift_countdown_absolute(countdown_new : float)

signal entered_door(door_id : int)
signal loaded_room

signal enemy_joined_combat
signal enemy_left_combat

# for music purposes
@warning_ignore("unused_signal")
signal player_died
@warning_ignore("unused_signal")
signal start_game_or_respawn
@warning_ignore("unused_signal")
signal returned_to_main_menu
@warning_ignore("unused_signal")
signal entered_boss_room

@warning_ignore("unused_signal")
signal boss_accessible(accessible : bool)

func _process(_delta: float) -> void:
	if Input.is_action_just_pressed("pause") && Globals.current_scene == Utils.GAME_SCENES.GAME:
		if SceneChanger.mid_change or SceneChanger.mid_animation:
			return
		if Globals.paused:
			unpaused.emit()
			AudioManager.create_audio(SoundEffect.SOUND_EFFECT_TYPE.PAUSE_MENU)
		else:
			paused.emit()
			AudioManager.create_audio(SoundEffect.SOUND_EFFECT_TYPE.PAUSE_MENU)

func change_scene_to(scene : Utils.GAME_SCENES):
	changed_scene_to.emit(scene)

func unpause():
	unpaused.emit()

func alert_enemies(player_position : Vector2, enemy_group : String):
	alerted_enemies.emit(player_position, enemy_group)

func change_time():
	changed_time.emit()

func change_input_type(input_type : Utils.INPUT_TYPE):
	changed_input_type.emit(input_type)

func change_remnant_timeline(timeline_index : int):
	changed_remnant_timeline.emit(timeline_index)

func emit_set_anchor():
	set_anchor.emit()

func emit_reload_anchor():
	reload_anchor.emit()

func set_remnant_countdown_max(countdown_max : float):
	setting_remnant_countdown_max.emit(countdown_max)

func set_timeshift_countdown_max(countdown_max : float):
	setting_timeshift_countdown_max.emit(countdown_max)

func change_remnant_countdown_absolute(countdown_new : float):
	changed_remnant_countdown_absolute.emit(countdown_new)

func change_timeshift_countdown_absolute(countdown_new : float):
	changed_timeshift_countdown_absolute.emit(countdown_new)

func change_player_position():
	changed_player_position.emit()

func enter_door(door_id : int):
	entered_door.emit(door_id)

func load_room():
	loaded_room.emit()

func anchor_run_out():
	anchor_ran_out.emit()

func emit_boss_set_anchor():
	boss_set_anchor.emit()

func emit_boss_reload_anchor():
	boss_reload_anchor.emit()

func enemy_join_combat():
	enemy_joined_combat.emit()

func enemy_leave_combat():
	enemy_left_combat.emit()

func end_boss_fight():
	boss_fight_ended.emit()

func boss_change_health_relative(delta_health : int):
	boss_changed_health_relative.emit(delta_health)

func boss_change_health_absolute(abs_health : int):
	boss_changed_health_absolute.emit(abs_health)
