extends StateAnimatedActor

export (NodePath) var idle_node

onready var idle_state: State = get_node(idle_node)

var flash_color = Color.yellow

func enter() -> void:
	modifier_stack_ref.clear()
	.enter()
	move_component.velocity.x = 0
	#parent.set_hurtbox(false)
	#TODO: Error check if timer was actually instanced
	state_timeout.start()

func exit() -> void:
	.exit()
	animations.modulate = Color.white

func process_input(_event: InputEvent) -> State:
#	move_component.wants_jump() 
	move_component.get_movement_direction()

	return null


func process_frame(delta: float) -> State:

	# Apply a little effect when damage taken.
	#UiManager.debug_text = str(abs(sin((ceil(state_timeout.time_left) - state_timeout.time_left)/.5)))
	animations.modulate = flash_color.linear_interpolate(Color.white, abs(sin((ceil(state_timeout.time_left) - state_timeout.time_left)/.5)))
	
	if state_timeout.time_left == 0:
		return idle_state
	return null


func process_physics(delta: float) -> State:
	move_component.velocity.y += gravity * delta
	#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
	move_component.velocity = parent.transform.x * move_speed
#	if (parent.direction.x > 0):
#		parent.velocity.x = 1 * move_speed
#	else:
#		parent.velocity.x = -1 * move_speed
	move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))

	return null
