48 lines
1.0 KiB
GDScript
48 lines
1.0 KiB
GDScript
extends State
|
|
|
|
export (NodePath) var idle_node
|
|
|
|
onready var idle_state: State = get_node(idle_node)
|
|
var can_fire = true
|
|
|
|
func enter() -> void:
|
|
.enter()
|
|
parent.set_hurtbox(false)
|
|
state_timeout.start()
|
|
can_fire = true
|
|
|
|
func process_input(_event: InputEvent) -> State:
|
|
# if move_component.get_movement_direction() != 0.0:
|
|
# return move_state
|
|
|
|
# move_component.wants_jump()
|
|
move_component.get_movement_direction()
|
|
|
|
# if Input.is_action_just_pressed('dash'):
|
|
# return dash_state
|
|
return null
|
|
|
|
func process_frame(delta: float) -> State:
|
|
if state_timeout.time_left == 0:
|
|
return idle_state
|
|
return null
|
|
|
|
|
|
func process_physics(delta: float) -> State:
|
|
|
|
if can_fire: # trying to do this in the physics because irrecular behavior
|
|
parent.shoot_projectile()
|
|
can_fire = false
|
|
|
|
parent.velocity.y += gravity * delta
|
|
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
|
|
|
# if move_component.flipped_sprite == true:
|
|
# animations.flip_h = parent.direction.x > 0
|
|
# else:
|
|
# animations.flip_h = parent.direction.x < 0
|
|
|
|
|
|
return null
|
|
|