terrain damage data is now properly removed when the tile is newly placed

This commit is contained in:
Song Minjae
2017-04-19 03:03:53 +09:00
parent a88f5ba4ec
commit 9427293d7d
5 changed files with 16 additions and 14 deletions

View 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)
}