Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ItemManager

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

  • Returns ItemManager

Properties

Readonly event

event: IEventEmitter<this, IItemManagerEvents> = new EventEmitter<this, E>(this)

Methods

addToContainerInternal

breakContainerOnTile

  • breakContainerOnTile(itemContainer: Item, x: number, y: number, z: number): void
  • Parameters

    • itemContainer: Item
    • x: number
    • y: number
    • z: number

    Returns void

checkMilestones

  • checkMilestones(player: Player, item: Item): void
  • Parameters

    Returns void

computeContainerWeight

  • computeContainerWeight(container: IContainer): number
  • Parameters

    Returns number

copyProperties

  • copyProperties(item: Item, item2: Item): void
  • Parameters

    Returns void

countItemsInContainer

  • Parameters

    Returns number

countItemsInContainerByGroup

craft

create

  • Parameters

    Returns Item

createFake

decayItem

  • decayItem(item: Item, isInInventory: boolean, skipUiUpdates?: boolean): boolean
  • Parameters

    • item: Item
    • isInInventory: boolean
    • Default value skipUiUpdates: boolean = false

    Returns boolean

decayItems

  • decayItems(pids: Set<number>, options: { skipPlayerItems?: undefined | false | true; skipUiUpdates?: undefined | false | true }): boolean
  • Parameters

    • pids: Set<number>
    • options: { skipPlayerItems?: undefined | false | true; skipUiUpdates?: undefined | false | true }
      • Optional skipPlayerItems?: undefined | false | true
      • Optional skipUiUpdates?: undefined | false | true

    Returns boolean

derefenceContainerReference

  • Parameters

    Returns object | undefined

exists

  • exists(item: Item): boolean
  • Parameters

    Returns boolean

generateLookups

  • generateLookups(): void
  • Returns void

getAbsentPlayerWithItemInInventory

  • Parameters

    Returns Player | undefined

getAdjacentContainers

  • getAdjacentContainers(humanOrPosition: Human | IVector3, includeNpcs?: undefined | false | true, ignoreOptions?: undefined | false | true): IContainer[]
  • Parameters

    • humanOrPosition: Human | IVector3
    • Optional includeNpcs: undefined | false | true
    • Optional ignoreOptions: undefined | false | true

    Returns IContainer[]

getBestItemForTier

getContainedContainers

  • Parameters

    Returns IContainer[]

getContainerReference

  • Parameters

    • containable: IContainable | undefined
    • Default value showWarnings: boolean = true

    Returns ContainerReference

getCraftQualityBonus

  • getCraftQualityBonus(item: Item, required?: undefined | false | true): number
  • Parameters

    • item: Item
    • Optional required: undefined | false | true

    Returns number

getDefaultDurability

  • getDefaultDurability(human: Human | undefined, weight: number, itemType: ItemType, getMax?: undefined | false | true): number
  • Parameters

    • human: Human | undefined
    • weight: number
    • itemType: ItemType
    • Optional getMax: undefined | false | true

    Returns number

getDisassemblyComponents

  • Parameters

    Returns Item[]

getDisassemblyComponentsAsItemTypes

getGroupDefault

getGroupItems

getGroups

getItemForHuman

  • Parameters

    Returns Item | undefined

getItemInAdjacentContainersByGroup

  • Parameters

    Returns Item | undefined

getItemInContainer

  • getItemInContainer(container: IContainer, itemTypeSearch: ItemType, ignoreItem?: Item, allowProtectedItems?: boolean): Item | undefined
  • Parameters

    • container: IContainer
    • itemTypeSearch: ItemType
    • Optional ignoreItem: Item
    • Default value allowProtectedItems: boolean = true

    Returns Item | undefined

getItemInContainerByGroup

  • getItemInContainerByGroup(container: IContainer, itemTypeGroupSearch: ItemTypeGroup, ignoreItemId?: undefined | number, allowProtectedItems?: boolean): Item | undefined
  • Parameters

    • container: IContainer
    • itemTypeGroupSearch: ItemTypeGroup
    • Optional ignoreItemId: undefined | number
    • Default value allowProtectedItems: boolean = true

    Returns Item | undefined

getItemInInventoryByGroup

  • getItemInInventoryByGroup(human: Human, itemTypeGroupSearch: ItemTypeGroup, ignoreItemId?: undefined | number): Item | undefined
  • Parameters

    • human: Human
    • itemTypeGroupSearch: ItemTypeGroup
    • Optional ignoreItemId: undefined | number

    Returns Item | undefined

getItemListTranslation

  • Formats a list translation out of an array of items.

    Parameters

    • items: Item[]
    • Optional listEnder: ListEnder | false

      The way the list should end (ie and, or, etc)

    Returns Translation

