2022-05-27 23:13:35 +01:00
|
|
|
import { DependencyContainer, Lifecycle } from "tsyringe";
|
|
|
|
import type { StaticRouterModService } from "../types/services/mod/staticRouter/StaticRouterModService";
|
|
|
|
import type { IMod } from "../types/models/external/mod";
|
|
|
|
import type { ILogger } from "../types/models/spt/utils/ILogger";
|
2022-05-26 22:57:33 +01:00
|
|
|
import { Other } from "./other";
|
|
|
|
import { Items } from "./items";
|
|
|
|
import { Raids } from "./raids";
|
|
|
|
import { Traders } from "./traders";
|
|
|
|
import { Player } from "./player";
|
|
|
|
import { Notifications } from "./Notifications";
|
|
|
|
import { Fixes } from "./fixes";
|
2022-05-27 23:13:35 +01:00
|
|
|
import { AIOConfigHandler } from "./AIOConfigHandler";
|
2022-05-26 22:57:33 +01:00
|
|
|
|
|
|
|
class AIOMod implements IMod
|
|
|
|
{
|
|
|
|
private logger: ILogger;
|
|
|
|
private pkg;
|
|
|
|
|
|
|
|
public load(container: DependencyContainer): void
|
|
|
|
{
|
2022-05-27 23:13:35 +01:00
|
|
|
container.register<AIOConfigHandler>("AIOConfigHandler", AIOConfigHandler, {lifecycle:Lifecycle.Singleton});
|
|
|
|
container.register<Other>("AIOOther", Other, {lifecycle:Lifecycle.Singleton});
|
|
|
|
container.register<Fixes>("AIOFixes", Fixes);
|
|
|
|
container.register<Raids>("AIORaids", Raids);
|
|
|
|
container.register<Items>("AIOItems", Items);
|
|
|
|
container.register<Traders>("AIOTraders", Traders);
|
|
|
|
container.register<Player>("AIOPlayer", Player);
|
|
|
|
container.register<Notifications>("AIONotifications", Notifications);
|
2022-05-26 22:57:33 +01:00
|
|
|
const staticRoute = container.resolve<StaticRouterModService>("StaticRouterModService");
|
2022-05-27 23:13:35 +01:00
|
|
|
container.resolve<ILogger>("WinstonLogger");
|
2022-05-26 22:57:33 +01:00
|
|
|
|
2022-05-27 23:13:35 +01:00
|
|
|
if (container.resolve<AIOConfigHandler>("AIOConfigHandler").getConfig().player.allSkillsMaster)
|
2022-05-26 22:57:33 +01:00
|
|
|
{
|
|
|
|
staticRoute.registerStaticRouter(
|
|
|
|
"AIOModGameVersion",
|
|
|
|
[
|
|
|
|
{
|
|
|
|
url: "/client/game/version/validate",
|
2022-05-27 23:13:35 +01:00
|
|
|
action: (sessionID: string): any =>
|
|
|
|
{
|
|
|
|
return container.resolve<Player>("AIOPlayer").maxSkills(sessionID);
|
2022-05-26 22:57:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"AIOMod"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-05-27 23:13:35 +01:00
|
|
|
if (container.resolve<AIOConfigHandler>("AIOConfigHandler").getConfig().other.preWipeEvents.raidersOnAllMaps)
|
2022-05-26 22:57:33 +01:00
|
|
|
{
|
|
|
|
staticRoute.registerStaticRouter(
|
|
|
|
"AIOModBotGen",
|
|
|
|
[
|
|
|
|
{
|
|
|
|
url: "/client/game/bot/generate",
|
2022-05-27 23:13:35 +01:00
|
|
|
action: (info: any): any =>
|
|
|
|
{
|
|
|
|
return container.resolve<Other>("AIOOther").spawnRaidersEverywhere(info);
|
2022-05-26 22:57:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"AIOMod"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
this.pkg = require("../package.json");
|
|
|
|
this.logger.info(`Loading: ${this.pkg.name} ${this.pkg.version}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
public delayedLoad(container: DependencyContainer): void
|
|
|
|
{
|
2022-05-27 23:13:35 +01:00
|
|
|
container.resolve<Other>("AIOOther").applyChanges();
|
|
|
|
container.resolve<Fixes>("AIOFixes").applyChanges();
|
|
|
|
container.resolve<Raids>("AIORaids").applyChanges();
|
|
|
|
container.resolve<Items>("AIOItems").applyChanges();
|
|
|
|
container.resolve<Traders>("AIOTrader").applyChanges();
|
|
|
|
container.resolve<Player>("AIOPlayer").applyChanges();
|
2022-05-26 22:57:33 +01:00
|
|
|
|
2022-05-27 23:13:35 +01:00
|
|
|
if (container.resolve<AIOConfigHandler>("AIOConfigHandler").getConfig().other.showModLogs)
|
2022-05-26 22:57:33 +01:00
|
|
|
{
|
2022-05-27 23:13:35 +01:00
|
|
|
container.resolve<Notifications>("AIONotifications").sendNotifications()
|
2022-05-26 22:57:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { mod: new AIOMod() };
|