Fix water collector craft not resetting after completion of craft

This commit is contained in:
Dev 2023-11-16 12:55:57 +00:00
parent 925d9b3f07
commit fce724b380
3 changed files with 33 additions and 3 deletions

View File

@ -740,7 +740,7 @@ export class HideoutController
counterHoursCrafting.value = hoursCrafting; counterHoursCrafting.value = hoursCrafting;
// Null production data now it's complete - will be cleaned up later by update() process // Null production data now it's complete - will be cleaned up later by update() process
pmcData.Hideout.Production[prodId] = null; pmcData.Hideout.Production[prodId].sptIsComplete = true;
}; };
// Remove the old production from output object before its sent to client // Remove the old production from output object before its sent to client
@ -820,8 +820,8 @@ export class HideoutController
const callback = () => const callback = () =>
{ {
// Null production data now it's complete - will be cleaned up later by update() process // Flag as complete - will be cleaned up later by update() process
pmcData.Hideout.Production[prodId] = null; pmcData.Hideout.Production[prodId].sptIsComplete = true;
}; };
return this.inventoryHelper.addItem(pmcData, newReq, output, sessionID, callback, true); return this.inventoryHelper.addItem(pmcData, newReq, output, sessionID, callback, true);

View File

@ -389,6 +389,8 @@ export interface Productive
/** Used when sending data to client */ /** Used when sending data to client */
NeedFuelForAllProductionTime?: boolean NeedFuelForAllProductionTime?: boolean
sptIsScavCase?: boolean sptIsScavCase?: boolean
/** Some crafts are always inProgress, but need to be reset, e.g. water collector */
sptIsComplete?: boolean
} }
export interface Production extends Productive export interface Production extends Productive

View File

@ -92,6 +92,9 @@ export class EventOutputHolder
profileChanges.production = this.getProductionsFromProfileAndFlagComplete(this.jsonUtil.clone(pmcData.Hideout.Production)); profileChanges.production = this.getProductionsFromProfileAndFlagComplete(this.jsonUtil.clone(pmcData.Hideout.Production));
profileChanges.improvements = this.jsonUtil.clone(this.getImprovementsFromProfileAndFlagComplete(pmcData)); profileChanges.improvements = this.jsonUtil.clone(this.getImprovementsFromProfileAndFlagComplete(pmcData));
profileChanges.traderRelations = this.constructTraderRelations(pmcData.TradersInfo); profileChanges.traderRelations = this.constructTraderRelations(pmcData.TradersInfo);
// Fixes container craft from water collector not resetting after collection
this.resetSptIsCompleteFlaggedCrafts(pmcData.Hideout.Production);
} }
/** /**
@ -160,6 +163,13 @@ export class EventOutputHolder
continue; continue;
} }
// Complete and is a water collector craft
// Needed as canister craft (water collector) is continuous
if (production.sptIsComplete && productionKey === "5d5589c1f934db045e6c5492")
{
continue;
}
// Skip completed // Skip completed
if (!production.inProgress) if (!production.inProgress)
{ {
@ -183,4 +193,22 @@ export class EventOutputHolder
return productions; return productions;
} }
/**
* Required as continuous productions don't reset and stay at 100% completion but client thinks it hasn't started
* @param productions Productions in a profile
*/
protected resetSptIsCompleteFlaggedCrafts(productions: Record<string, Productive>): void
{
for (const productionKey in productions)
{
const production = productions[productionKey];
if (production.sptIsComplete)
{
production.sptIsComplete = false;
production.Progress = 0;
production.StartTimestamp = this.timeUtil.getTimestamp();
}
}
}
} }