insert 插入物品或装备到库存中的空位置
insert
类型: MethodDeclaration
所属类: Inventory
定义位置: actor.ts
描述
插入物品或装备到库存中的空位置
参数 goods
: 插入货物
参数
参数名 | 类型 | 描述 | 默认值 |
---|---|---|---|
goods | Item | Equipment | - | - |
返回值
类型: void
源代码
位置: 第 4297 行
public insert(goods: Item | Equipment): void {
if (goods.parent === null) {
// 将物品插入到空槽位
let i = this.pointer
const {list} = this
while (list[i]?.order === i) {i++}
list.splice(i, 0, goods)
goods.order = i
goods.parent = this
// 将物品添加到映射表
this.addToMap(goods)
// 设置空槽位起始查找位置
this.pointer = i + 1
this.version++
}
}
文档生成时间:2025/7/7 12:07:06