2022-08-05 18:02:00 -04:00
|
|
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
|
|
|
import { Logger } from "./logger";
|
2022-08-09 19:51:08 -04:00
|
|
|
import { ContainersConfig } from "../config/containers";
|
2022-08-05 18:02:00 -04:00
|
|
|
import { CommonContainers, SecuredContainers } from "./containertypes";
|
|
|
|
|
|
|
|
export class Containers
|
|
|
|
{
|
2022-08-09 19:51:08 -04:00
|
|
|
private modConfig: ContainersConfig = require("../config/containers.json");
|
2022-08-05 18:02:00 -04:00
|
|
|
private logger: Logger;
|
2022-08-08 20:03:48 -04:00
|
|
|
private tables: DatabaseServer;
|
2022-08-05 18:02:00 -04:00
|
|
|
|
|
|
|
constructor(logger: Logger, databaseServer: DatabaseServer)
|
|
|
|
{
|
|
|
|
this.logger = logger;
|
|
|
|
this.tables = databaseServer.getTables();
|
|
|
|
}
|
|
|
|
|
|
|
|
public updateContainers(): void
|
|
|
|
{
|
|
|
|
const mod = this.modConfig.containers;
|
|
|
|
|
|
|
|
if (mod.commonContainers.enabled)
|
|
|
|
{
|
|
|
|
this.updatingCommonContainers();
|
|
|
|
this.logger.info("Common Containers Patched");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mod.securedContainers.enabled)
|
|
|
|
{
|
|
|
|
this.updatingSecuredContainers();
|
|
|
|
this.logger.info("Secured Containers Patched");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private updatingCommonContainers()
|
|
|
|
{
|
|
|
|
const items = this.tables.templates.items;
|
|
|
|
const mod = this.modConfig.containers.commonContainers;
|
|
|
|
|
|
|
|
for (const [key, value] of Object.entries(CommonContainers))
|
|
|
|
{
|
|
|
|
items[value]._props.Grids[0]._props.cellsH = mod[key].cellsH;
|
|
|
|
items[value]._props.Grids[0]._props.cellsV = mod[key].cellsV;
|
|
|
|
items[value]._props.Width = mod[key].width;
|
|
|
|
items[value]._props.Height = mod[key].height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private updatingSecuredContainers()
|
|
|
|
{
|
|
|
|
const items = this.tables.templates.items;
|
|
|
|
const mod = this.modConfig.containers.securedContainers;
|
|
|
|
|
|
|
|
for (const [key, value] of Object.entries(SecuredContainers))
|
|
|
|
{
|
|
|
|
items[value]._props.Grids[0]._props.cellsH = mod[key].cellsH;
|
|
|
|
items[value]._props.Grids[0]._props.cellsV = mod[key].cellsV;
|
|
|
|
items[value]._props.Width = mod[key].width;
|
|
|
|
items[value]._props.Height = mod[key].height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|