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