跳到主要内容

count 查找指定的物品或装备数量

count

类型: MethodDeclaration

所属类: Inventory

定义位置: actor.ts

描述

查找指定的物品或装备数量

参数 id: 物品或装备的文件ID

返回值:资产的数量

参数

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

返回值

类型: number

资产的数量

源代码

位置: 第 4714 行

public count(id: string): number {
const list = this.getList(id)
if (!list) return 0
let count = 0
for (const asset of list) {
count += asset instanceof Item ? asset.quantity : 1
}
return count
}

文档生成时间:2026/2/1 16:51:38