extends State


var direction := Vector2.ZERO


### 	 ACCESSORS 	 ###






### 	 BUILT-IN 	 ###

func _ready() -> void:
	pass




### 	 VIRTUAL 	 ###

func enter_state() -> void:
	direction = (owner.target - owner.global_position).normalized()
	owner.anims.play(owner.get_dir_string(direction))


func update(delta : float) -> void:
	if !owner.go_clean:
		if (owner.target - owner.global_position).length_squared() < 50.0:
			state_machine.set_state("Idle")
		else:
			direction = (owner.target - owner.global_position).normalized()
			owner.velocity = direction * (owner.stats[Astronaut.STAT_TYPES.MVMT_SPEED]/owner.stress_modifier)
			owner.move_and_slide()
	else:
		direction = (owner.panel.global_position - owner.global_position).normalized()
		owner.velocity = direction * (owner.stats[Astronaut.STAT_TYPES.MVMT_SPEED]/owner.stress_modifier)
		owner.move_and_slide()


func exit_state(same : bool = false) -> void:
	if !same:
		owner.go_clean = false
		owner.clean_shape.set_deferred("disabled", true)


### 	 LOGIC 	 ###




### 	 SIGNAL-RESPONSE 	 ###