getItemTranslations

  • Maps each item in the given array to its name translation.

    Parameters

    • items: Item[]
    • Default value article: boolean = true

      Whether the item name translation should include an article

    • Optional formatter: Translation

      A formatting translation that should be used for each item translation

    Returns Translation[]

getItemTypeGroupName

  • Parameters

    • itemType: ItemType | ItemTypeGroup
    • Optional article: undefined | false | true
    • Optional count: undefined | number

    Returns Translation

getItemTypeListTranslation

getItemTypeTranslation

getItemTypes

  • getItemTypes(): ReadonlyArray<ItemType>
  • Returns ReadonlyArray<ItemType>

getItemsByWeight

  • getItemsByWeight(a: number, b: number): number
  • Parameters

    • a: number
    • b: number

    Returns number

getItemsInContainer

  • getItemsInContainer(container: IContainer, includeSubContainers?: boolean, allowProtectedItems?: boolean): Item[]
  • Parameters

    • container: IContainer
    • Default value includeSubContainers: boolean = false
    • Default value allowProtectedItems: boolean = true

    Returns Item[]

getItemsInContainerByGroup

  • Parameters

    Returns Item[]

getItemsInContainerByType

  • getItemsInContainerByType(container: IContainer, itemType: ItemType, includeSubContainers?: boolean, filterText?: undefined | string): Item[]
  • Parameters

    • container: IContainer
    • itemType: ItemType
    • Default value includeSubContainers: boolean = false
    • Optional filterText: undefined | string

    Returns Item[]

getItemsWeight

  • getItemsWeight(items: Item[]): number
  • Parameters

    Returns number

getItemsWithRecipes

  • getItemsWithRecipes(): ReadonlyArray<ItemType>
  • Returns ReadonlyArray<ItemType>

getMagicalWeightCapacity

  • getMagicalWeightCapacity(container: IContainer): number
  • Parameters

    Returns number

getNPCFromInventoryContainer

  • Parameters

    Returns NPC | undefined

getNPCWithItemInInventory

  • Parameters

    Returns NPC | undefined

getOrderedContainerItems

  • getOrderedContainerItems(container: IContainer, allowProtectedItems?: boolean): Item[]
  • Parameters

    • container: IContainer
    • Default value allowProtectedItems: boolean = true

    Returns Item[]

getPlayerFromInventoryContainer

  • getPlayerFromInventoryContainer(containable: IContainable): any
  • Parameters

    Returns any

getPlayerWithItemInInventory

  • Parameters

    Returns Player | undefined

getPoint

  • Parameters

    Returns undefined | Vector3

getQualityBasedOnSkill

  • getQualityBasedOnSkill(itemQuality: Quality | undefined, skillValue: number, allowIncreasedQuality?: boolean, bonusChance?: number): Quality | undefined
  • Parameters

    • itemQuality: Quality | undefined
    • skillValue: number
    • Default value allowIncreasedQuality: boolean = false
    • Default value bonusChance: number = 0

    Returns Quality | undefined

getRandomQuality

  • getRandomQuality(bonusQuality?: number): Quality
  • Parameters

    • Default value bonusQuality: number = 0

    Returns Quality

getTileContainer

  • getTileContainer(x: number, y: number, z: number, tile?: ITile): IContainer
  • Parameters

    • x: number
    • y: number
    • z: number
    • Optional tile: ITile

    Returns IContainer

getWeight

  • Returns the "processed" weight of the given item.

    • If the item is a "raw" item — ie, it was not created from other items, this is the weightFraction lerping the item's min & max weight.
    • If the item is a "constructed" item — ie, it was created from other items, this is the processed weights of all component items added together.

    Processed item weights can also be "tweaked", such as weight additions or reductions.

    deprecated

    This method currently shouldn't be used in production code, as it's to do with the new crafting system. Stay tuned.

    Parameters

    Returns number

  • Uses the old system to get the weight of an item type.

    Parameters

    Returns number

getWeightCapacity

  • getWeightCapacity(container: IContainer, includeMagic?: boolean): number | undefined
  • Parameters

    • container: IContainer
    • Default value includeMagic: boolean = true

    Returns number | undefined

hasAdditionalRequirements

hasRoomInContainer

  • hasRoomInContainer(extraWeight: number, container: IContainer, itemToMove: Item): boolean
  • Parameters

    Returns boolean

hashContainerReference

  • hashContainerReference(container: IContainer): string
  • Parameters

    Returns string

isContainableInAdjacentContainer

  • isContainableInAdjacentContainer(player: Player, containable: IContainable, includeNpcs?: undefined | false | true, ignoreOptions?: undefined | false | true): boolean
  • Parameters

    • player: Player
    • containable: IContainable
    • Optional includeNpcs: undefined | false | true
    • Optional ignoreOptions: undefined | false | true

    Returns boolean

