mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-31 08:21:54 +08:00
refactor(Statemachine): 引入CooldownTimer类重构攻击冷却逻辑
将攻击冷却逻辑从EntityBase中提取到独立的CooldownTimer类 简化EntityBase代码并提高可维护性
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
class_name CooldownTimer
|
||||
|
||||
var cooldown: float = 100
|
||||
var lastStart: int = 0
|
||||
|
||||
func isCooldowned():
|
||||
return WorldManager.getTime() - lastStart >= cooldown
|
||||
func startCooldown():
|
||||
var state = isCooldowned()
|
||||
if state:
|
||||
lastStart = WorldManager.getTime()
|
||||
return state
|
||||
Reference in New Issue
Block a user