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

refactor(子弹系统): 重构子弹伤害检测逻辑

将子弹伤害检测逻辑提取到BulletTool工具类中
新增SevenSoul子弹的初始属性和碰撞处理
调整hitbox位置并启用碰撞检测
This commit is contained in:
2025-09-26 22:37:05 +08:00
parent 65d31940de
commit a38d99a998
4 changed files with 26 additions and 5 deletions
+4 -1
View File
@@ -29,6 +29,9 @@ alpha_curve = SubResource("CurveTexture_d1eej")
[node name="SevenSoul" instance=ExtResource("1_c4fl5")]
script = ExtResource("2_egs34")
speed = 0.0
damage = 0.0
penerate = 1.0
lifeTime = 112000.0
[node name="heart" type="Sprite2D" parent="texture" index="1"]
@@ -49,4 +52,4 @@ one_shot = true
local_coords = true
[node name="hitbox" parent="." index="1"]
disabled = true
position = Vector2(100, 0)
+8
View File
@@ -15,6 +15,14 @@ var pingAfterGeneration: float = 5000
@onready var heart = $"%heart"
@onready var effect: GPUParticles2D = $"%effect"
func register():
area_entered.connect(
func(area):
var bullet = BulletTool.fromArea(area)
if bullet and BulletTool.canDamage(bullet, launcher):
launcher.tryHeal(1)
launcher.storeEnergy(damage * 0.25)
)
func spawn():
modulate = Color(colors[index % colors.size()])
effect.emitting = true
+1 -4
View File
@@ -81,10 +81,7 @@ func _physics_process(_delta: float) -> void:
func hit(target: Node):
var entity: EntityBase = EntityTool.fromHurtbox(target)
if !entity || !launcher: return
if entity.currentInvinsible: return
if !canDamageSelf && entity == launcher: return
if !indisDamage && !GameRule.allowFriendlyFire:
if entity.isPlayer() == launcher.isPlayer() and launcher.currentFocusedBoss != entity: return
if !BulletTool.canDamage(self, entity): return
var resultDamage = entity.takeDamage(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE) + GameRule.critRateInfluenceByLuckValue * launcher.fields[FieldStore.Entity.LUCK_VALUE]))
succeedToHit(resultDamage, entity)
if MathTool.rate(fullPenerate()):
+13
View File
@@ -0,0 +1,13 @@
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 target.currentInvinsible: return false
if !bullet.canDamageSelf && target == bullet.launcher: return false
if !bullet.is_node_ready() && !GameRule.allowFriendlyFire:
if target.isPlayer() == bullet.launcher.isPlayer() and bullet.launcher.currentFocusedBoss != target: return false
return true