First pass at handling the cancellation of a hideout craft.
Doesnt explode server with unhandled exception error Does remove craft from profile Doesnt remove it from client screen until client refresh
This commit is contained in:
parent
f4fce0612e
commit
0316278b15
@ -4,6 +4,7 @@ import { HideoutController } from "@spt-aki/controllers/HideoutController";
|
||||
import { OnUpdate } from "@spt-aki/di/OnUpdate";
|
||||
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
||||
import { IHandleQTEEventRequestData } from "@spt-aki/models/eft/hideout/IHandleQTEEventRequestData";
|
||||
import { IHideoutCancelProductionRequestData } from "@spt-aki/models/eft/hideout/IHideoutCancelProductionRequestData";
|
||||
import { IHideoutContinuousProductionStartRequestData } from "@spt-aki/models/eft/hideout/IHideoutContinuousProductionStartRequestData";
|
||||
import { IHideoutImproveAreaRequestData } from "@spt-aki/models/eft/hideout/IHideoutImproveAreaRequestData";
|
||||
import { IHideoutPutItemInRequestData } from "@spt-aki/models/eft/hideout/IHideoutPutItemInRequestData";
|
||||
@ -129,6 +130,14 @@ export class HideoutCallbacks implements OnUpdate
|
||||
return this.hideoutController.improveArea(sessionId, pmcData, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client/game/profile/items/moving - HideoutCancelProductionCommand
|
||||
*/
|
||||
public cancelProduction(pmcData: IPmcData, request: IHideoutCancelProductionRequestData, sessionId: string): IItemEventRouterResponse
|
||||
{
|
||||
return this.hideoutController.cancelProduction(sessionId, pmcData, request);
|
||||
}
|
||||
|
||||
public async onUpdate(timeSinceLastRun: number): Promise<boolean>
|
||||
{
|
||||
if (timeSinceLastRun > this.hideoutConfig.runIntervalSeconds)
|
||||
|
@ -12,6 +12,7 @@ import { Upd } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { HideoutUpgradeCompleteRequestData } from "@spt-aki/models/eft/hideout/HideoutUpgradeCompleteRequestData";
|
||||
import { IHandleQTEEventRequestData } from "@spt-aki/models/eft/hideout/IHandleQTEEventRequestData";
|
||||
import { IHideoutArea, Stage } from "@spt-aki/models/eft/hideout/IHideoutArea";
|
||||
import { IHideoutCancelProductionRequestData } from "@spt-aki/models/eft/hideout/IHideoutCancelProductionRequestData";
|
||||
import { IHideoutContinuousProductionStartRequestData } from "@spt-aki/models/eft/hideout/IHideoutContinuousProductionStartRequestData";
|
||||
import { IHideoutImproveAreaRequestData } from "@spt-aki/models/eft/hideout/IHideoutImproveAreaRequestData";
|
||||
import { IHideoutProduction } from "@spt-aki/models/eft/hideout/IHideoutProduction";
|
||||
@ -125,7 +126,6 @@ export class HideoutController
|
||||
}
|
||||
|
||||
const hideoutData = this.databaseServer.getTables().hideout.areas.find(area => area.type === request.areaType);
|
||||
|
||||
if (!hideoutData)
|
||||
{
|
||||
this.logger.error(this.localisationService.getText("hideout-unable_to_find_area_in_database", request.areaType));
|
||||
@ -133,7 +133,6 @@ export class HideoutController
|
||||
}
|
||||
|
||||
const ctime = hideoutData.stages[hideoutArea.level + 1].constructionTime;
|
||||
|
||||
if (ctime > 0)
|
||||
{
|
||||
const timestamp = this.timeUtil.getTimestamp();
|
||||
@ -832,7 +831,6 @@ export class HideoutController
|
||||
return this.hideoutHelper.registerProduction(pmcData, request, sessionID);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get quick time event list for hideout
|
||||
* // TODO - implement this
|
||||
@ -909,8 +907,8 @@ export class HideoutController
|
||||
/**
|
||||
* Handle client/game/profile/items/moving - HideoutImproveArea
|
||||
* @param sessionId Session id
|
||||
* @param pmcData profile to improve area in
|
||||
* @param request improve area request data
|
||||
* @param pmcData Profile to improve area in
|
||||
* @param request Improve area request data
|
||||
*/
|
||||
public improveArea(sessionId: string, pmcData: IPmcData, request: IHideoutImproveAreaRequestData): IItemEventRouterResponse
|
||||
{
|
||||
@ -980,6 +978,34 @@ export class HideoutController
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client/game/profile/items/moving HideoutCancelProductionCommand
|
||||
* @param sessionId Session id
|
||||
* @param pmcData Profile with craft to cancel
|
||||
* @param request Cancel production request data
|
||||
* @returns
|
||||
*/
|
||||
public cancelProduction(sessionId: string, pmcData: IPmcData, request: IHideoutCancelProductionRequestData): IItemEventRouterResponse
|
||||
{
|
||||
const output = this.eventOutputHolder.getOutput(sessionId);
|
||||
|
||||
const craftToCancel = pmcData.Hideout.Production[request.recipeId];
|
||||
if (!craftToCancel)
|
||||
{
|
||||
const errorMessage = `Unable to find craft ${request.recipeId} to cancel`;
|
||||
this.logger.error(errorMessage);
|
||||
|
||||
return this.httpResponse.appendErrorToOutput(output, errorMessage);
|
||||
}
|
||||
|
||||
// Remove production from profile
|
||||
delete pmcData.Hideout.Production[request.recipeId];
|
||||
|
||||
// TODO - handle timestamp somehow?
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called every x seconds as part of onUpdate event
|
||||
*/
|
||||
|
@ -383,7 +383,7 @@ export interface Productive
|
||||
ProductionTime?: number
|
||||
GivenItemsInStart?: string[]
|
||||
Interrupted?: boolean
|
||||
/** Used in hideout prodiction.json */
|
||||
/** Used in hideout production.json */
|
||||
needFuelForAllProductionTime?: boolean
|
||||
/** Used when sending data to client */
|
||||
NeedFuelForAllProductionTime?: boolean
|
||||
|
@ -0,0 +1,6 @@
|
||||
export interface IHideoutCancelProductionRequestData
|
||||
{
|
||||
Action: "HideoutCancelProductionCommand"
|
||||
recipeId: string
|
||||
timestamp: number
|
||||
}
|
@ -10,5 +10,6 @@ export enum HideoutEventActions
|
||||
HIDEOUT_CONTINUOUS_PRODUCTION_START = "HideoutContinuousProductionStart",
|
||||
HIDEOUT_TAKE_PRODUCTION = "HideoutTakeProduction",
|
||||
HIDEOUT_RECORD_SHOOTING_RANGE_POINTS = "RecordShootingRangePoints",
|
||||
HIDEOUT_IMPROVE_AREA = "HideoutImproveArea"
|
||||
HIDEOUT_IMPROVE_AREA = "HideoutImproveArea",
|
||||
HIDEOUT_CANCEL_PRODUCTION_COMMAND = "HideoutCancelProductionCommand"
|
||||
}
|
@ -29,7 +29,8 @@ export class HideoutItemEventRouter extends ItemEventRouterDefinition
|
||||
new HandledRoute(HideoutEventActions.HIDEOUT_CONTINUOUS_PRODUCTION_START, false),
|
||||
new HandledRoute(HideoutEventActions.HIDEOUT_TAKE_PRODUCTION, false),
|
||||
new HandledRoute(HideoutEventActions.HIDEOUT_RECORD_SHOOTING_RANGE_POINTS, false),
|
||||
new HandledRoute(HideoutEventActions.HIDEOUT_IMPROVE_AREA, false)
|
||||
new HandledRoute(HideoutEventActions.HIDEOUT_IMPROVE_AREA, false),
|
||||
new HandledRoute(HideoutEventActions.HIDEOUT_CANCEL_PRODUCTION_COMMAND, false)
|
||||
];
|
||||
}
|
||||
|
||||
@ -59,6 +60,8 @@ export class HideoutItemEventRouter extends ItemEventRouterDefinition
|
||||
return this.hideoutCallbacks.recordShootingRangePoints(pmcData, body, sessionID);
|
||||
case HideoutEventActions.HIDEOUT_IMPROVE_AREA:
|
||||
return this.hideoutCallbacks.improveArea(pmcData, body, sessionID);
|
||||
case HideoutEventActions.HIDEOUT_CANCEL_PRODUCTION_COMMAND:
|
||||
return this.hideoutCallbacks.cancelProduction(pmcData, body, sessionID);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user