Skip to main content

increaseItems 在库存中增加物品数量(如果找不到物品,新建一个实例)

increaseItems

类型: MethodDeclaration

所属类: Inventory

定义位置: actor.ts

描述

在库存中增加物品数量(如果找不到物品,新建一个实例)

参数 id: 物品文件ID

参数 quantity: 物品数量

参数

参数名类型描述默认值
idstring--
quantitynumber--

返回值

类型: void

源代码

位置: 第 4508 行

public increaseItems(id: string, quantity: number): void {
const item = this.get(id)
// 如果存在该物品,则增加数量,否则创建物品
if (item instanceof Item) {
Item.latest = item
Item.increment = quantity
item.increase(quantity)
item.callEvent('itemgain')
}
else {
this.createItems(id, quantity)
}
}

文档生成时间:2025/7/7 12:07:06