extends "res://scenes/entities/SimpleMovable.gd"

@onready var audio_player = $AudioStreamPlayer3D


func _ready() -> void:
	if LevelManager.exec_context != "game":
		return
	super._ready()
	update_rotation_point(DIRECTIONS.UP)
	
	InputManager.player_scene = self

func _process(delta):
	
	if driving_object != null:
		update_rotation_point(driving_object.view_direction)
	#print ("left turning? " + str(enable_left_turning))
	#print ("right turning? " + str(enable_right_turning))

func hit():
	if health_node.invulnerable == false:
		audio_player.stream = load("res://sfx/ncl_player_hit.ogg")
		#audio_player.volume_db = -1
		audio_player.pitch_scale = randf_range(0.86, 0.93)
		audio_player.play()
	health_node.hurt()
	#SceneManager.game_scene.update_labels()	

func kill():
	pass
	#health_node.kill()

	

func _on_Health_no_health() -> void:
	pass
	#if SceneManager.game_scene.is_finished:
		#no gameover when the level is already finished :-)
	#	return
	#print ("you died")
	
#	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	#get_tree().change_scene_to_file("res://UI/GameOverScreen.tscn")


func _on_jump_timer_timeout():
	if is_on_floor():
		jump(35)
