2023-03-03 16:23:46 +01:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2023-10-19 19:21:17 +02:00
|
|
|
|
|
|
|
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
|
|
|
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
export interface OwnerInventoryItems
|
|
|
|
{
|
2023-11-16 22:42:06 +01:00
|
|
|
from: Item[];
|
|
|
|
to: Item[];
|
|
|
|
sameInventory: boolean;
|
|
|
|
isMail: boolean;
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class SecureContainerHelper
|
|
|
|
{
|
2023-11-16 22:42:06 +01:00
|
|
|
constructor(@inject("ItemHelper") protected itemHelper: ItemHelper)
|
|
|
|
{}
|
2023-03-03 16:23:46 +01:00
|
|
|
|
2023-12-14 16:47:01 +01:00
|
|
|
/**
|
|
|
|
* Get an array of the item IDs (NOT tpls) inside a secure container
|
|
|
|
* @param items Inventory items to look for secure container in
|
|
|
|
* @returns Array of ids
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
public getSecureContainerItems(items: Item[]): string[]
|
|
|
|
{
|
2023-11-16 22:42:06 +01:00
|
|
|
const secureContainer = items.find((x) => x.slotId === "SecuredContainer");
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
// No container found, drop out
|
|
|
|
if (!secureContainer)
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
const itemsInSecureContainer = this.itemHelper.findAndReturnChildrenByItems(items, secureContainer._id);
|
|
|
|
|
|
|
|
// Return all items returned and exclude the secure container item itself
|
2023-11-16 22:42:06 +01:00
|
|
|
return itemsInSecureContainer.filter((x) => x !== secureContainer._id);
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
}
|