1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

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

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