mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
refactor(武器系统): 优化武器攻击逻辑和能量检查
- 将武器攻击前的条件检查提取为独立方法 canAttackBy - 重构能量检查逻辑,增加 isEnergyEnough 方法 - 简化公鸡角色的输入处理,合并重复代码为 tryLaunch 方法 - 调整钢管武器的冷却时间为 3000.0
This commit is contained in:
@@ -166,9 +166,11 @@ func playSound(sound: String):
|
||||
cloned.play()
|
||||
await cloned.finished
|
||||
cloned.queue_free()
|
||||
func tryAttack(entity: EntityBase):
|
||||
func canAttackBy(entity: EntityBase):
|
||||
cooldownTimer.speedScale = entity.fields.get(FieldStore.Entity.ATTACK_SPEED)
|
||||
if cooldownTimer.isCooldowned():
|
||||
return cooldownTimer.isCooldowned() and entity.isEnergyEnough(needEnergy)
|
||||
func tryAttack(entity: EntityBase):
|
||||
if canAttackBy(entity):
|
||||
var result = await attack(entity)
|
||||
if result:
|
||||
cooldownTimer.start()
|
||||
|
||||
Reference in New Issue
Block a user