1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Improve tunnel performance by caching receivers

This commit is contained in:
tobspr
2020-06-27 11:39:32 +02:00
parent a057d68a8e
commit 5dab3508cd
3 changed files with 193 additions and 70 deletions

View File

@@ -3,6 +3,7 @@ import { Component } from "../component";
import { globalConfig } from "../../core/config";
import { types } from "../../savegame/serialization";
import { gItemRegistry } from "../../core/global_registries";
import { Entity } from "../entity";
/** @enum {string} */
export const enumUndergroundBeltMode = {
@@ -10,6 +11,13 @@ export const enumUndergroundBeltMode = {
receiver: "receiver",
};
/**
* @typedef {{
* entity: Entity,
* distance: number
* }} LinkedUndergroundBelt
*/
export class UndergroundBeltComponent extends Component {
static getId() {
return "UndergroundBelt";
@@ -52,6 +60,13 @@ export class UndergroundBeltComponent extends Component {
* @type {Array<[BaseItem, number]>} Format is [Item, remaining seconds until transfer/ejection]
*/
this.pendingItems = [];
/**
* The linked entity, used to speed up performance. This contains either
* the entrance or exit depending on the tunnel type
* @type {LinkedUndergroundBelt}
*/
this.cachedLinkedEntity = null;
}
/**