mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Fix belt underlays not rendering
This commit is contained in:
parent
b7efda9bf6
commit
d4cbb5b124
@ -32,50 +32,52 @@ export class BeltUnderlaysSystem extends GameSystemWithFilter {
|
|||||||
for (let i = 0; i < contents.length; ++i) {
|
for (let i = 0; i < contents.length; ++i) {
|
||||||
const entity = contents[i];
|
const entity = contents[i];
|
||||||
const underlayComp = entity.components.BeltUnderlays;
|
const underlayComp = entity.components.BeltUnderlays;
|
||||||
if (underlayComp) {
|
if (!underlayComp) {
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
continue;
|
||||||
const underlays = underlayComp.underlays;
|
}
|
||||||
for (let i = 0; i < underlays.length; ++i) {
|
|
||||||
const { pos, direction } = underlays[i];
|
|
||||||
const transformedPos = staticComp.localTileToWorld(pos);
|
|
||||||
|
|
||||||
// Culling
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
if (!chunk.tileSpaceRectangle.containsPoint(transformedPos.x, transformedPos.y)) {
|
const underlays = underlayComp.underlays;
|
||||||
continue;
|
for (let i = 0; i < underlays.length; ++i) {
|
||||||
}
|
const { pos, direction } = underlays[i];
|
||||||
|
const transformedPos = staticComp.localTileToWorld(pos);
|
||||||
|
|
||||||
const destX = transformedPos.x * globalConfig.tileSize;
|
// Culling
|
||||||
const destY = transformedPos.y * globalConfig.tileSize;
|
if (!chunk.tileSpaceRectangle.containsPoint(transformedPos.x, transformedPos.y)) {
|
||||||
|
continue;
|
||||||
// Culling, #2
|
|
||||||
if (
|
|
||||||
parameters.visibleRect.containsRect4Params(
|
|
||||||
destX,
|
|
||||||
destY,
|
|
||||||
globalConfig.tileSize,
|
|
||||||
globalConfig.tileSize
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const angle = enumDirectionToAngle[staticComp.localDirectionToWorld(direction)];
|
|
||||||
|
|
||||||
// SYNC with systems/belt.js:drawSingleEntity!
|
|
||||||
const animationIndex = Math.floor(
|
|
||||||
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
|
|
||||||
globalConfig.itemSpacingOnBelts
|
|
||||||
);
|
|
||||||
|
|
||||||
drawRotatedSprite({
|
|
||||||
parameters,
|
|
||||||
sprite: this.underlayBeltSprites[animationIndex % this.underlayBeltSprites.length],
|
|
||||||
x: destX + globalConfig.halfTileSize,
|
|
||||||
y: destY + globalConfig.halfTileSize,
|
|
||||||
angle: Math.radians(angle),
|
|
||||||
size: globalConfig.tileSize,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const destX = transformedPos.x * globalConfig.tileSize;
|
||||||
|
const destY = transformedPos.y * globalConfig.tileSize;
|
||||||
|
|
||||||
|
// Culling, #2
|
||||||
|
if (
|
||||||
|
!parameters.visibleRect.containsRect4Params(
|
||||||
|
destX,
|
||||||
|
destY,
|
||||||
|
globalConfig.tileSize,
|
||||||
|
globalConfig.tileSize
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const angle = enumDirectionToAngle[staticComp.localDirectionToWorld(direction)];
|
||||||
|
|
||||||
|
// SYNC with systems/belt.js:drawSingleEntity!
|
||||||
|
const animationIndex = Math.floor(
|
||||||
|
((this.root.time.realtimeNow() * speedMultiplier * BELT_ANIM_COUNT * 126) / 42) *
|
||||||
|
globalConfig.itemSpacingOnBelts
|
||||||
|
);
|
||||||
|
|
||||||
|
drawRotatedSprite({
|
||||||
|
parameters,
|
||||||
|
sprite: this.underlayBeltSprites[animationIndex % this.underlayBeltSprites.length],
|
||||||
|
x: destX + globalConfig.halfTileSize,
|
||||||
|
y: destY + globalConfig.halfTileSize,
|
||||||
|
angle: Math.radians(angle),
|
||||||
|
size: globalConfig.tileSize,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user