meta data for this page
📚 World/Backpack
📒 Property
📘 backpack.Name
设置背包的名称(同步于UI显示)。
backpack.Name = "Backpack";
📒 Static Function
📘 Backpack.Create()
生成一个新的背包实例。
背包实例是一个抽象的数据类型,通常可用于多数领域,而不仅仅是背包功能。
function Backpack.Create( count: int, name: string = "Backpack" ): Backpack
📒 Function
📘 backpack.SetPropCount()
设置背包容量(格子)。
注意:此方法仅处理背包最大容量,不会考虑溢出的物品处理。
function backpack.SetPropCount( count: int )
📘 backpack.GetPropCount()
获取背包容量(格子)。
function backpack.GetPropCount(): int
📘 backpack.GetValidPropCount()
获取背包已使用容量(格子)。
function backpack.GetValidPropCount(): int
📘 backpack.SetProp()
根据索引设置物品到背包。
此方法可以设置一个空白物品,已达到同RemovePropAt()的效果。
function backpack.SetProp( index: int, propData: Prop ): bool
return是否设置成功
📘 backpack.AddProp()
尝试添加物品到背包。
此方法会自动内部处理,尝试合理的方式添加到背包(自动叠加)。
function backpack.AddProp( propData: Prop, autoResize: bool = false ): int
autoResize如果背包位置不足,是否自动扩容return剩余未添加的数量,如果为-1表示失败,如果为0表示完全添加
📘 backpack.GetProp()
根据索引获取背包物品。
function backpack.GetProp( index: int ): Prop
📘 backpack.RemoveProp()
根据物品对象从背包移除物品(不改变容量)。
function backpack.RemoveProp( prop: Prop ): bool
📘 backpack.RemovePropAt()
根据索引从背包移除物品(不改变容量)。
function backpack.RemovePropAt( index: int ): bool
📘 backpack.RemovePropAmount()
尝试根据物品数量从背包移除物品(不改变容量)。
此方法会自动内部处理,尝试合理的方式从背包移除物品(自动寻找匹配)。
function backpack.RemovePropAmount( propID: int, amount: int ): int
return剩余未移除的数量,如果为-1表示失败,如果为0表示完全移除
📘 backpack.IndexOfProp()
正向查找首个物品的索引。
function backpack.IndexOfProp( propID: int ): int
📘 backpack.LastIndexOfProp()
反向查找首个物品的索引。
function backpack.LastIndexOfProp( propID: int ): int
📘 backpack.TrimProp()
根据物品对象执行整理背包。
function backpack.TrimProp( prop: Prop )
📘 backpack.TrimProp()
根据索引执行整理背包。
function backpack.TrimPropAt( index: int )
📘 backpack.TrimAll()
执行整理背包。
function backpack.TrimAll()