From 2c1d4906aa90b5ae7836d0904b0a6b77a06e5dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Sat, 21 Mar 2026 17:32:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor(QKSwordBullet):=20=E7=A7=BB=E9=99=A4at?= =?UTF-8?q?tackedTracer=E5=8F=98=E9=87=8F=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=91=BD=E4=B8=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用tryDestroy()替代attackedTracer标记,简化代码逻辑 移除不再需要的attackedTracer变量 --- scripts/Contents/Bullets/QKSword.gd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/Contents/Bullets/QKSword.gd b/scripts/Contents/Bullets/QKSword.gd index 9f51054..122fb69 100644 --- a/scripts/Contents/Bullets/QKSword.gd +++ b/scripts/Contents/Bullets/QKSword.gd @@ -2,7 +2,6 @@ extends BulletBase class_name QKSwordBullet var tracer: EntityBase -var attackedTracer: bool = false var spawnSpeed: float = 1 func register(): @@ -10,7 +9,7 @@ func register(): animator.speed_scale = spawnSpeed lifeTime /= spawnSpeed func ai(): - if is_instance_valid(tracer) && !attackedTracer: + if is_instance_valid(tracer): look_at(tracer.getTrackingAnchor()) if timeLived() > 1000 / spawnSpeed: PresetBulletAI.forward(self , rotation) # 前进 @@ -19,7 +18,7 @@ func ai(): hitbox.disabled = true func succeedToHit(_dmg: float, entity: EntityBase): if entity == tracer: - attackedTracer = true # 只需要命中一次目标就不需要继续前进了 + tryDestroy() # 只需要命中一次目标就不需要继续前进了 EffectController.create( ComponentManager.getEffect("FooExplosion"), entity.texture.global_position