1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-24 20:42:30 +08:00

refactor: 替换PresetAIs为PresetBulletAI,优化子弹AI逻辑

This commit is contained in:
2025-09-06 18:33:11 +08:00
parent b32f864e84
commit f5db5829a2
14 changed files with 36 additions and 15 deletions
+12
View File
@@ -0,0 +1,12 @@
class_name PresetBulletAI
static func lockLauncher(bullet: BulletBase, launcher: EntityBase, onTexture: bool = false):
bullet.position = launcher.texture.global_position if onTexture else launcher.position
static func forward(bullet: BulletBase, rotation: float):
bullet.forward(Vector2.from_angle(rotation))
static func trace(bullet: BulletBase, target: Vector2, speed: float):
bullet.rotation = lerp_angle(
bullet.rotation,
bullet.position.angle_to_point(target),
speed
)
+10
View File
@@ -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)