class_name StateAnimatedActor
extends State
## Animation and movement state class
##
## A state intended to control the movement and animation
## functions of a KinimaticBody2D node.
##
## @WIP

const RELATIVE_DIRECTION = 0

# Movement Speed in Pixels Per Second
export(Vector2) var speed_start = Vector2(0,0)
export(Vector2) var speed_end = Vector2(0,1000) ## Terminal velocity
export(Vector2) var min_acceleration = Vector2(0,0)
export(Vector2) var acceleration = Vector2(0,280)
export(Vector2) var max_acceleration = Vector2(0,0)
export(Vector2) var jerk_factor = Vector2(1,1)
#export(Vector2) var speed_start_positive
#export(Vector2) var speed_end_positive
#export(Vector2) var acceleration_positive
#export(Vector2) var speed_start_negative
#export(Vector2) var speed_end_negative
#export(Vector2) var acceleration_negative

# The base movement speed and accelleration
export var horizontal_speed: float = 60
export var horizontal_acceleration: float = 0
## Movement Speed Offsets (Positive or Negative)
export var horizontal_speed_offset: float = 0
## Applies only if offset applies
export var horizontal_speed_offset_acceleration: float = 0
#export var jerk_factor: float = 1.0

export var vertical_speed: float = 0
export var vertical_acceleration: float = 0
## Movement Speed Offsets (Positive or Negative)
export var vertical_speed_offset: float = 0
## Applies only if offset applies
export var vertical_speed_offset_acceleration: float = 0

export var horizontal_jerk_factor: float = 1.0
export  var vertical_jerk_factor: float = 1.0

## Should this state keep the inertia from previous states
export var preserve_inertia :bool = true

## Whether this state should be considered a grounded state
export var is_grounded :bool = true

## Default state gravity is the project's gravity
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")

## Variables intended to allow state receivers to communicate
var animation_finished: bool = false
var animation_frame :int = -1
var movement_stopped: bool = false

# Not sure if this should be here. probably not
export(Array, String) var animation_sequence

func enter() -> void:

	# Call parent class enter
	.enter()
	animation_finished = false
	movement_stopped = false
	animation_frame = -1
	#jerk = 0

	return

func get_movement_parameters() -> MovementParameters:
	var movement_parameters = MovementParameters.new()

	movement_parameters.debug_name = name
	movement_parameters.set_speed_start(RELATIVE_DIRECTION, speed_start)
	#movement_parameters.speed_start = speed_start
	movement_parameters.set_speed_end(RELATIVE_DIRECTION, speed_end)
	#movement_parameters.speed_end = speed_end
	movement_parameters.set_acceleration(acceleration, min_acceleration, max_acceleration)
	#movement_parameters.acceleration = acceleration
	movement_parameters.jerk_factor = jerk_factor
	
	## Old stuff
#	movement_parameters.base_move_speed.x = horizontal_speed
#	movement_parameters.base_move_acceleration.x = horizontal_acceleration
#	movement_parameters.move_speed_modifier.x = horizontal_speed_offset
#	movement_parameters.move_speed_modifier_acceleration.x = horizontal_speed_offset_acceleration
#	movement_parameters.base_move_speed.y = vertical_speed
#	movement_parameters.base_move_acceleration.y = vertical_acceleration
#	movement_parameters.move_speed_modifier.y = vertical_speed_offset
#	movement_parameters.move_speed_modifier_acceleration.y = vertical_speed_offset_acceleration


	return movement_parameters

