Attempt2/lib/classes/state_animated_actor.gd

53 lines
1.5 KiB
GDScript

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
# Movement Speed in Pixels Per Second
# 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 = 0
## Default state gravity is the project's gravity
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
var jerk: float
## 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.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
return movement_parameters