1
0
mirror of https://github.com/teoxoy/factorio-blueprint-editor.git synced 2025-03-27 21:39:03 +02:00

fix offset by ignoring tiles if there are entities in the blueprint

This commit is contained in:
teoxoy 2021-01-24 16:05:45 +01:00
parent 70f0e7581f
commit b6910441d3

View File

@ -109,27 +109,26 @@ export class Blueprint extends EventEmitter {
}
}
const positionData = [
...(data.entities || []).map(entity => {
const POG = FD.entities[entity.name].flags.includes('placeable_off_grid')
const size = util.switchSizeBasedOnDirection(
FD.entities[entity.name].size,
entity.direction
)
return {
x: POG ? Math.floor(entity.position.x) : entity.position.x,
y: POG ? Math.floor(entity.position.y) : entity.position.y,
w: size.x,
h: size.y,
}
}),
...(data.tiles || []).map(tile => ({
x: tile.position.x + 0.5,
y: tile.position.y + 0.5,
w: 1,
h: 1,
})),
]
const positionData = data.entities
? data.entities.map(entity => {
const POG = FD.entities[entity.name].flags.includes('placeable_off_grid')
const size = util.switchSizeBasedOnDirection(
FD.entities[entity.name].size,
entity.direction
)
return {
x: POG ? Math.floor(entity.position.x) : entity.position.x,
y: POG ? Math.floor(entity.position.y) : entity.position.y,
w: size.x,
h: size.y,
}
})
: data.tiles.map(tile => ({
x: tile.position.x + 0.5,
y: tile.position.y + 0.5,
w: 1,
h: 1,
}))
const minX = positionData.reduce((min, d) => Math.min(min, d.x - d.w / 2), Infinity)
const minY = positionData.reduce((min, d) => Math.min(min, d.y - d.h / 2), Infinity)
const maxX = positionData.reduce((max, d) => Math.max(max, d.x + d.w / 2), -Infinity)