quicksave (part of the autosaving) is working

This commit is contained in:
minjaesong
2021-09-29 16:51:41 +09:00
parent f6eb567385
commit 60a8382f93
18 changed files with 283 additions and 42 deletions

View File

@@ -22,15 +22,24 @@ object LandUtil {
fun toChunkNum(world: GameWorld, x: Int, y: Int): Int {
// coercing and fmod-ing follows ROUNDWORLD rule. See: GameWorld.coerceXY()
val (x, y) = world.coerceXY(x, y)
return (x / CHUNK_W) + (y / CHUNK_H) * (world.width / CHUNK_W)
return chunkXYtoChunkNum(world, x / CHUNK_W, y / CHUNK_H)
}
fun toChunkIndices(world: GameWorld, x: Int, y: Int): Point2i {
fun toChunkXY(world: GameWorld, x: Int, y: Int): Point2i {
// coercing and fmod-ing follows ROUNDWORLD rule. See: GameWorld.coerceXY()
val (x, y) = world.coerceXY(x, y)
return Point2i(x / CHUNK_W, y / CHUNK_H)
}
fun chunkXYtoChunkNum(world: GameWorld, cx: Int, cy: Int): Int {
val ch = world.height / CHUNK_H
return cx * ch + cy
}
fun chunkNumToChunkXY(world: GameWorld, chunkNum: Int): Point2i {
val ch = world.height / CHUNK_H
return Point2i(chunkNum / ch, chunkNum % ch)
}
fun getBlockAddr(world: GameWorld, x: Int, y: Int): BlockAddress {
// coercing and fmod-ing follows ROUNDWORLD rule. See: GameWorld.coerceXY()
val (x, y) = world.coerceXY(x, y)