mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(Statemachine): 添加获取周期计时器方法并增强子弹过滤逻辑
为EntityBase添加getCycleTimer方法以直接获取计时器 修改CycleTimer的forceFilter方法以检查子弹是否正在销毁 更新InfinitySword的hitBullet逻辑以处理内部伤害子弹
This commit is contained in:
@@ -20,4 +20,9 @@ func hitBullet(bullet: BulletBase):
|
|||||||
if !is_instance_valid(launcher): return
|
if !is_instance_valid(launcher): return
|
||||||
if BulletTool.canDamage(bullet, launcher):
|
if BulletTool.canDamage(bullet, launcher):
|
||||||
baseDamage *= rate2 ** bullet.getDamage()
|
baseDamage *= rate2 ** bullet.getDamage()
|
||||||
|
var cycler = launcher.getCycleTimer("internalDamages")
|
||||||
|
if cycler is CycleTimer:
|
||||||
|
if len(cycler.bullets) > 0:
|
||||||
InternalDamageBullet.generateBall(launcher, bullet.launcher, sqrt(baseDamage))
|
InternalDamageBullet.generateBall(launcher, bullet.launcher, sqrt(baseDamage))
|
||||||
|
cycler.bullets[0].tryDestroy()
|
||||||
|
cycler.forceFilter()
|
||||||
|
|||||||
@@ -15,7 +15,13 @@ func lifetime():
|
|||||||
func getStateAngle(index: int):
|
func getStateAngle(index: int):
|
||||||
return lifetime() / period * deg_to_rad(360) - deg_to_rad(360.0 * index / len(bullets))
|
return lifetime() / period * deg_to_rad(360) - deg_to_rad(360.0 * index / len(bullets))
|
||||||
func forceFilter():
|
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):
|
func apply(where: Vector2):
|
||||||
forceFilter()
|
forceFilter()
|
||||||
for index in len(bullets):
|
for index in len(bullets):
|
||||||
|
|||||||
@@ -227,6 +227,8 @@ func getOrCreateCycleTimer(timerName: String, period: float = 1000, distance: fl
|
|||||||
if start: newTimer.start()
|
if start: newTimer.start()
|
||||||
cycleTimers[timerName] = newTimer
|
cycleTimers[timerName] = newTimer
|
||||||
return cycleTimers[timerName]
|
return cycleTimers[timerName]
|
||||||
|
func getCycleTimer(timerName: String):
|
||||||
|
return cycleTimers.get(timerName)
|
||||||
func initHealth(maxHealth: float):
|
func initHealth(maxHealth: float):
|
||||||
fields[FieldStore.Entity.MAX_HEALTH] = maxHealth
|
fields[FieldStore.Entity.MAX_HEALTH] = maxHealth
|
||||||
health = maxHealth
|
health = maxHealth
|
||||||
|
|||||||
Reference in New Issue
Block a user