1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 23:11:54 +08:00
Files
Dog-Lynx-And-HCN/scripts/Tools/BulletTool.gd
T
fallingshrimp 4990a3e300 feat(角色): 添加Gobo角色及相关资源
添加Gobo角色,包括武器、召唤物和治疗导弹功能
- 新增Gobo角色模型和动画资源
- 实现Gobo武器系统,可召唤Gobo单位
- 添加治疗导弹功能,Gobo受伤时会发射治疗友军
- 优化实体基础类,添加生命值初始化方法
- 修改子弹伤害判定逻辑,支持友军伤害设置
2026-01-28 20:20:55 +08:00

35 lines
1.3 KiB
GDScript

class_name BulletTool
static func fromArea(area: Area2D) -> BulletBase:
if area is BulletBase:
return area as BulletBase
else:
return null
static func canDamage(bullet: BulletBase, target: EntityBase) -> bool:
if !bullet or !target or !bullet.launcher: return false
if target.currentInvinsible: return false
if !GameRule.allowFriendlyFire:
if target.isPlayer() == bullet.launcher.isPlayer() and bullet.launcher.currentFocusedBoss != target and !bullet.allowFriendlyDamage:
return false
if !bullet.canDamageSelf:
if target == bullet.launcher:
return false
return true
static func findClosetBullet(to: Vector2, fromTree: SceneTree) -> BulletBase:
var result: BulletBase = null
var lastDistance = INF
for bullet in fromTree.get_nodes_in_group("bullets"):
if to.distance_to(bullet.position) < lastDistance:
lastDistance = to.distance_to(bullet.position)
result = bullet
return result
static func findClosetBulletCanDamage(to: Vector2, fromTree: SceneTree, target: EntityBase) -> BulletBase:
var result: BulletBase = null
var lastDistance = INF
for bullet in fromTree.get_nodes_in_group("bullets"):
if canDamage(bullet, target):
if to.distance_to(bullet.position) < lastDistance:
lastDistance = to.distance_to(bullet.position)
result = bullet
return result