Skip to content

Inventory

abstract class Inventory(
inventoryId: Int,
raw: ItemContainer?,
stack: ItemContainerStackBehaviour? = null
) : Component(), Syncable
Example
fun pickUp(player: Actor, item: WorldItem, bag: InventoryDefinition) {
val inventory = player.allComponents().filterIsInstance<Inventory>().firstOrNull { it.inventoryId == bag.id }
if (inventory == null || inventory.isFull) return player.message("You have no room.")
inventory.add(Item(item.stack.id, item.quantity))
item.remove()
}
open val inventoryId: Int
val raw: ItemContainer
override fun refusalToJoin(entity: rift.entities.Entity): String?
val capacity: Int
fun fill(vararg items: Item)
fun add(
item: Item,
assureFullInsertion: Boolean = true,
beginSlot: Int = -1
): ItemTransaction
fun remove(
item: Item,
assureFullRemoval: Boolean = false,
beginSlot: Int = -1
): ItemTransaction
fun count(item: Int): Int
val freeSlotCount: Int
val isFull: Boolean
fun removeAll(): Unit
fun move(
from: Int,
to: Int
): Unit
val contents: Array<Item?>
override fun syncTo(client: Actor)
override fun markDirty()
var dirty: Boolean