1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-07 04:07:13 +08:00

refactor(bullets): 重命名PresetsAI为PresetAIs并添加地图碰撞检测

将子弹AI预设类从PresetsAI重命名为PresetAIs
为BulletBase添加autoDestroyOnHitMap选项控制地图碰撞销毁
修改多个子弹脚本使用新的PresetAIs类名
为ChickSprint子弹添加地图碰撞伤害逻辑
This commit is contained in:
2025-08-29 18:34:58 +08:00
parent b8887d8d0c
commit a7e05cff65
10 changed files with 24 additions and 13 deletions
+1 -1
View File
@@ -5,4 +5,4 @@ func register():
penerate = 1
func ai():
rotation_degrees += 1
PresetsAI.lockLauncher(self, launcher, true)
PresetAIs.lockLauncher(self, launcher, true)
+4 -1
View File
@@ -6,6 +6,9 @@ func register():
damage = 20
penerate = 1
func ai():
PresetsAI.lockLauncher(self, launcher, true)
PresetAIs.lockLauncher(self, launcher, true)
if !launcher.sprinting:
tryDestroy()
func destroy(beacuseMap: bool):
if beacuseMap:
launcher.takeDamage(self, 0.5)
+2 -2
View File
@@ -7,6 +7,6 @@ func register():
damage = 2
func ai():
canDamageSelf = !(timeLived() >= traceTime)
PresetsAI.forward(self, rotation)
PresetAIs.forward(self, rotation)
if timeLived() < traceTime:
PresetsAI.trace(self, launcher.currentFocusedBoss.position, 0.05)
PresetAIs.trace(self, launcher.currentFocusedBoss.position, 0.05)
+1 -1
View File
@@ -6,4 +6,4 @@ func register():
damage = 5
func ai():
PresetsAI.forward(self, rotation)
PresetAIs.forward(self, rotation)
@@ -1,4 +1,4 @@
class_name PresetsAI
class_name PresetAIs
static func lockLauncher(bullet: BulletBase, launcher: EntityBase, onTexture: bool = false):
bullet.position = launcher.texture.global_position if onTexture else launcher.position
+2 -2
View File
@@ -2,6 +2,6 @@ extends BulletBase
class_name PurpleCrystal
func ai():
PresetsAI.forward(self, rotation)
func destroy():
PresetAIs.forward(self, rotation)
func destroy(_beacuseMap: bool):
EffectController.create(preload("res://components/Effects/PurpleCrystalExplosion.tscn"), global_position).shot()
+1 -1
View File
@@ -4,4 +4,4 @@ class_name Star
func register():
damage = 1
func ai():
PresetsAI.forward(self, rotation)
PresetAIs.forward(self, rotation)
+10 -3
View File
@@ -12,6 +12,7 @@ class_name BulletBase
@export var autoSpawnAnimation: bool = false
@export var autoLoopAnimation: bool = false
@export var autoDestroyAnimation: bool = false
@export var autoDestroyOnHitMap: bool = true
@export var freeAfterSpawn: bool = false
@export var knockback: float = 0 # 击退力,物理引擎单位
@export var recoil: float = 0 # 后坐力,物理引擎单位
@@ -39,6 +40,12 @@ func _ready():
tryDestroy()
if autoLoopAnimation:
animator.play("loop")
body_entered.connect(
func(body):
if body.is_in_group("map"):
if autoDestroyOnHitMap:
tryDestroy(true)
)
func _process(_delta: float) -> void:
if destroying: return
if lifeTime > 0:
@@ -74,10 +81,10 @@ func timeLived():
func dotLoop():
if await applyDot():
await dotLoop()
func tryDestroy():
func tryDestroy(becauseMap: bool = false):
if destroying: return
destroying = true
await destroy()
await destroy(becauseMap)
if autoDestroyAnimation:
animator.play("destroy")
await animator.animation_finished
@@ -86,7 +93,7 @@ func tryDestroy():
# 抽象方法
func ai():
pass
func destroy():
func destroy(_beacuseMap: bool):
pass
func spawn():
pass