Files
Terrarum/src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt
Song Minjae ac9f5b5138 com.torvald → net.torvald
Former-commit-id: 375604da8a20a6ba7cd0a8d05a44add02b2d04f4
Former-commit-id: 287287c5920b07618174d7a7573f049d350ded66
2016-04-12 12:29:02 +09:00

102 lines
2.5 KiB
Kotlin

package net.torvald.terrarum.gameactors
import net.torvald.random.HQRNG
import net.torvald.terrarum.gameactors.ai.ActorAI
import net.torvald.terrarum.gameactors.faction.Faction
import net.torvald.terrarum.gameitem.InventoryItem
import net.torvald.terrarum.Terrarum
import org.newdawn.slick.GameContainer
import java.util.*
/**
* Created by minjaesong on 16-03-14.
*/
open class NPCIntelligentBase : ActorWithBody()
, AIControlled, Pocketed, CanBeAnItem, Factionable, LandHolder {
override var itemData: InventoryItem = object : InventoryItem {
override var itemID = HQRNG().nextLong()
override var mass: Float
get() = actorValue.get("mass") as Float
set(value) {
actorValue.set("mass", value)
}
override var scale: Float
get() = actorValue.get("scale") as Float
set(value) {
actorValue.set("scale", value)
}
override fun effectWhileInPocket(gc: GameContainer, delta_t: Int) {
}
override fun effectWhenPickedUp(gc: GameContainer, delta_t: Int) {
}
override fun primaryUse(gc: GameContainer, delta_t: Int) {
}
override fun secondaryUse(gc: GameContainer, delta_t: Int) {
}
override fun effectWhenThrownAway(gc: GameContainer, delta_t: Int) {
}
}
@Transient private var ai: ActorAI? = null
override var inventory: ActorInventory = ActorInventory()
private val factionSet = HashSet<Faction>()
override var referenceID: Long = HQRNG().nextLong()
override var faction: HashSet<Faction> = HashSet()
override var houseDesignation: ArrayList<Int>? = null
/**
* Absolute tile index. index(x, y) = y * map.width + x
* The arraylist will be saved in JSON format with GSON.
*/
private var houseTiles = ArrayList<Int>()
override fun attachItemData() {
}
override fun getItemWeight(): Float {
return mass
}
override fun addHouseTile(x: Int, y: Int) {
houseTiles.add(Terrarum.game.map.width * y + x)
}
override fun removeHouseTile(x: Int, y: Int) {
houseTiles.remove(Terrarum.game.map.width * y + x)
}
override fun clearHouseDesignation() {
houseTiles.clear()
}
override fun stopUpdateAndDraw() {
isUpdate = false
isVisible = false
}
override fun resumeUpdateAndDraw() {
isUpdate = true
isVisible = true
}
override fun attachAI(ai: ActorAI) {
this.ai = ai
}
}