From 6e0d0ad89b92404bec72e051364d500d73fa755b 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, 10 May 2026 13:17:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(Statemachine):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=91=A8=E6=9C=9F=E8=AE=A1=E6=97=B6=E5=99=A8?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=B9=B6=E5=A2=9E=E5=BC=BA=E5=AD=90=E5=BC=B9?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为EntityBase添加getCycleTimer方法以直接获取计时器 修改CycleTimer的forceFilter方法以检查子弹是否正在销毁 更新InfinitySword的hitBullet逻辑以处理内部伤害子弹 --- scripts/Contents/Bullets/InfinitySword.gd | 7 ++++++- scripts/Statemachine/CycleTimer.gd | 8 +++++++- scripts/Statemachine/EntityBase.gd | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/Contents/Bullets/InfinitySword.gd b/scripts/Contents/Bullets/InfinitySword.gd index af94f58..0decfd7 100644 --- a/scripts/Contents/Bullets/InfinitySword.gd +++ b/scripts/Contents/Bullets/InfinitySword.gd @@ -20,4 +20,9 @@ func hitBullet(bullet: BulletBase): if !is_instance_valid(launcher): return if BulletTool.canDamage(bullet, launcher): baseDamage *= rate2 ** bullet.getDamage() - InternalDamageBullet.generateBall(launcher, bullet.launcher, sqrt(baseDamage)) + var cycler = launcher.getCycleTimer("internalDamages") + if cycler is CycleTimer: + if len(cycler.bullets) > 0: + InternalDamageBullet.generateBall(launcher, bullet.launcher, sqrt(baseDamage)) + cycler.bullets[0].tryDestroy() + cycler.forceFilter() diff --git a/scripts/Statemachine/CycleTimer.gd b/scripts/Statemachine/CycleTimer.gd index a44008d..e6299c3 100644 --- a/scripts/Statemachine/CycleTimer.gd +++ b/scripts/Statemachine/CycleTimer.gd @@ -15,7 +15,13 @@ func lifetime(): func getStateAngle(index: int): return lifetime() / period * deg_to_rad(360) - deg_to_rad(360.0 * index / len(bullets)) func forceFilter(): - bullets = bullets.filter(is_instance_valid) + bullets = bullets.filter( + func(b): + if b is BulletBase: + return !b.destroying + else: + return false + ) func apply(where: Vector2): forceFilter() for index in len(bullets): diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index b7091ba..901af53 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -227,6 +227,8 @@ func getOrCreateCycleTimer(timerName: String, period: float = 1000, distance: fl if start: newTimer.start() cycleTimers[timerName] = newTimer return cycleTimers[timerName] +func getCycleTimer(timerName: String): + return cycleTimers.get(timerName) func initHealth(maxHealth: float): fields[FieldStore.Entity.MAX_HEALTH] = maxHealth health = maxHealth