extends BaseState

signal StartedWalking

@export var walking_speed := 100
@export var movement_component: MovementComponent
@export var direction_component: FacingDirectionComponent
@export var body: CharacterBody2D

func GetStateEnum() -> PlayerStateMachine.States:
	return PlayerStateMachine.States.WALKING


func Enter(_extra_parameters: Dictionary) -> void:
	StartedWalking.emit()


func Update(_delta: float) -> void:
	if movement_component.movement_vector == Vector2.ZERO:
		state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
		return
	
	var movement_vector := movement_component.movement_vector
	body.velocity = movement_vector * walking_speed
	body.move_and_slide()
	
	direction_component.ChangeDirectionUsingMovementVector(movement_vector)
