Server/project/src/callbacks/HideoutCallbacks.ts

161 lines
5.9 KiB
TypeScript
Raw Normal View History

2023-03-03 16:23:46 +01:00
import { inject, injectable } from "tsyringe";
import { HideoutController } from "../controllers/HideoutController";
import { OnUpdate } from "../di/OnUpdate";
import { IPmcData } from "../models/eft/common/IPmcData";
import { IHandleQTEEventRequestData } from "../models/eft/hideout/IHandleQTEEventRequestData";
import {
IHideoutContinuousProductionStartRequestData
} from "../models/eft/hideout/IHideoutContinuousProductionStartRequestData";
import {
IHideoutImproveAreaRequestData
} from "../models/eft/hideout/IHideoutImproveAreaRequestData";
import { IHideoutPutItemInRequestData } from "../models/eft/hideout/IHideoutPutItemInRequestData";
import {
IHideoutScavCaseStartRequestData
} from "../models/eft/hideout/IHideoutScavCaseStartRequestData";
import {
IHideoutSingleProductionStartRequestData
} from "../models/eft/hideout/IHideoutSingleProductionStartRequestData";
import {
IHideoutTakeItemOutRequestData
} from "../models/eft/hideout/IHideoutTakeItemOutRequestData";
import {
IHideoutTakeProductionRequestData
} from "../models/eft/hideout/IHideoutTakeProductionRequestData";
import { IHideoutToggleAreaRequestData } from "../models/eft/hideout/IHideoutToggleAreaRequestData";
import {
IHideoutUpgradeCompleteRequestData
} from "../models/eft/hideout/IHideoutUpgradeCompleteRequestData";
import { IHideoutUpgradeRequestData } from "../models/eft/hideout/IHideoutUpgradeRequestData";
import { IRecordShootingRangePoints } from "../models/eft/hideout/IRecordShootingRangePoints";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { ConfigTypes } from "../models/enums/ConfigTypes";
import { IHideoutConfig } from "../models/spt/config/IHideoutConfig";
import { ConfigServer } from "../servers/ConfigServer";
@injectable()
export class HideoutCallbacks implements OnUpdate
{
protected hideoutConfig: IHideoutConfig;
constructor(
@inject("HideoutController") protected hideoutController: HideoutController, // TODO: delay needed
@inject("ConfigServer") protected configServer: ConfigServer
)
{
this.hideoutConfig = this.configServer.getConfig(ConfigTypes.HIDEOUT);
}
/**
2023-07-15 15:49:25 +02:00
* Handle HideoutUpgrade event
2023-03-03 16:23:46 +01:00
*/
public upgrade(pmcData: IPmcData, body: IHideoutUpgradeRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.startUpgrade(pmcData, body, sessionID);
}
/**
2023-07-15 15:49:25 +02:00
* Handle HideoutUpgradeComplete event
2023-03-03 16:23:46 +01:00
*/
public upgradeComplete(pmcData: IPmcData, body: IHideoutUpgradeCompleteRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.upgradeComplete(pmcData, body, sessionID);
}
/**
* Handle HideoutPutItemsInAreaSlots
*/
public putItemsInAreaSlots(pmcData: IPmcData, body: IHideoutPutItemInRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.putItemsInAreaSlots(pmcData, body, sessionID);
}
/**
2023-07-15 15:49:25 +02:00
* Handle HideoutTakeItemsFromAreaSlots event
2023-03-03 16:23:46 +01:00
*/
public takeItemsFromAreaSlots(pmcData: IPmcData, body: IHideoutTakeItemOutRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.takeItemsFromAreaSlots(pmcData, body, sessionID);
}
/**
2023-07-15 15:49:25 +02:00
* Handle HideoutToggleArea event
2023-03-03 16:23:46 +01:00
*/
public toggleArea(pmcData: IPmcData, body: IHideoutToggleAreaRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.toggleArea(pmcData, body, sessionID);
}
/**
2023-07-15 15:49:25 +02:00
* Handle HideoutSingleProductionStart event
2023-03-03 16:23:46 +01:00
*/
public singleProductionStart(pmcData: IPmcData, body: IHideoutSingleProductionStartRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.singleProductionStart(pmcData, body, sessionID);
}
/**
2023-07-15 15:49:25 +02:00
* Handle HideoutScavCaseProductionStart event
2023-03-03 16:23:46 +01:00
*/
public scavCaseProductionStart(pmcData: IPmcData, body: IHideoutScavCaseStartRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.scavCaseProductionStart(pmcData, body, sessionID);
}
/**
* Handle HideoutContinuousProductionStart
*/
public continuousProductionStart(pmcData: IPmcData, body: IHideoutContinuousProductionStartRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.continuousProductionStart(pmcData, body, sessionID);
}
/**
2023-07-15 15:49:25 +02:00
* Handle HideoutTakeProduction event
2023-03-03 16:23:46 +01:00
*/
public takeProduction(pmcData: IPmcData, body: IHideoutTakeProductionRequestData, sessionID: string): IItemEventRouterResponse
{
return this.hideoutController.takeProduction(pmcData, body, sessionID);
}
/**
* Handle HideoutQuickTimeEvent
*/
public handleQTEEvent(pmcData: IPmcData, request: IHandleQTEEventRequestData, sessionId: string): IItemEventRouterResponse
{
return this.hideoutController.handleQTEEventOutcome(sessionId, pmcData, request);
}
/**
* Handle client/game/profile/items/moving - RecordShootingRangePoints
*/
public recordShootingRangePoints(pmcData: IPmcData, request: IRecordShootingRangePoints, sessionId: string): IItemEventRouterResponse
{
return this.hideoutController.recordShootingRangePoints(sessionId, pmcData, request);
}
/**
* Handle client/game/profile/items/moving - RecordShootingRangePoints
*/
public improveArea(pmcData: IPmcData, request: IHideoutImproveAreaRequestData, sessionId: string): IItemEventRouterResponse
{
return this.hideoutController.improveArea(sessionId, pmcData, request);
}
public async onUpdate(timeSinceLastRun: number): Promise<boolean>
{
if (timeSinceLastRun > this.hideoutConfig.runIntervalSeconds)
{
this.hideoutController.update();
return true;
}
return false;
}
public getRoute() :string
{
return "aki-hideout";
}
}