map tiles are now saved!
This commit is contained in:
parent
8533be0af8
commit
a7a095ecbf
14 changed files with 220 additions and 151 deletions
|
|
@ -105,19 +105,10 @@ export namespace Converters {
|
|||
}
|
||||
}
|
||||
|
||||
// export function convertMapTilePositionToMapChunkPosition(
|
||||
// tilePosition: TilePositionTable
|
||||
// ): ChunkPositionTable {
|
||||
// return {
|
||||
// x: tilePosition.x / 32,
|
||||
// y: tilePosition.y / 32,
|
||||
// }
|
||||
// }
|
||||
|
||||
export function convertBoundingBox(bb: BoundingBoxTable): MapBoundingBox {
|
||||
export function convertBoundingBox(bb: BoundingBoxRead): MapBoundingBox {
|
||||
return {
|
||||
topLeft: mapTilePosition(bb.left_top as PositionTable),
|
||||
bottomRight: mapTilePosition(bb.right_bottom as PositionTable),
|
||||
topLeft: mapTilePosition(bb.left_top),
|
||||
bottomRight: mapTilePosition(bb.right_bottom),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,14 +57,11 @@ export function handleChunkUpdate(
|
|||
eventType: string,
|
||||
surfaceIndex: uint,
|
||||
position: ChunkPositionTable,
|
||||
area: BoundingBoxTable,
|
||||
area: BoundingBoxRead,
|
||||
) {
|
||||
|
||||
let surface = game.get_surface(surfaceIndex)
|
||||
|
||||
// let x = (position as ChunkPositionTable).x * CHUNK_SIZE
|
||||
// let y = (position as ChunkPositionTable).y * CHUNK_SIZE
|
||||
|
||||
let tiles: LuaTile[] = surface?.find_tiles_filtered({
|
||||
area: area,
|
||||
// position: {x: x, y: y},
|
||||
|
|
@ -81,7 +78,7 @@ export function handleChunkUpdate(
|
|||
objectName: "MapChunk",
|
||||
tiles: createMapTiles(surfaceIndex, convertedTiles),
|
||||
position: Converters.mapChunkPosition(position),
|
||||
area: Converters.convertBoundingBox(area)
|
||||
area: Converters.convertBoundingBox(area),
|
||||
}
|
||||
|
||||
emitEvent(mapChunk, tick, eventType)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
import on_player_built_tile = defines.events.on_player_built_tile;
|
||||
import on_robot_built_tile = defines.events.on_robot_built_tile;
|
||||
|
||||
|
||||
const mapEventIdToName = new LuaTable<defines.Events, keyof typeof defines.events>()
|
||||
for (const [k, v] of pairs(defines.events)) {
|
||||
mapEventIdToName.set(v, k)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue