class_name Actor 
extends KinematicBody2D

var velocity = Vector2(0,0)
var direction = Vector2(-1,0)

export var sprite_facing_right: bool = true
export(Array, Resource) var SoundEffects 

onready var movement_animations: AnimatedSprite = $AnimatedSprite

onready var sound_effect_player = $SE_Player

onready var movement_state_machine: StateMachineAnimatedActor = $Controllers/state_machine

onready var movement_component = $Controllers/move_component

var sound_effects_dict: Dictionary

##TODO:
# Can't seem to implement the ready and process node functions
# without causing a double run somehow. Not sure why. 
# not a huge deal because this is mostly to help with 
# interfaces for the state machines.

var last_sound_frame_animation: String = ''
var last_sound_frame: int = -1
func play_sound_frame(animation: String, frame: int ):
	##DEBUG:
	#if animation == 'run' and frame == 6:
	#	print("Do the thign! (", animation + str(frame), ")", " (", last_sound_frame_animation + str(last_sound_frame), ")")
	if animation != last_sound_frame_animation or frame != last_sound_frame:
		last_sound_frame = frame
		last_sound_frame_animation = animation
		var sound_index = animation + str(frame)
		if sound_effects_dict.has(sound_index):
			sound_effect_player.stream = sound_effects_dict[sound_index]
			sound_effect_player.play()
			print("Playing SE: ", sound_index)
