Attempt2/src/classes/movement_component.gd

83 lines
2.1 KiB
GDScript

class_name MovementComponent
extends Node
## Movement component
# attempts to interact with movement of the scene root without knowing what
# it is. It can be perhaps a static body or kinematicbody
# it doesn't actually move a node, that's what the state machine does
# but it does keep track of velocity
# I can't give it an actor node or a direct reference.
# It can use a number of detection components to help inform decisions.
export var debug_component: bool = false
onready var desired_movement_vector: Vector2 = Vector2(0,0)
var current_movement_state:String
# Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player.
var velocity = Vector2(0,0)
var momentum = Vector2(0,0)
var acceleration = Vector2(0,0)
var sim_velocity = Vector2(0,0)
#Can't use floats here, switched to constants.
#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT}
var attack_function: FuncRef
const UP = -1.0
const DOWN = 1.0
const LEFT = -1.0
const RIGHT = 1.0
func process_physics(delta):
pass
func process(delta):
pass
func process_input(event: InputEvent):
pass
# A Series of helper functions
func go_up():
desired_movement_vector.y = UP
func go_down():
desired_movement_vector.y = DOWN
func go_left():
desired_movement_vector.x = LEFT
func go_right():
desired_movement_vector.x = RIGHT
func stop():
desired_movement_vector = Vector2(0,0)
# Return the desired direction of movement for the character
# in the range [-1, 1], where positive values indicate a desire
# to move to the right and negative values to the left.
func get_movement_direction() -> float:
return desired_movement_vector.x
# Return a boolean indicating if the character wants to jump
func wants_jump() -> bool:
return false
# Return a boolean indicating if the character wants to attack
func wants_shoot() -> bool:
return false
# Return a boolean indicating if the character wants to dash
func wants_dash() -> bool:
return false
func wants_roll() -> bool:
return false
func wants_climb() -> bool:
return false
func get_climb_shape_location() -> Vector2:
return Vector2(-1,-1)