godot-plateformer/_player/states/hook_shooting.gd

39 lines
962 B
GDScript3
Raw Normal View History

2025-12-29 11:54:31 +08:00
extends LimboState
@export var grap_hook_shooting_time: float
var _timer: float
2025-12-31 13:07:31 +08:00
func _setup() -> void:
self.add_event_handler(&"completed_grap_hook",_handle_hook_input_completed)
agent.spawn_hook_comp.hook_reach_finished.connect(_handle_hook_stretching_end)
2025-12-29 11:54:31 +08:00
func _enter() -> void:
agent.locomotion_comp.suspend_movement()
agent.locomotion_comp.stop_dash(true)
2025-12-31 13:07:31 +08:00
var d = agent.get_move_input() as Vector2
agent.spawn_hook_comp.spawn_grap_hook_inst(d)
2025-12-29 11:54:31 +08:00
func _update(delta: float) -> void:
2025-12-31 13:07:31 +08:00
pass
2025-12-29 11:54:31 +08:00
func _exit() -> void:
#agent.locomotion_comp.enable_movement()
pass
2025-12-31 13:07:31 +08:00
func _handle_hook_input_completed() -> bool:
return true
agent.spawn_hook_comp.suspend_hook_stretching(false)
return true
func _handle_hook_stretching_end(reach_end: bool,Anchor:Node2D) -> void:
##如果鈎爪沒有找到任何錨點,則直接退出
if not Anchor:
if agent.is_on_floor():
self.dispatch(&"exit_on_ground")
else:
self.dispatch(&"exit_on_air")
return