mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-11 22:27:12 +08:00
refactor: 替换PresetAIs为PresetBulletAI,优化子弹AI逻辑
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
class_name PresetAIs
|
||||
class_name PresetBulletAI
|
||||
|
||||
static func lockLauncher(bullet: BulletBase, launcher: EntityBase, onTexture: bool = false):
|
||||
bullet.position = launcher.texture.global_position if onTexture else launcher.position
|
||||
@@ -0,0 +1,10 @@
|
||||
class_name PresetEntityAI
|
||||
|
||||
static func follow(entity: EntityBase, target: EntityBase, minDistance: float = 100):
|
||||
var delta = target.position - entity.position
|
||||
var distanceOffset = abs(delta.length() - minDistance)
|
||||
if distanceOffset > entity.fields[FieldStore.Entity.MOVEMENT_SPEED] * 10:
|
||||
if delta.length() < minDistance:
|
||||
entity.move(-delta)
|
||||
else:
|
||||
entity.move(delta)
|
||||
@@ -5,4 +5,4 @@ func register():
|
||||
penerate = 1
|
||||
func ai():
|
||||
rotation_degrees += 1
|
||||
PresetAIs.lockLauncher(self, launcher, true)
|
||||
PresetBulletAI.lockLauncher(self, launcher, true)
|
||||
|
||||
@@ -6,7 +6,7 @@ func register():
|
||||
damage = 20
|
||||
penerate = 1
|
||||
func ai():
|
||||
PresetAIs.lockLauncher(self, launcher, true)
|
||||
PresetBulletAI.lockLauncher(self, launcher, true)
|
||||
if !launcher.sprinting:
|
||||
tryDestroy()
|
||||
func destroy(beacuseMap: bool):
|
||||
|
||||
@@ -7,6 +7,6 @@ func register():
|
||||
damage = 2
|
||||
func ai():
|
||||
canDamageSelf = !(timeLived() >= traceTime)
|
||||
PresetAIs.forward(self, rotation)
|
||||
PresetBulletAI.forward(self, rotation)
|
||||
if timeLived() < traceTime:
|
||||
PresetAIs.trace(self, launcher.currentFocusedBoss.getTrackingAnchor(), 0.05)
|
||||
PresetBulletAI.trace(self, launcher.currentFocusedBoss.getTrackingAnchor(), 0.05)
|
||||
|
||||
@@ -6,4 +6,4 @@ func register():
|
||||
damage = 5
|
||||
|
||||
func ai():
|
||||
PresetAIs.forward(self, rotation)
|
||||
PresetBulletAI.forward(self, rotation)
|
||||
|
||||
@@ -11,7 +11,7 @@ func ai():
|
||||
speed *= 1.05
|
||||
speed = clamp(speed, 0, 20)
|
||||
if is_instance_valid(tracer) and timeLived() < maxTraceTime:
|
||||
PresetAIs.trace(self, tracer.getTrackingAnchor(), clamp(speed / 50 * tracePower, 0, 1))
|
||||
PresetAIs.forward(self, rotation)
|
||||
PresetBulletAI.trace(self, tracer.getTrackingAnchor(), clamp(speed / 50 * tracePower, 0, 1))
|
||||
PresetBulletAI.forward(self, rotation)
|
||||
func destroy(_b):
|
||||
EffectController.create(preload("res://components/Effects/LGBTBoom.tscn"), position).shot()
|
||||
|
||||
@@ -2,7 +2,7 @@ extends BulletBase
|
||||
class_name PurpleCrystal
|
||||
|
||||
func ai():
|
||||
PresetAIs.forward(self, rotation)
|
||||
PresetBulletAI.forward(self, rotation)
|
||||
func destroy(_beacuseMap: bool):
|
||||
var eff = EffectController.create(preload("res://components/Effects/PurpleCrystalExplosion.tscn"), global_position)
|
||||
eff.rotation = rotation
|
||||
|
||||
@@ -4,4 +4,4 @@ class_name Star
|
||||
func register():
|
||||
damage = 5
|
||||
func ai():
|
||||
PresetAIs.forward(self, rotation)
|
||||
PresetBulletAI.forward(self, rotation)
|
||||
|
||||
@@ -9,7 +9,7 @@ var rotateSpeed: float = 1
|
||||
func ai():
|
||||
texture.rotation_degrees += rotateSpeed
|
||||
rotateSpeed += 0.25
|
||||
PresetAIs.forward(self, rotation)
|
||||
PresetBulletAI.forward(self, rotation)
|
||||
if timeLived() <= forwardTime:
|
||||
speed = 10 * ((forwardTime - timeLived()) / forwardTime)
|
||||
elif forwarded:
|
||||
|
||||
@@ -17,7 +17,7 @@ func spawn():
|
||||
texture.play("walk")
|
||||
|
||||
func ai():
|
||||
move(currentFocusedBoss.position - position)
|
||||
PresetEntityAI.follow(self, currentFocusedBoss, 0)
|
||||
if currentFocusedBoss.position.distance_to(position) < 200:
|
||||
tryAttack(2)
|
||||
elif currentFocusedBoss.position.distance_to(position) < 700:
|
||||
|
||||
@@ -8,7 +8,7 @@ func register():
|
||||
|
||||
func ai():
|
||||
attackCooldownMap[0] = randi_range(1500, 4000)
|
||||
move(currentFocusedBoss.position - position)
|
||||
PresetEntityAI.follow(self, currentFocusedBoss, 300)
|
||||
tryAttack(0)
|
||||
func attack(type):
|
||||
if type == 0:
|
||||
|
||||
Reference in New Issue
Block a user