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

Fix buildings not working at their advertised speed, closes #440, closes #442, closes #437, closes #449

This commit is contained in:
tobspr
2020-08-29 22:35:30 +02:00
parent 12892dcf54
commit 78fe34840a
17 changed files with 750 additions and 806 deletions

View File

@@ -109,6 +109,11 @@ export class ItemProcessorComponent extends Component {
* How long it takes until we are done with the current items
*/
this.secondsUntilEject = 0;
/**
* How much processing time we have lest from the last tick
*/
this.bonusFromLastTick = 0;
}
/**

View File

@@ -1,58 +1,58 @@
import { types } from "../../savegame/serialization";
import { BaseItem } from "../base_item";
import { Component } from "../component";
import { typeItemSingleton } from "../item_resolver";
const chainBufferSize = 3;
export class MinerComponent extends Component {
static getId() {
return "Miner";
}
static getSchema() {
// cachedMinedItem is not serialized.
return {
lastMiningTime: types.ufloat,
itemChainBuffer: types.array(typeItemSingleton),
};
}
duplicateWithoutContents() {
return new MinerComponent({
chainable: this.chainable,
});
}
constructor({ chainable = false }) {
super();
this.lastMiningTime = 0;
this.chainable = chainable;
/**
* Stores items from other miners which were chained to this
* miner.
* @type {Array<BaseItem>}
*/
this.itemChainBuffer = [];
/**
* @type {BaseItem}
*/
this.cachedMinedItem = null;
}
/**
*
* @param {BaseItem} item
*/
tryAcceptChainedItem(item) {
if (this.itemChainBuffer.length > chainBufferSize) {
// Well, this one is full
return false;
}
this.itemChainBuffer.push(item);
return true;
}
}
import { types } from "../../savegame/serialization";
import { BaseItem } from "../base_item";
import { Component } from "../component";
import { typeItemSingleton } from "../item_resolver";
const chainBufferSize = 6;
export class MinerComponent extends Component {
static getId() {
return "Miner";
}
static getSchema() {
// cachedMinedItem is not serialized.
return {
lastMiningTime: types.ufloat,
itemChainBuffer: types.array(typeItemSingleton),
};
}
duplicateWithoutContents() {
return new MinerComponent({
chainable: this.chainable,
});
}
constructor({ chainable = false }) {
super();
this.lastMiningTime = 0;
this.chainable = chainable;
/**
* Stores items from other miners which were chained to this
* miner.
* @type {Array<BaseItem>}
*/
this.itemChainBuffer = [];
/**
* @type {BaseItem}
*/
this.cachedMinedItem = null;
}
/**
*
* @param {BaseItem} item
*/
tryAcceptChainedItem(item) {
if (this.itemChainBuffer.length > chainBufferSize) {
// Well, this one is full
return false;
}
this.itemChainBuffer.push(item);
return true;
}
}