Centralise time elapsed code in hideouthelper into one function
This commit is contained in:
parent
f52c42e8b7
commit
b1605b20fe
@ -41,7 +41,6 @@ export class HideoutHelper
|
|||||||
public static bitcoin = "59faff1d86f7746c51718c9c";
|
public static bitcoin = "59faff1d86f7746c51718c9c";
|
||||||
public static expeditionaryFuelTank = "5d1b371186f774253763a656";
|
public static expeditionaryFuelTank = "5d1b371186f774253763a656";
|
||||||
public static maxSkillPoint = 5000;
|
public static maxSkillPoint = 5000;
|
||||||
private static generatorOffMultipler = 0.2;
|
|
||||||
|
|
||||||
protected hideoutConfig: IHideoutConfig;
|
protected hideoutConfig: IHideoutConfig;
|
||||||
|
|
||||||
@ -208,12 +207,7 @@ export class HideoutHelper
|
|||||||
*/
|
*/
|
||||||
protected updateWaterCollectorProductionTimer(pmcData: IPmcData, productionId: string, hideoutProperties: { btcFarmCGs?: number; isGeneratorOn: boolean; waterCollectorHasFilter: boolean; }): void
|
protected updateWaterCollectorProductionTimer(pmcData: IPmcData, productionId: string, hideoutProperties: { btcFarmCGs?: number; isGeneratorOn: boolean; waterCollectorHasFilter: boolean; }): void
|
||||||
{
|
{
|
||||||
let timeElapsed = (this.timeUtil.getTimestamp() - pmcData.Hideout.sptUpdateLastRunTimestamp);
|
const timeElapsed = this.getTimeElapsedSinceLastServerTick(pmcData, hideoutProperties.isGeneratorOn);
|
||||||
if (!hideoutProperties.isGeneratorOn)
|
|
||||||
{
|
|
||||||
timeElapsed = Math.floor(timeElapsed * HideoutHelper.generatorOffMultipler);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hideoutProperties.waterCollectorHasFilter)
|
if (hideoutProperties.waterCollectorHasFilter)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -290,12 +284,7 @@ export class HideoutHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get seconds since last hideout update + now
|
// Get seconds since last hideout update + now
|
||||||
let timeElapsed = this.timeUtil.getTimestamp() - pmcData.Hideout.sptUpdateLastRunTimestamp;
|
const timeElapsed = this.getTimeElapsedSinceLastServerTick(pmcData, hideoutProperties.isGeneratorOn);
|
||||||
if (!hideoutProperties.isGeneratorOn)
|
|
||||||
{
|
|
||||||
// Adjust for running without fuel
|
|
||||||
timeElapsed *= this.databaseServer.getTables().hideout.settings.generatorSpeedWithoutFuel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increment progress by time passed
|
// Increment progress by time passed
|
||||||
pmcData.Hideout.Production[prodId].Progress += timeElapsed;
|
pmcData.Hideout.Production[prodId].Progress += timeElapsed;
|
||||||
@ -572,24 +561,15 @@ export class HideoutHelper
|
|||||||
return waterFilterArea;
|
return waterFilterArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of ticks that have passed since hideout areas were last processed, reduced when generator is off
|
* Create a upd object using passed in parameters
|
||||||
* @param pmcData Player profile
|
* @param stackCount
|
||||||
* @param isGeneratorOn Is the generator on for the duration of elapsed time
|
* @param resourceValue
|
||||||
* @returns Amount of time elapsed in seconds
|
* @param resourceUnitsConsumed
|
||||||
|
* @returns Upd
|
||||||
*/
|
*/
|
||||||
protected getTimeElapsedSinceLastServerTick(pmcData: IPmcData, isGeneratorOn: boolean): number
|
|
||||||
{
|
|
||||||
// Reduce time elapsed (and progress) when generator is off
|
|
||||||
let timeElapsed = this.timeUtil.getTimestamp() - pmcData.Hideout.sptUpdateLastRunTimestamp;
|
|
||||||
if (!isGeneratorOn)
|
|
||||||
{
|
|
||||||
timeElapsed = Math.floor(timeElapsed * HideoutHelper.generatorOffMultipler);
|
|
||||||
}
|
|
||||||
|
|
||||||
return timeElapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected getAreaUpdObject(stackCount: number, resourceValue: number, resourceUnitsConsumed: number): Upd
|
protected getAreaUpdObject(stackCount: number, resourceValue: number, resourceUnitsConsumed: number): Upd
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
@ -679,13 +659,7 @@ export class HideoutHelper
|
|||||||
|
|
||||||
if (this.isProduction(btcProd))
|
if (this.isProduction(btcProd))
|
||||||
{
|
{
|
||||||
let timeElapsedSeconds = this.timeUtil.getTimestamp() - pmcData.Hideout.sptUpdateLastRunTimestamp;
|
const timeElapsedSeconds = this.getTimeElapsedSinceLastServerTick(pmcData, isGeneratorOn);
|
||||||
if (!isGeneratorOn)
|
|
||||||
{
|
|
||||||
// Generator off, reduce time elapsed
|
|
||||||
timeElapsedSeconds = Math.floor(timeElapsedSeconds * HideoutHelper.generatorOffMultipler);
|
|
||||||
}
|
|
||||||
|
|
||||||
btcProd.Progress += timeElapsedSeconds;
|
btcProd.Progress += timeElapsedSeconds;
|
||||||
|
|
||||||
// The wiki has a wrong formula!
|
// The wiki has a wrong formula!
|
||||||
@ -753,6 +727,24 @@ export class HideoutHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of ticks that have passed since hideout areas were last processed, reduced when generator is off
|
||||||
|
* @param pmcData Player profile
|
||||||
|
* @param isGeneratorOn Is the generator on for the duration of elapsed time
|
||||||
|
* @returns Amount of time elapsed in seconds
|
||||||
|
*/
|
||||||
|
protected getTimeElapsedSinceLastServerTick(pmcData: IPmcData, isGeneratorOn: boolean): number
|
||||||
|
{
|
||||||
|
// Reduce time elapsed (and progress) when generator is off
|
||||||
|
let timeElapsed = this.timeUtil.getTimestamp() - pmcData.Hideout.sptUpdateLastRunTimestamp;
|
||||||
|
if (!isGeneratorOn)
|
||||||
|
{
|
||||||
|
timeElapsed *= this.databaseServer.getTables().hideout.settings.generatorSpeedWithoutFuel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return timeElapsed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a count of how many BTC can be gathered by the profile
|
* Get a count of how many BTC can be gathered by the profile
|
||||||
* @param pmcData Profile to look up
|
* @param pmcData Profile to look up
|
||||||
|
Loading…
x
Reference in New Issue
Block a user