mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Display throughput in storage
This commit is contained in:
parent
fc0fd2eb49
commit
f3760e3e0f
@ -5,6 +5,12 @@ import { BaseItem, enumItemType } from "../base_item";
|
|||||||
import { ColorItem } from "../items/color_item";
|
import { ColorItem } from "../items/color_item";
|
||||||
import { ShapeItem } from "../items/shape_item";
|
import { ShapeItem } from "../items/shape_item";
|
||||||
|
|
||||||
|
/** @enum {string} */
|
||||||
|
export const enumStorageDisplayType = {
|
||||||
|
count: "count",
|
||||||
|
rate: "rate",
|
||||||
|
};
|
||||||
|
|
||||||
export class StorageComponent extends Component {
|
export class StorageComponent extends Component {
|
||||||
static getId() {
|
static getId() {
|
||||||
return "Storage";
|
return "Storage";
|
||||||
@ -51,6 +57,8 @@ export class StorageComponent extends Component {
|
|||||||
* We compute an opacity to make sure it doesn't flicker
|
* We compute an opacity to make sure it doesn't flicker
|
||||||
*/
|
*/
|
||||||
this.overlayOpacity = 0;
|
this.overlayOpacity = 0;
|
||||||
|
|
||||||
|
this.displayType = enumStorageDisplayType.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,4 +101,12 @@ export class StorageComponent extends Component {
|
|||||||
this.storedCount++;
|
this.storedCount++;
|
||||||
this.itemsToAnalyze++;
|
this.itemsToAnalyze++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cycleDisplayType() {
|
||||||
|
if (this.displayType === enumStorageDisplayType.count) {
|
||||||
|
this.displayType = enumStorageDisplayType.rate;
|
||||||
|
} else {
|
||||||
|
this.displayType = enumStorageDisplayType.count;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { StorageComponent } from "../components/storage";
|
import { StorageComponent, enumStorageDisplayType } from "../components/storage";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { formatBigNumber, lerp } from "../../core/utils";
|
import { formatBigNumber, lerp } from "../../core/utils";
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { enumLayer } from "../root";
|
import { enumLayer } from "../root";
|
||||||
|
import { enumAnalyticsDataSource } from "../production_analytics";
|
||||||
|
import { globalConfig } from "../../core/config";
|
||||||
|
import { enumItemType } from "../base_item";
|
||||||
|
import { ShapeItem } from "../items/shape_item";
|
||||||
|
|
||||||
export class StorageSystem extends GameSystemWithFilter {
|
export class StorageSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
@ -76,10 +80,25 @@ export class StorageSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
this.storageOverlaySprite.drawCached(parameters, center.x - 15, center.y + 15, 30, 15);
|
this.storageOverlaySprite.drawCached(parameters, center.x - 15, center.y + 15, 30, 15);
|
||||||
|
|
||||||
context.font = "bold 10px GameFont";
|
if (storageComp.displayType === enumStorageDisplayType.count) {
|
||||||
context.textAlign = "center";
|
context.font = "bold 10px GameFont";
|
||||||
context.fillStyle = "#64666e";
|
context.textAlign = "center";
|
||||||
context.fillText(formatBigNumber(storageComp.storedCount), center.x, center.y + 25.5);
|
context.fillStyle = "#64666e";
|
||||||
|
context.fillText(formatBigNumber(storageComp.storedCount), center.x, center.y + 25.5);
|
||||||
|
} else if (storageComp.displayType === enumStorageDisplayType.rate) {
|
||||||
|
const shapeKey = entity.uid.toString() + "," + storageComp.storedItem.serialize();
|
||||||
|
let rate =
|
||||||
|
(this.root.productionAnalytics.getCurrentShapeRate(
|
||||||
|
enumAnalyticsDataSource.deliveredToStorage,
|
||||||
|
shapeKey
|
||||||
|
) /
|
||||||
|
globalConfig.analyticsSliceDurationSeconds) *
|
||||||
|
60;
|
||||||
|
context.font = "bold 7px GameFont";
|
||||||
|
context.textAlign = "center";
|
||||||
|
context.fillStyle = "#64666e";
|
||||||
|
context.fillText("" + formatBigNumber(rate) + " /s", center.x, center.y + 24.5);
|
||||||
|
}
|
||||||
|
|
||||||
context.textAlign = "left";
|
context.textAlign = "left";
|
||||||
context.globalAlpha = 1;
|
context.globalAlpha = 1;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user