mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
26 lines
802 B
Kotlin
26 lines
802 B
Kotlin
package net.torvald.terrarum.realestate
|
|
|
|
import net.torvald.terrarum.Terrarum
|
|
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
|
import net.torvald.terrarum.gameworld.BlockAddress
|
|
import net.torvald.terrarum.gameworld.GameWorld
|
|
|
|
/**
|
|
* Created by minjaesong on 16-03-27.
|
|
*/
|
|
object LandUtil {
|
|
fun getBlockAddr(world: GameWorld, x: Int, y: Int): BlockAddress =
|
|
(world.width * y).toLong() + x
|
|
|
|
fun resolveBlockAddr(world: GameWorld, t: BlockAddress): Pair<Int, Int> =
|
|
Pair((t % world.width).toInt(), (t / world.width).toInt())
|
|
|
|
/**
|
|
* Get owner ID as an Actor/Faction
|
|
*/
|
|
fun resolveOwner(id: Int): Any =
|
|
if (id >= 0)
|
|
Terrarum.ingame!!.getActorByID(id)
|
|
else
|
|
FactionCodex.getFactionByID(id)
|
|
} |