class_name GameAnimation # Helpers for HUD slide/warning animations and the per-item dissolve effect. # Pure functions — no state — so no autoload is needed. static func level_hud_slide(node: Node) -> Animation: var animation := Animation.new() var track_index := animation.add_track(Animation.TYPE_BEZIER) animation.track_set_path(track_index, str(node.get_path()) + ":position:x") animation.bezier_track_insert_key(track_index, 0.0, 0.0, Vector2(-0.25, 0), Vector2(0.031, 190.492)) animation.bezier_track_insert_key(track_index, 1.0, 170, Vector2(-0.349, 2.576), Vector2(0.25, 0)) return animation static func level_hud_warning(node: Node) -> Animation: var animation := Animation.new() var track_index := animation.add_track(Animation.TYPE_BEZIER) animation.track_set_path(track_index, str(node.get_path()) + ":position:x") animation.bezier_track_insert_key(track_index, 0.0, 0.0, Vector2(-0.25, 0), Vector2(0, 78.1)) animation.bezier_track_insert_key(track_index, 0.2, 34.9, Vector2(-0.25, 0), Vector2(0, -66)) animation.bezier_track_insert_key(track_index, 0.4, 12.1, Vector2(0, 73.2), Vector2(0, -124.8)) animation.bezier_track_insert_key(track_index, 0.6, -41.9, Vector2(-0.095, 109.2), Vector2(0.062, -58.8)) animation.bezier_track_insert_key(track_index, 0.8, 13.3, Vector2(-0.188, 93.6), Vector2(0.196, 104.4)) animation.bezier_track_insert_key(track_index, 1.0, 0.0, Vector2(-0.155, -135.5), Vector2(0.25, 0)) return animation # Captures `material` in the tween callback so no shared mutable state is # needed (replaces the old `current_material` member from the autoload). static func start_dissolve(node: Node, material: ShaderMaterial) -> void: if material == null: return var tween := node.create_tween() tween.tween_method( func(progress: float) -> void: material.set_shader_parameter("dissolve_amount", ease(progress, 0.4)), 0.0, 1.0, 1.5) \ .set_trans(Tween.TRANS_LINEAR) \ .set_ease(Tween.EASE_IN_OUT)