1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-18 22:09:20 +00:00

Works with regular layer

This commit is contained in:
isaisstillalive 2020-06-30 23:15:02 +09:00
parent 6f99d49435
commit 3d9f8c9b42

View File

@ -15,20 +15,14 @@ export class ChainableSplitterSystem extends GameSystemWithFilter {
}
update() {
// Precompute effective belt speed
const effectiveBeltSpeed = this.root.hubGoals.getBeltBaseSpeed() * globalConfig.itemSpacingOnBelts;
let progressGrowth = (effectiveBeltSpeed / 0.5) * this.root.dynamicTickrate.deltaSeconds;
if (G_IS_DEV && globalConfig.debug.instantBelts) {
progressGrowth = 1;
}
const beltSpeed = this.getBeltSpeed();
for (let i = 0; i < this.allEntities.length; ++i) {
const entity = this.allEntities[i];
const splitterComp = entity.components.ChainableSplitter;
// First, try to get rid of received item
this.tryEject(entity, progressGrowth);
this.tryEject(entity, beltSpeed);
const item = splitterComp.inputItem;
if (item === null) {
@ -115,4 +109,19 @@ export class ChainableSplitterSystem extends GameSystemWithFilter {
return false;
}
/** @returns {number} */
getBeltSpeed() {
let progressGrowth = 2 * this.root.dynamicTickrate.deltaSeconds;
if (G_IS_DEV && globalConfig.debug.instantBelts) {
progressGrowth = 1;
}
return (
progressGrowth *
this.root.hubGoals.getBeltBaseSpeed(enumLayer.regular) *
globalConfig.beltItemSpacingByLayer[enumLayer.regular]
);
}
}