extends State

@onready var timer = $Timer
var dir: Vector3 = Vector3(0,0,0);

func enter(previous_state_path: String, data := {}) -> void:
	timer.start((float)(randi() % 10)/5)
	dir = calc_dir(randi() % 360)

func physics_update(_delta: float) -> void:
	owner.move(dir)

func calc_dir(angle: float) -> Vector3:
	return Vector3(cos(angle), sin(angle), 0)	
	
func _on_timer_timeout() -> void:
	finished.emit(owner.fsm.States.RANDOMMOVEMENT, {})
	#finished.emit(owner.fsm.States.IDLE, {})

func exit() -> void:
	timer.stop()
