418d9f2a8f
- Ability to use @spt-aki path alias on the whole project. - Swapped all imports from relative paths, for imports using the path alias. Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/157 Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com> Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
36 lines
969 B
TypeScript
36 lines
969 B
TypeScript
import { inject, injectable } from "tsyringe";
|
|
|
|
import { PresetHelper } from "@spt-aki/helpers/PresetHelper";
|
|
import { IPreset } from "@spt-aki/models/eft/common/IGlobals";
|
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
|
|
|
@injectable()
|
|
export class PresetController
|
|
{
|
|
constructor(
|
|
@inject("PresetHelper") protected presetHelper: PresetHelper,
|
|
@inject("DatabaseServer") protected databaseServer: DatabaseServer
|
|
)
|
|
{ }
|
|
|
|
public initialize(): void
|
|
{
|
|
const presets: IPreset[] = Object.values(this.databaseServer.getTables().globals.ItemPresets);
|
|
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);
|
|
}
|
|
}
|