From 0837d23cb6eec28343f8b40455953d3955afb80d Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Mon, 24 Oct 2016 12:23:51 +0900 Subject: [PATCH] NPCIntelligentBase -> HumanoidNPC, modified HumanoidNPC accordingly Former-commit-id: 0645b78df018cfd4c10e2b2956985412bee536e6 Former-commit-id: 8578954077c68de4d47a19cd72927c79aa8c07d8 --- .../torvald/terrarum/console/ActorHumanoid.kt | 9 +++--- .../{NPCIntelligentBase.kt => HumanoidNPC.kt} | 29 +++++-------------- 2 files changed, 12 insertions(+), 26 deletions(-) rename src/net/torvald/terrarum/gameactors/{NPCIntelligentBase.kt => HumanoidNPC.kt} (65%) diff --git a/src/net/torvald/terrarum/console/ActorHumanoid.kt b/src/net/torvald/terrarum/console/ActorHumanoid.kt index 1b28aa45a..f901d2d91 100644 --- a/src/net/torvald/terrarum/console/ActorHumanoid.kt +++ b/src/net/torvald/terrarum/console/ActorHumanoid.kt @@ -6,6 +6,7 @@ import net.torvald.terrarum.gameactors.* import net.torvald.terrarum.gameactors.faction.Faction import net.torvald.terrarum.gamecontroller.EnumKeyFunc import net.torvald.terrarum.gamecontroller.KeyMap +import net.torvald.terrarum.realestate.RealEstateUtility import org.dyn4j.geometry.Vector2 import org.lwjgl.input.Controller import org.lwjgl.input.Controllers @@ -30,18 +31,18 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null) * Absolute tile index. index(x, y) = y * map.width + x * The arraylist will be saved in JSON format with GSON. */ - override var houseDesignation: ArrayList? = null + override var houseDesignation: ArrayList? = ArrayList() override fun addHouseTile(x: Int, y: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + if (houseDesignation != null) houseDesignation!!.add(RealEstateUtility.getAbsoluteTileNumber(x, y)) } override fun removeHouseTile(x: Int, y: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + if (houseDesignation != null) houseDesignation!!.remove(RealEstateUtility.getAbsoluteTileNumber(x, y)) } override fun clearHouseDesignation() { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + if (houseDesignation != null) houseDesignation!!.clear() } /** diff --git a/src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt b/src/net/torvald/terrarum/gameactors/HumanoidNPC.kt similarity index 65% rename from src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt rename to src/net/torvald/terrarum/gameactors/HumanoidNPC.kt index 5c5ed8195..f5a87fe2a 100644 --- a/src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt +++ b/src/net/torvald/terrarum/gameactors/HumanoidNPC.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.gameactors +import net.torvald.terrarum.console.ActorHumanoid import net.torvald.terrarum.gameactors.ai.ActorAI import net.torvald.terrarum.gameactors.faction.Faction import net.torvald.terrarum.gameitem.InventoryItem @@ -10,15 +11,11 @@ import java.util.* /** * Created by minjaesong on 16-03-14. */ -open class NPCIntelligentBase(born: GameDate) : HistoricalFigure(born) - , AIControlled, Pocketed, CanBeAnItem, Factionable, LandHolder { +open class HumanoidNPC(born: GameDate) : ActorHumanoid(born), AIControlled, CanBeAnItem { override var actorAI: ActorAI = object : ActorAI { // TODO fully establish ActorAI so that I can implement AI here } - override var inventory: ActorInventory = ActorInventory() - override var faction: HashSet = HashSet() - override var houseDesignation: ArrayList? = null // we're having InventoryItem data so that this class could be somewhat universal override var itemData: InventoryItem = object : InventoryItem { @@ -36,23 +33,23 @@ open class NPCIntelligentBase(born: GameDate) : HistoricalFigure(born) actorValue[AVKey.SCALE] = value } - override fun effectWhileInPocket(gc: GameContainer, delta_t: Int) { + override fun effectWhileInPocket(gc: GameContainer, delta: Int) { } - override fun effectWhenPickedUp(gc: GameContainer, delta_t: Int) { + override fun effectWhenPickedUp(gc: GameContainer, delta: Int) { } - override fun primaryUse(gc: GameContainer, delta_t: Int) { + override fun primaryUse(gc: GameContainer, delta: Int) { // TODO do not allow primary_use } - override fun secondaryUse(gc: GameContainer, delta_t: Int) { + override fun secondaryUse(gc: GameContainer, delta: Int) { // TODO place this Actor to the world } - override fun effectWhenThrown(gc: GameContainer, delta_t: Int) { + override fun effectWhenThrown(gc: GameContainer, delta: Int) { } override fun effectWhenTakenOut(gc: GameContainer, delta: Int) { @@ -66,18 +63,6 @@ open class NPCIntelligentBase(born: GameDate) : HistoricalFigure(born) return mass } - override fun addHouseTile(x: Int, y: Int) { - if (houseDesignation != null) houseDesignation!!.add(getAbsoluteTileNumber(x, y)) - } - - override fun removeHouseTile(x: Int, y: Int) { - if (houseDesignation != null) houseDesignation!!.remove(getAbsoluteTileNumber(x, y)) - } - - override fun clearHouseDesignation() { - if (houseDesignation != null) houseDesignation!!.clear() - } - override fun stopUpdateAndDraw() { isUpdate = false isVisible = false