mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-21 07:54:05 +09:00
terrain damage data is now properly removed when the tile is newly placed
This commit is contained in:
25
src/net/torvald/terrarum/realestate/LandUtil.kt
Normal file
25
src/net/torvald/terrarum/realestate/LandUtil.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
package net.torvald.terrarum.realestate
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
||||
import net.torvald.terrarum.gameworld.TileAddress
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-27.
|
||||
*/
|
||||
object LandUtil {
|
||||
fun getTileAddr(x: Int, y: Int): TileAddress =
|
||||
(Terrarum.ingame!!.world.width * y).toLong() + x
|
||||
|
||||
fun resolveAbsoluteTileNumber(t: TileAddress): Pair<Int, Int> =
|
||||
Pair((t % Terrarum.ingame!!.world.width).toInt(), (t / Terrarum.ingame!!.world.width).toInt())
|
||||
|
||||
/**
|
||||
* Get owner ID as an Actor/Faction
|
||||
*/
|
||||
fun resolveOwner(id: TileAddress): Any =
|
||||
if (id < 0x80000000L)
|
||||
Terrarum.ingame!!.getActorByID(id.toInt())
|
||||
else
|
||||
FactionCodex.getFactionByID(id)
|
||||
}
|
||||
Reference in New Issue
Block a user