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

Rework to cache instead of serialize

Using lessons from other PRs
This commit is contained in:
Phlosioneer
2020-06-17 15:36:53 -04:00
parent d4fc2e6dcd
commit f15cd5bcff
3 changed files with 24 additions and 23 deletions

View File

@@ -12,10 +12,10 @@ export class MinerComponent extends Component {
}
static getSchema() {
// cachedMinedItem is not serialized.
return {
lastMiningTime: types.ufloat,
chainable: types.bool,
minedItem: types.nullable(types.obj(gItemRegistry)),
itemChainBuffer: types.array(types.obj(gItemRegistry)),
};
}
@@ -23,14 +23,10 @@ export class MinerComponent extends Component {
duplicateWithoutContents() {
return new MinerComponent({
chainable: this.chainable,
minedItem: this.minedItem,
});
}
/**
* @param {{chainable?: boolean, minedItem?: BaseItem}} param0
*/
constructor({ chainable = false, minedItem = null }) {
constructor({ chainable = false }) {
super();
this.lastMiningTime = 0;
this.chainable = chainable;
@@ -45,7 +41,7 @@ export class MinerComponent extends Component {
/**
* @type {BaseItem}
*/
this.minedItem = minedItem;
this.cachedMinedItem = null;
}
/**