mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-19 23:14:05 +09:00
fluidmap won't have errenous behaviour at the world edge; tga alpha fix
This commit is contained in:
@@ -4,13 +4,15 @@ import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-27.
|
||||
*/
|
||||
object LandUtil {
|
||||
fun getBlockAddr(world: GameWorld, x: Int, y: Int): BlockAddress =
|
||||
(world.width * y).toLong() + x
|
||||
// coercing and fmod-ing follows ROUNDWORLD rule
|
||||
(world.width * y.coerceIn(0, world.height - 1)).toLong() + x.fmod(world.width)
|
||||
|
||||
fun resolveBlockAddr(world: GameWorld, t: BlockAddress): Pair<Int, Int> =
|
||||
Pair((t % world.width).toInt(), (t / world.width).toInt())
|
||||
@@ -26,4 +28,6 @@ object LandUtil {
|
||||
Terrarum.ingame!!.getActorByID(id)
|
||||
else
|
||||
FactionCodex.getFactionByID(id)
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user