class_name SpawnHookComponet extends ComponentBase ##可以通過在這裏添加一個ComponentOwner默認的字段名來讀取輸入方向,默認是為空的。 @export var binded_hook_move_input_property_name: StringName ##用於Grapping Hook的基本Instance const GRAPPING_HOOK = preload("uid://ddwoxlqluxiq5") ##當前的Graphook的實例 var _current_grap_hook_inst: Hook ##钩爪伸长达到动画位置 signal hook_reach_finished(reach_limit: float, anchor: Node2D) ##生成一个Grap Hook func spawn_grap_hook_inst(dir: Vector2) -> Hook: var i = GRAPPING_HOOK.instantiate() as Hook owner.add_child(i) i.init(self,true) i.start_stretching(dir) _current_grap_hook_inst = i i.stretching_finished.connect(_on_hook_stretching_end) return _current_grap_hook_inst func release_cached_hook() -> void: if _current_grap_hook_inst: _current_grap_hook_inst.release_hook_with_transition(true) func get_current_hook_inst() -> Hook: return _current_grap_hook_inst ##尝试关闭hook的延长 func suspend_hook_stretching(force_suspend: bool = false) -> bool: if not _current_grap_hook_inst: return false return _current_grap_hook_inst.end_stretching(force_suspend) ##当Hook stretching 关闭的时候,触发。 func _on_hook_stretching_end(reach_limit,anchor:Node2D) -> void: hook_reach_finished.emit(reach_limit,anchor) ##从当前的hook获取到hook的anchor func get_current_hook_anchor() -> Node2D: return _current_grap_hook_inst._anchor ##是否存在anchor func has_hook_anchor() -> bool: return _current_grap_hook_inst and _current_grap_hook_inst._anchor ##初始化組件 func _init_component() -> void: pass