isContainableInContainer

  • Parameters

    Returns boolean

isContainer

  • isContainer(obj: unknown): obj is IContainer
  • Parameters

    • obj: unknown

    Returns obj is IContainer

isFiltered

  • isFiltered(item: ItemType | Item, filterText: string, craftingFilter?: undefined | false | true): boolean
  • Checks if the item type or item is filtered from inventory/crafting/container dialogs.

    Parameters

    • item: ItemType | Item

      The ItemType or Item to check.

    • filterText: string

      The string of text in which to filter for.

    • Optional craftingFilter: undefined | false | true

      True if we are filtering the crafting dialog.

    Returns boolean

isGroup

  • Parameters

    Returns item is ItemTypeGroup

isInGroup

isInInventory

  • Parameters

    Returns boolean

isItemAcceptedAsOffer

  • isItemAcceptedAsOffer(item: ItemType): undefined | false | true
  • Parameters

    Returns undefined | false | true

isItemInContainer

  • Parameters

    Returns boolean

isTileContainer

  • isTileContainer(container: IContainer | undefined): boolean
  • Parameters

    Returns boolean

loadReferences

  • loadReferences(generatedNewWorld: boolean, isTraveling: boolean): void
  • Parameters

    • generatedNewWorld: boolean
    • isTraveling: boolean

    Returns void

loadTileReferences

  • loadTileReferences(): void
  • Returns void

moveAllFromContainerToContainer

  • moveAllFromContainerToContainer(human: Human | undefined, fromContainer: IContainer, toContainer: IContainer, itemType?: ItemType | undefined, ofQuality?: Quality | undefined, checkWeight?: boolean, filterText?: string | undefined, onMoveItem?: undefined | ((item: Item) => void)): Item[]
  • Parameters

    • human: Human | undefined
    • fromContainer: IContainer
    • toContainer: IContainer
    • Optional itemType: ItemType | undefined
    • Optional ofQuality: Quality | undefined
    • Default value checkWeight: boolean = true
    • Default value filterText: string | undefined = undefined
    • Optional onMoveItem: undefined | ((item: Item) => void)

    Returns Item[]

moveAllFromContainerToInventory

  • Parameters

    Returns Item[]

movePlayerItemsToIsland

  • movePlayerItemsToIsland(targetIsland: Island): void
  • Moves all player items to the target island This should be called before switching islands

    Parameters

    Returns void

moveToContainer

  • Parameters

    Returns boolean

placeItemsAroundLocation

  • placeItemsAroundLocation(container: IContainer, x: number, y: number, z: number, skipMessage?: boolean): void
  • Drop items in a 3x3 square around the location

    Parameters

    • container: IContainer
    • x: number
    • y: number
    • z: number
    • Default value skipMessage: boolean = true

    Returns void

reduceDismantleWeight

  • reduceDismantleWeight(createdItems: Item[], itemWeight: number): void
  • Parameters

    • createdItems: Item[]
    • itemWeight: number

    Returns void

remove

  • remove(item: Item, removeContainedItems?: boolean): void
  • Parameters

    • item: Item
    • Default value removeContainedItems: boolean = false

    Returns void

removeContainerItems

  • removeContainerItems(container: IContainer, removeContainedItems?: boolean): void
  • Parameters

    • container: IContainer
    • Default value removeContainedItems: boolean = false

    Returns void

resolveContainer

  • Parameters

    Returns any

saveTileReferences

  • saveTileReferences(): void
  • Returns void

spawn

  • spawn(terrainType: TerrainType, x: number, y: number, z: number): void
  • Used to spawn a random item on the current biome type and at a set location (and terrain type) based on spawnOnWorldGen properties in item descriptions.

    Parameters

    • terrainType: TerrainType

      The terrain type to check.

    • x: number

      The x coordinate to check.

    • y: number

      The y coordinate to check.

    • z: number

      The z coordinate to check.

    Returns void

summonVoidDweller

  • Summons a void dweller based on item worth and chance or provides a hint message.

    Parameters

    • item: Item

      Item to get the worth of.

    • player: Player | NPC

      The player that is dropping the item.

    • point: IVector3

      The point in which we are dropping the item.

    Returns boolean

    True or false based on if we get a message or not.

updateContainedWithin

  • Parameters

    Returns void

updateItemOrder

  • updateItemOrder(container: IContainer, itemOrder: number[] | undefined): void
  • Parameters

    • container: IContainer
    • itemOrder: number[] | undefined

    Returns void

weightTree

  • weightTree(itemType: ItemType, weightType?: WeightType, debug?: boolean, depth?: number): number
  • Parameters

    • itemType: ItemType
    • Default value weightType: WeightType = WeightType.Normal
    • Default value debug: boolean = false
    • Default value depth: number = 0

    Returns number

Generated using TypeDoc