ContainerManager

This module handles the management of containers associated with horse attachments that have container behavior, such as saddlebags.

Holds all the utility functions to manage containers on horses.

Require: require("HorseMod/attachments/ContainerManager")

HorseMod.attachments.ContainerManager.ORPHAN_CONTAINERS: table<number, IsoWorldInventoryObject>

Lookup table of containers that were found as horse containers but didn’t manage to directly link to a horse (e.g. horse was out of loaded area). The table maps itemID to world item reference.

HorseMod.attachments.ContainerManager.CONTAINERS_MOD_DATA: HorseMod.ModDataKind<HorseMod.ContainersModData>
HorseMod.attachments.ContainerManager.transferAll(
    player: IsoPlayer,
    srcContainer: ItemContainer,
    destContainer: ItemContainer
): nil

Transfert every items from the srcContainer to the destContainer.

HorseMod.attachments.ContainerManager.registerContainerInformation(
    horse: IsoAnimal,
    slot: HorseMod.AttachmentSlot,
    worldItem?: IsoWorldInventoryObject
): nil

Registers or unregisters the container information for the horse attachment on the specified slot. If worldItem is nil, then the container information is removed, else it is created.

HorseMod.attachments.ContainerManager.setContainerData(
    worldItem: IsoWorldInventoryObject,
    containerInfo: HorseMod.ContainerInformation
): nil

Updates the mod data of the world item to store the container information, and update the position and item reference to track the container.

HorseMod.attachments.ContainerManager.getHorseContainerData(worldItem: IsoWorldInventoryObject): HorseMod.ContainerInformation?

Retrieve possible container information from the world item mod data. If it isn’t a horse container, then nil should be returned.

HorseMod.attachments.ContainerManager.initContainer(
    player: IsoPlayer,
    horse: IsoAnimal,
    slot: HorseMod.AttachmentSlot,
    containerBehavior: HorseMod.ContainerBehavior,
    accessory: InventoryContainer
): nil

Creates and initialize an invisible world container for the horse attachment. Every items from the accessory container are transfered to the invisible container, and the container information is registered to the horse.

HorseMod.attachments.ContainerManager.removeContainer(
    player: IsoPlayer,
    horse: IsoAnimal,
    slot: HorseMod.AttachmentSlot,
    accessory: InventoryContainer
): nil

Transfer all items from the invisible world container back to the accessory container, then delete the world container and unregister it from the horse.

HorseMod.attachments.ContainerManager.isContainer(worldItem: IsoWorldInventoryObject): boolean

Verify if the world item is a horse attachment container.

HorseMod.attachments.ContainerManager.isSearchedContainer(
    worldItem: IsoWorldInventoryObject,
    containerInfo: HorseMod.ContainerInformation
): boolean, number?
HorseMod.attachments.ContainerManager.findContainerOnSquare(square: IsoGridSquare, itemIDSearched: number): IsoWorldInventoryObject?
HorseMod.attachments.ContainerManager.findContainer(
    horse: IsoAnimal,
    containerInfo: HorseMod.ContainerInformation,
    squareHorse: IsoGridSquare
): IsoWorldInventoryObject?

Find the horse container by different means.

HorseMod.attachments.ContainerManager.getContainer(horse: IsoAnimal, slot: HorseMod.AttachmentSlot): IsoWorldInventoryObject?
HorseMod.attachments.ContainerManager.moveWorldItem(
    squareHorse: IsoGridSquare,
    containerInfo: HorseMod.ContainerInformation,
    worldItem: IsoWorldInventoryObject,
    horse: IsoAnimal
): nil

Change the position of the worldItem.

HorseMod.attachments.ContainerManager.track(horse: IsoAnimal): nil

Track and update the position of the horse attachment containers.