From 4289bde0dec25d11de885dcc58bb2175150bd78b 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: Sun, 14 Dec 2025 15:36:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(BulletBase):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AD=90=E5=BC=B9=E5=88=86=E8=A3=82=E5=92=8C=E6=8A=98=E5=B0=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将分裂和折射计算中的临时变量命名更清晰,并简化循环逻辑。使用更直观的变量名提高可读性,同时保持原有功能不变。 --- scripts/Statemachine/BulletBase.gd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index 36c7333..7ac0a8d 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -140,16 +140,18 @@ func tryDestroy(becauseMap: bool = false): queue_free() func trySplit(): if is_instance_valid(launcher) and !isChildSplit: - var launcherSplit = launcher.fields.get(FieldStore.Entity.BULLET_SPLIT) - for i in range(MathTool.shrimpRate(launcherSplit)): - split(i, launcherSplit, launcherSplit - floor(launcherSplit)) + var value = launcher.fields.get(FieldStore.Entity.BULLET_SPLIT) + var total = MathTool.shrimpRate(value) + for i in total: + split(i, total, total - floor(total)) func tryRefract(): if is_instance_valid(launcher) and !isChildRefract: var value = launcher.fields.get(FieldStore.Entity.BULLET_REFRACTION) - for i in range(MathTool.shrimpRate(value)): + var total = MathTool.shrimpRate(value) + for i in total: var entity = EntityTool.findClosetEntity(position, get_tree(), !launcher.isPlayer(), launcher.isPlayer(), [launcher]) if is_instance_valid(entity): - refract(entity, i, value, value - floor(value)) + refract(entity, i, total, value - floor(total)) # 抽象方法 func ai():