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:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user