From ef6e21de78cfc84fe324430abec666f97b5c7821 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, 17 Jan 2026 12:40:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=AD=90=E5=BC=B9=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=90=E5=BC=B9=E5=88=86=E8=A3=82=E5=92=8C?= =?UTF-8?q?=E6=8A=98=E5=B0=84=E9=80=BB=E8=BE=91=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复子弹分裂和折射方法未返回子弹实例的问题,确保子弹能正确添加到场景中。同时在Rooster角色中添加非发布环境下的子弹分裂和折射调试配置。 --- scripts/Contents/Bullets/VectorStar.gd | 2 ++ scripts/Contents/Characters/Rooster.gd | 3 +++ scripts/Statemachine/BulletBase.gd | 12 ++++++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/Contents/Bullets/VectorStar.gd b/scripts/Contents/Bullets/VectorStar.gd index c2bc497..56a2c3a 100644 --- a/scripts/Contents/Bullets/VectorStar.gd +++ b/scripts/Contents/Bullets/VectorStar.gd @@ -19,6 +19,8 @@ func ai(): func split(newBullet: BulletBase, _index: int, _total: int, _lastBullet: float): if newBullet is VectorStar: newBullet.forwarded = false + return newBullet func refract(newBullet: BulletBase, _entity: EntityBase, _index: int, _total: int, _lastBullet: float): if newBullet is VectorStar: newBullet.forwarded = false + return newBullet diff --git a/scripts/Contents/Characters/Rooster.gd b/scripts/Contents/Characters/Rooster.gd index 067ce1c..2d09656 100644 --- a/scripts/Contents/Characters/Rooster.gd +++ b/scripts/Contents/Characters/Rooster.gd @@ -11,6 +11,9 @@ func register(): elif bullet is FoxZhua: EffectController.create(ComponentManager.getEffect("BloodFall"), texture.global_position).shot() ) + if !WorldManager.isRelease(): + fields[FieldStore.Entity.BULLET_SPLIT] = 2 + fields[FieldStore.Entity.BULLET_REFRACTION] = 2 func ai(): texture.play("walk") var direction = Vector2( diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index 437fa72..39d62c0 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -152,7 +152,7 @@ func trySplit(): var cloned = duplicate() as BulletBase cloned.rotation = deg_to_rad(360.0 / total * i) cloned.isChildSplit = true - split(cloned, i, total, last) + get_parent().add_child(split(cloned, i, total, last)) func tryRefract(): if is_instance_valid(launcher) and !isChildRefract: var value = launcher.fields.get(FieldStore.Entity.BULLET_REFRACTION) @@ -164,7 +164,7 @@ func tryRefract(): var cloned = duplicate() as BulletBase cloned.look_at(entity.position) cloned.isChildRefract = true - refract(cloned, entity, i, total, last) + get_parent().add_child(refract(cloned, entity, i, total, last)) # 抽象方法 func firstFrame(): @@ -181,10 +181,10 @@ func succeedToHit(_dmg: float, _entity: EntityBase): pass func register(): pass -func split(_newBullet: BulletBase, _index: int, _total: int, _lastBullet: float): - pass -func refract(_newBullet: BulletBase, _entity: EntityBase, _index: int, _total: int, _lastBullet: float): - pass +func split(newBullet: BulletBase, _index: int, _total: int, _lastBullet: float): + return newBullet +func refract(newBullet: BulletBase, _entity: EntityBase, _index: int, _total: int, _lastBullet: float): + return newBullet static func generate( bullet: PackedScene,