mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Get shape rate with shape key
This commit is contained in:
parent
9f8c3086e3
commit
790e404556
@ -87,7 +87,7 @@ export class HUDShapeStatisticsHandle {
|
||||
case enumAnalyticsDataSource.produced:
|
||||
case enumAnalyticsDataSource.deliveredToStorage: {
|
||||
let rate =
|
||||
(this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.definition) /
|
||||
(this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.shapeKey) /
|
||||
globalConfig.analyticsSliceDurationSeconds) *
|
||||
60;
|
||||
this.counter.innerText = T.ingame.statistics.shapesPerMinute.replace(
|
||||
@ -136,7 +136,7 @@ export class HUDShapeStatisticsHandle {
|
||||
for (let i = 0; i < globalConfig.statisticsGraphSlices - 2; ++i) {
|
||||
const value = this.root.productionAnalytics.getPastShapeRate(
|
||||
dataSource,
|
||||
this.definition,
|
||||
this.shapeKey,
|
||||
globalConfig.statisticsGraphSlices - i - 2
|
||||
);
|
||||
if (value > maxValue) {
|
||||
|
@ -98,27 +98,27 @@ export class ProductionAnalytics extends BasicSerializableObject {
|
||||
/**
|
||||
* Returns the current rate of a given shape
|
||||
* @param {enumAnalyticsDataSource} dataSource
|
||||
* @param {ShapeDefinition} definition
|
||||
* @param {string} shapeKey
|
||||
*/
|
||||
getCurrentShapeRate(dataSource, definition) {
|
||||
getCurrentShapeRate(dataSource, shapeKey) {
|
||||
const slices = this.history[dataSource];
|
||||
return slices[slices.length - 2][definition.getHash()] || 0;
|
||||
return slices[slices.length - 2][shapeKey] || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rate of a given shape, <historyOffset> frames ago
|
||||
* @param {enumAnalyticsDataSource} dataSource
|
||||
* @param {ShapeDefinition} definition
|
||||
* @param {string} shapeKey
|
||||
* @param {number} historyOffset
|
||||
*/
|
||||
getPastShapeRate(dataSource, definition, historyOffset) {
|
||||
getPastShapeRate(dataSource, shapeKey, historyOffset) {
|
||||
assertAlways(
|
||||
historyOffset >= 0 && historyOffset < globalConfig.statisticsGraphSlices - 1,
|
||||
"Invalid slice offset: " + historyOffset
|
||||
);
|
||||
|
||||
const slices = this.history[dataSource];
|
||||
return slices[slices.length - 2 - historyOffset][definition.getHash()] || 0;
|
||||
return slices[slices.length - 2 - historyOffset][shapeKey] || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user