2023-03-03 15:23:46 +00:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2023-10-19 17:21:17 +00:00
|
|
|
|
|
|
|
import { PresetHelper } from "@spt-aki/helpers/PresetHelper";
|
|
|
|
import { IPreset } from "@spt-aki/models/eft/common/IGlobals";
|
|
|
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class PresetController
|
|
|
|
{
|
|
|
|
constructor(
|
|
|
|
@inject("PresetHelper") protected presetHelper: PresetHelper,
|
2023-11-15 20:35:05 -05:00
|
|
|
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
2023-03-03 15:23:46 +00:00
|
|
|
)
|
2023-11-15 20:35:05 -05:00
|
|
|
{}
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
public initialize(): void
|
|
|
|
{
|
2023-07-18 15:44:14 +01:00
|
|
|
const presets: IPreset[] = Object.values(this.databaseServer.getTables().globals.ItemPresets);
|
2023-03-03 15:23:46 +00:00
|
|
|
const reverse: Record<string, string[]> = {};
|
|
|
|
|
|
|
|
for (const preset of presets)
|
|
|
|
{
|
|
|
|
const tpl = preset._items[0]._tpl;
|
|
|
|
|
|
|
|
if (!(tpl in reverse))
|
|
|
|
{
|
|
|
|
reverse[tpl] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
reverse[tpl].push(preset._id);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.presetHelper.hydratePresetStore(reverse);
|
|
|
|
}
|
|
|
|
}
|