mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
2c1d4906aa
使用tryDestroy()替代attackedTracer标记,简化代码逻辑 移除不再需要的attackedTracer变量
26 lines
696 B
GDScript
26 lines
696 B
GDScript
extends BulletBase
|
|
class_name QKSwordBullet
|
|
|
|
var tracer: EntityBase
|
|
var spawnSpeed: float = 1
|
|
|
|
func register():
|
|
spawnSpeed = randf_range(0.25, 1.75)
|
|
animator.speed_scale = spawnSpeed
|
|
lifeTime /= spawnSpeed
|
|
func ai():
|
|
if is_instance_valid(tracer):
|
|
look_at(tracer.getTrackingAnchor())
|
|
if timeLived() > 1000 / spawnSpeed:
|
|
PresetBulletAI.forward(self , rotation) # 前进
|
|
hitbox.disabled = false
|
|
else:
|
|
hitbox.disabled = true
|
|
func succeedToHit(_dmg: float, entity: EntityBase):
|
|
if entity == tracer:
|
|
tryDestroy() # 只需要命中一次目标就不需要继续前进了
|
|
EffectController.create(
|
|
ComponentManager.getEffect("FooExplosion"),
|
|
entity.texture.global_position
|
|
).shot()
|