mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
27 lines
851 B
Kotlin
27 lines
851 B
Kotlin
package net.torvald.terrarum.realestate
|
|
|
|
import net.torvald.terrarum.gameworld.GameWorld
|
|
import java.util.*
|
|
|
|
/**
|
|
* Created by minjaesong on 16-03-27.
|
|
*/
|
|
object RealEstateCodex {
|
|
/**
|
|
* HashMap<Absolute block number, Actor/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(world: GameWorld, tileX: Int, tileY: Int, refID: Int) {
|
|
ownershipRegistry[LandUtil.getBlockAddr(world, tileX, tileY)] = refID
|
|
}
|
|
|
|
fun removeOwner(world: GameWorld, tileX: Int, tileY: Int) {
|
|
ownershipRegistry.remove(LandUtil.getBlockAddr(world, tileX, tileY))
|
|
}
|
|
|
|
fun getOwner(world: GameWorld, tileX: Int, tileY: Int): Int? =
|
|
ownershipRegistry[LandUtil.getBlockAddr(world, tileX, tileY)]
|
|
} |