1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-30 16:01:53 +08:00

refactor(EntityBase): 调整方法顺序以提高代码可读性

将getSprintInitialDisplace和getSprintProgress方法移动到move方法附近,使相关功能代码更集中
This commit is contained in:
2025-09-08 22:27:16 +08:00
parent 45eb1dcb00
commit b1de068892
+4 -4
View File
@@ -160,10 +160,6 @@ func _physics_process(_delta: float) -> void:
trailParticle.emitting = trailing
# 通用方法
func getSprintInitialDisplace():
return displace(velocity) * sprintMultiplier
func getSprintProgress():
return velocity.length() / getSprintInitialDisplace().length()
func applyLevel():
fields[FieldStore.Entity.MAX_HEALTH] *= (1 + GameRule.entityHealthIncreasePerWave * (GameRule.difficulty + 1)) ** level
fields[FieldStore.Entity.DAMAGE_MULTIPILER] *= (1 + GameRule.entityDamageIncreasePerWave * (GameRule.difficulty + 1)) ** level
@@ -174,6 +170,10 @@ func move(direction: Vector2, isSprinting: bool = false):
var currentDirection = sign(direction.x)
if currentDirection != 0:
lastDirection = currentDirection
func getSprintInitialDisplace():
return displace(velocity) * sprintMultiplier
func getSprintProgress():
return velocity.length() / getSprintInitialDisplace().length()
func takeDamage(bullet: BulletBase, crit: bool):
hurtAnimator.play("hurt")
var baseDamage: float = bullet.damage * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)