From 41d1b544c9b18a3e2f6c64a5f60cb3310a5ed2bd 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: Fri, 23 Jan 2026 23:59:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(BulletBase):=20=E6=B7=BB=E5=8A=A0canDoDupli?= =?UTF-8?q?cate=E6=8E=A7=E5=88=B6=E5=AD=90=E5=BC=B9=E5=88=86=E8=A3=82?= =?UTF-8?q?=E5=92=8C=E6=8A=98=E5=B0=84=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 防止子弹在不应该分裂或折射时执行这些操作,通过新增的canDoDuplicate布尔变量来控制 --- components/Bullets/AcidC.tscn | 1 + scripts/Statemachine/BulletBase.gd | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/Bullets/AcidC.tscn b/components/Bullets/AcidC.tscn index 329d881..2035409 100644 --- a/components/Bullets/AcidC.tscn +++ b/components/Bullets/AcidC.tscn @@ -8,6 +8,7 @@ script = ExtResource("2_nxpf5") speed = 5.0 penerate = 1.0 lifeTime = 4000.0 +canDoDuplicate = false [node name="texture" parent="." index="0"] modulate = Color(1, 0.7075234, 0.6972954, 1) diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index 86e7127..18b0304 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -19,6 +19,7 @@ class_name BulletBase @export var freeAfterSpawn: bool = false @export var knockback: float = 0 # 击退力,物理引擎单位 @export var recoil: float = 0 # 后坐力,物理引擎单位 +@export var canDoDuplicate: bool = true # 是否可以分裂、折射 @onready var animator: AnimationPlayer = $"%animator" @onready var hitbox: CollisionShape2D = $"%hitbox" @@ -135,8 +136,9 @@ func dotLoop(): func tryDestroy(becauseMap: bool = false): if destroying: return destroying = true - trySplit() - tryRefract() + if canDoDuplicate: + trySplit() + tryRefract() await destroy(becauseMap) if autoDestroyAnimation: animator.play("destroy")