chore: run gdformat on all gdscript files

This commit is contained in:
2025-08-19 08:43:13 +02:00
parent efb9f0d92f
commit 77f1d0811c
10 changed files with 69 additions and 24 deletions

View File

@@ -16,17 +16,22 @@ var current_progress: float = 0.0
var damaged_this_attack: Array = []
var is_attacking: bool = false
func _ready() -> void:
attack_path.visible = false
damage = default_damage
func _process(delta: float) -> void:
if timer.is_stopped() and current_progress == 0.0:
timer.start()
if current_progress > 0.95:
reset_attack()
if current_target and is_instance_valid(current_target) and not current_target.is_queued_for_deletion():
if (
current_target
and is_instance_valid(current_target)
and not current_target.is_queued_for_deletion()
):
track_target(current_target)
is_attacking = true
attack_path.visible = true
@@ -37,33 +42,39 @@ func _process(delta: float) -> void:
current_progress = clampf(current_progress, 0.0, 1.0)
path_follow_2d.progress_ratio = current_progress
func reset_attack() -> void:
current_target = null
attack_path.visible = false
current_progress = 0.0
damaged_this_attack = []
is_attacking = false
position = Vector2.ZERO
rotation = 0.0
current_target = null
attack_path.visible = false
current_progress = 0.0
damaged_this_attack = []
is_attacking = false
position = Vector2.ZERO
rotation = 0.0
func set_target(body: Node2D):
current_target = body
is_attacking = true
func track_target(body: Node2D):
var mid_distance = attack_path.curve.get_baked_length() / 2
var mid_distance = attack_path.curve.get_baked_length() / 2
var mid_point: Vector2 = attack_path.curve.sample_baked(mid_distance)
var offset = body.global_position - to_global(mid_point)
var desired_dir = (body.global_position - to_global(mid_point)).normalized()
var start_point_global = attack_path.to_global(attack_path.curve.sample_baked(0))
var end_point_global = attack_path.to_global(attack_path.curve.sample_baked(attack_path.curve.get_baked_length()))
var end_point_global = attack_path.to_global(
attack_path.curve.sample_baked(attack_path.curve.get_baked_length())
)
var curve_dir = (start_point_global - end_point_global).normalized()
var angle_diff = curve_dir.angle_to(desired_dir)
if rotation == 0.0:
rotation = curve_dir.angle_to(desired_dir)
position += offset
func _on_timer_timeout() -> void:
if current_target:
if trigger_area.has_overlapping_areas():
@@ -75,6 +86,7 @@ func _on_timer_timeout() -> void:
if body.is_in_group(GlobalConst.GROUP_ENEMY):
set_target(body)
func _on_attack_area_body_entered(body: Node2D) -> void:
if not attack_path.visible:
return