Tile -> Block && Map -> World

This commit is contained in:
Song Minjae
2017-04-27 01:57:45 +09:00
parent 49d3c9f55b
commit b4b2c0d85b
80 changed files with 1075 additions and 1645 deletions

View File

@@ -2,16 +2,16 @@ package net.torvald.terrarum.realestate
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.faction.FactionCodex
import net.torvald.terrarum.gameworld.TileAddress
import net.torvald.terrarum.gameworld.BlockAddress
/**
* Created by minjaesong on 16-03-27.
*/
object LandUtil {
fun getTileAddr(x: Int, y: Int): TileAddress =
fun getBlockAddr(x: Int, y: Int): BlockAddress =
(Terrarum.ingame!!.world.width * y).toLong() + x
fun resolveAbsoluteTileNumber(t: TileAddress): Pair<Int, Int> =
fun resolveAbsoluteBlockNumber(t: BlockAddress): Pair<Int, Int> =
Pair((t % Terrarum.ingame!!.world.width).toInt(), (t / Terrarum.ingame!!.world.width).toInt())
/**

View File

@@ -1,6 +1,5 @@
package net.torvald.terrarum.realestate
import java.io.Serializable
import java.util.*
/**
@@ -8,20 +7,20 @@ import java.util.*
*/
object RealEstateCodex {
/**
* HashMap<Absolute tile number, Actor/Faction ID>
* HashMap<Absolute block number, Actor/Faction ID>
*
* Note that a tile can have only ONE owner (as an Actor or Faction ID)
* Note that a block can have only ONE owner (as an Actor or Faction ID)
*/
private var ownershipRegistry: HashMap<Long, Int> = HashMap()
fun setOwner(tileX: Int, tileY: Int, refID: Int) {
ownershipRegistry[LandUtil.getTileAddr(tileX, tileY)] = refID
ownershipRegistry[LandUtil.getBlockAddr(tileX, tileY)] = refID
}
fun removeOwner(tileX: Int, tileY: Int) {
ownershipRegistry.remove(LandUtil.getTileAddr(tileX, tileY))
ownershipRegistry.remove(LandUtil.getBlockAddr(tileX, tileY))
}
fun getOwner(tileX: Int, tileY: Int): Int? =
ownershipRegistry[LandUtil.getTileAddr(tileX, tileY)]
ownershipRegistry[LandUtil.getBlockAddr(tileX, tileY)]
}