mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-30 16:01:53 +08:00
fix(物品系统): 修复物品收集和库存上限问题
在EntityBase.gd中添加物品数量上限检查,防止库存溢出 在ItemDropped.gd中增加收集条件,仅在库存未满时收集物品
This commit is contained in:
@@ -362,7 +362,7 @@ func useItem(items: Dictionary):
|
||||
return state
|
||||
func getItem(items: Dictionary):
|
||||
for item in items:
|
||||
inventory[item] += items[item]
|
||||
inventory[item] = clamp(inventory[item] + items[item], 0, inventoryMax[item])
|
||||
|
||||
func getTrackingAnchor() -> Vector2:
|
||||
return hurtbox.get_node("hitbox").global_position
|
||||
|
||||
@@ -35,8 +35,9 @@ func _physics_process(_delta):
|
||||
if targetPlayer.sprinting:
|
||||
apply_central_force((position - targetPlayer.texture.global_position).normalized() * targetPlayer.velocity.length() * 10)
|
||||
else:
|
||||
targetPlayer.collectItem(item, stackCount)
|
||||
collect()
|
||||
if targetPlayer.inventoryMax[item] > targetPlayer.inventory[item]:
|
||||
targetPlayer.collectItem(item, stackCount)
|
||||
collect()
|
||||
|
||||
func collect():
|
||||
collecting = true
|
||||
|
||||
Reference in New Issue
Block a user