class_name StateModifierAnimatedActor
extends StateModifier

## Animation modifier variables
## The name of the animation that could be applied and starting frame
var animation_name: String = ''
var animation_suffix: String = ''
var animation_starting_frame: int = 0
var animation_speed: float

var horizontal_speed: float = 0
var horizontal_acceleration: float = 0
## Movement Speed Offsets (Positive or Negative)
var horizontal_speed_offset: float = 0
## Applies only if offset applies
var horizontal_speed_offset_acceleration: float = 0
var jerk_factor: float = 0

var gravity: int = 0

func reset():
	.reset()
	animation_name = ''
	animation_suffix = ''
	animation_starting_frame = 0

	horizontal_speed = 0
	horizontal_acceleration = 0
	## Movement Speed Offsets (Positive or Negative)
	horizontal_speed_offset = 0
	## Applies only if offset applies
	horizontal_speed_offset_acceleration = 0
	jerk_factor = 0

func copy_StateModifierAnimatedActor(_copy_state: StateModifierAnimatedActor):
	.copy(_copy_state)
	_copy_state.animation_name = animation_name
	_copy_state.animation_starting_frame = animation_starting_frame
	_copy_state.animation_speed = animation_speed
	
	#TODO: finish these
	_copy_state.horizontal_speed = horizontal_speed
	_copy_state.horizontal_acceleration = horizontal_acceleration

func merge_StateModifierAnimatedActor(_merge_from_modifier: StateModifierAnimatedActor):
	.merge(_merge_from_modifier)
	if modifier_type == TYPE.NONE and _merge_from_modifier.modifier_type != TYPE.NONE:
		modifier_type = _merge_from_modifier.modifier_type
	
	#_copy_state.animation_name += animation_name
	match _merge_from_modifier.modifier_type:
		TYPE.ANIMATION_SUFFIX:
			# Attempt to seemlessly transition animations.
			if _merge_from_modifier.animation_suffix != '':
				animation_suffix = _merge_from_modifier.animation_suffix 
		TYPE.REPLACE_ANIMATION:
			if _merge_from_modifier.animation_name != '':
				animation_name = _merge_from_modifier.animation_name
		_: # None
			#print ('physics?')
			horizontal_speed += _merge_from_modifier.horizontal_speed
			horizontal_acceleration += _merge_from_modifier.horizontal_acceleration
			horizontal_speed_offset += _merge_from_modifier.horizontal_speed_offset
			horizontal_speed_offset_acceleration += _merge_from_modifier.horizontal_speed_offset_acceleration
	

	#_copy_state.animation_starting_frame = animation_starting_frame
	#_copy_state.animation_speed = animation_speed


# This is probably not necessary just access properties directly
#func animation_mod_setup( anim_name:String = ''):
#	# If somebody forgot to specify the type
#	if anim_name != '' and modifier_type == TYPE.NONE:
#		modifier_type = TYPE.REPLACE_ANIMATION
#	animation_name = anim_name
##	if parent != null and function_name != "":
##		state_call_function = funcref(parent, function_name)

