extends Node2D ## Auto-fire KINETIC hardpoint. No player input ever touches this — ## the build expresses itself while the pilot only positions. Draws its ## own range ring so the kill zone is legible (positioning <-> build bet). const PROJECTILE := preload("res://scenes/kinetic_projectile.tscn") @export var fire_interval := 0.4 @export var range_px := 220.0 var _cooldown := 0.0 func _physics_process(delta: float) -> void: _cooldown -= delta if _cooldown > 0.0: return var target := _nearest_enemy() if target == null: return _fire(target) _cooldown = fire_interval func _nearest_enemy() -> Node2D: var best: Node2D = null var best_d := range_px * range_px for e in get_tree().get_nodes_in_group("enemies"): var d: float = global_position.distance_squared_to(e.global_position) if d < best_d: best_d = d best = e return best func _fire(target: Node2D) -> void: var p := PROJECTILE.instantiate() p.direction = (target.global_position - global_position).normalized() p.position = global_position owner.get_parent().add_child(p) func _draw() -> void: draw_arc(Vector2.ZERO, range_px, 0.0, TAU, 64, Color(0.55, 0.7, 0.85, 0.18), 1.0)