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

fix(Statemachine): 修复物品掉落收集逻辑的条件判断

调整物品掉落状态机的收集逻辑,仅在玩家背包未满时才会被吸引和收集。移除冗余的条件判断,简化代码逻辑。
This commit is contained in:
2025-09-20 17:46:25 +08:00
parent 8ff063865e
commit e2d29599ed
+1 -2
View File
@@ -26,7 +26,7 @@ func _physics_process(_delta):
if is_instance_valid(targetPlayer): if is_instance_valid(targetPlayer):
if collecting: if collecting:
linear_velocity = Vector2.ZERO linear_velocity = Vector2.ZERO
else: elif targetPlayer.inventoryMax[item] > targetPlayer.inventory[item]:
var direction = (targetPlayer.position - position).normalized() var direction = (targetPlayer.position - position).normalized()
var speed = 1000.0 * targetPlayer.fields.get(FieldStore.Entity.GRAVITY) / ((targetPlayer.position - position).length() ** (1 / 3.0)) var speed = 1000.0 * targetPlayer.fields.get(FieldStore.Entity.GRAVITY) / ((targetPlayer.position - position).length() ** (1 / 3.0))
apply_central_force(direction * speed) apply_central_force(direction * speed)
@@ -35,7 +35,6 @@ func _physics_process(_delta):
if targetPlayer.sprinting: if targetPlayer.sprinting:
apply_central_force((position - targetPlayer.texture.global_position).normalized() * targetPlayer.velocity.length() * 10) apply_central_force((position - targetPlayer.texture.global_position).normalized() * targetPlayer.velocity.length() * 10)
else: else:
if targetPlayer.inventoryMax[item] > targetPlayer.inventory[item]:
targetPlayer.collectItem(item, stackCount) targetPlayer.collectItem(item, stackCount)
collect() collect()