Prevent items from being rendered on each other when a belt stalls, closes #1000

This commit is contained in:
tobspr 2020-12-07 19:24:39 +01:00
parent 203cd88ad9
commit 01733c48a3
2 changed files with 18 additions and 2 deletions

View File

@ -5,6 +5,7 @@ export const CHANGELOG = [
entries: [
"Fix item readers and some other buildings slowing up belts, especially if they stalled (inspired by Keterr's fix)",
"Added the ability to edit constant signals by left clicking them",
"Prevent items from being rendered on each other when a belt stalls (inspired by Keterr)",
"You can now add markers in the wire layer (partially by daanbreur)",
"Allow to cycle backwards in the toolbar with SHIFT + Tab (idea by EmeraldBlock)",
"Allow to cycle variants backwards with SHIFT + T",

View File

@ -328,6 +328,21 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
continue;
}
// Limit the progress to the maximum available space on the next belt (also see #1000)
let progress = slot.progress;
const nextBeltPath = slot.cachedBeltPath;
if (nextBeltPath) {
progress = Math.min(
progress,
nextBeltPath.spacingToFirstItem / globalConfig.itemSpacingOnBelts
);
}
// Skip if the item would barely be visible
if (progress < 0.05) {
continue;
}
const realPosition = staticComp.localTileToWorld(slot.pos);
if (!chunk.tileSpaceRectangle.containsPoint(realPosition.x, realPosition.y)) {
// Not within this chunk
@ -337,8 +352,8 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
const realDirection = staticComp.localDirectionToWorld(slot.direction);
const realDirectionVector = enumDirectionToVector[realDirection];
const tileX = realPosition.x + 0.5 + realDirectionVector.x * 0.5 * slot.progress;
const tileY = realPosition.y + 0.5 + realDirectionVector.y * 0.5 * slot.progress;
const tileX = realPosition.x + 0.5 + realDirectionVector.x * 0.5 * progress;
const tileY = realPosition.y + 0.5 + realDirectionVector.y * 0.5 * progress;
const worldX = tileX * globalConfig.tileSize;
const worldY = tileY * globalConfig.tileSize;