mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Make miners cache mined item
Saves two chunk+tile lookups per update, and one chunk+tile lookup per draw.
This commit is contained in:
@@ -15,6 +15,7 @@ export class MinerComponent extends Component {
|
||||
return {
|
||||
lastMiningTime: types.ufloat,
|
||||
chainable: types.bool,
|
||||
minedItem: types.nullable(types.obj(gItemRegistry)),
|
||||
itemChainBuffer: types.array(types.obj(gItemRegistry)),
|
||||
};
|
||||
}
|
||||
@@ -22,12 +23,15 @@ export class MinerComponent extends Component {
|
||||
duplicateWithoutContents() {
|
||||
return new MinerComponent({
|
||||
chainable: this.chainable,
|
||||
minedItem: this.minedItem
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{chainable?: boolean, minedItem?: BaseItem}} param0
|
||||
*/
|
||||
constructor({ chainable = false }) {
|
||||
constructor({ chainable = false, minedItem = null }) {
|
||||
super();
|
||||
this.lastMiningTime = 0;
|
||||
this.chainable = chainable;
|
||||
@@ -38,6 +42,11 @@ export class MinerComponent extends Component {
|
||||
* @type {Array<BaseItem>}
|
||||
*/
|
||||
this.itemChainBuffer = [];
|
||||
|
||||
/**
|
||||
* @type {BaseItem}
|
||||
*/
|
||||
this.minedItem = minedItem;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user