mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 14:04:05 +09:00
equip item by body parts
Former-commit-id: 34294de21d16c03da98427edae3b3c6ed94088aa Former-commit-id: b37fe27635b1643e72e8f714bfea6ce214006931
This commit is contained in:
@@ -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.gameitem.EquipPosition
|
||||
import net.torvald.terrarum.gameitem.InventoryItem
|
||||
import net.torvald.terrarum.gameitem.InventoryItemAdapter
|
||||
import net.torvald.terrarum.realestate.RealEstateUtility
|
||||
@@ -27,8 +28,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
/** Must be set by PlayerFactory */
|
||||
override var inventory: ActorInventory = ActorInventory()
|
||||
|
||||
override var itemHolding: InventoryItem? = null
|
||||
override val itemEquipped = ArrayList<InventoryItem>()
|
||||
override val itemEquipped = Array<InventoryItem?>(EquipPosition.INDEX_MAX + 1, { null })
|
||||
|
||||
/** Must be set by PlayerFactory */
|
||||
override var faction: HashSet<Faction> = HashSet()
|
||||
@@ -136,6 +136,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
private val nullItem = object : InventoryItemAdapter() {
|
||||
override val itemID: Int = 0
|
||||
override val equipPosition: Int = EquipPosition.NULL
|
||||
override var mass: Double = 0.0
|
||||
override var scale: Double = 1.0
|
||||
}
|
||||
@@ -211,12 +212,12 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
*/
|
||||
// Left mouse
|
||||
if (isGamer && input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
|
||||
(itemHolding ?: nullItem).primaryUse(gc, delta)
|
||||
(itemEquipped[EquipPosition.HAND_GRIP] ?: nullItem).primaryUse(gc, delta)
|
||||
}
|
||||
|
||||
// Right mouse
|
||||
if (isGamer && input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
|
||||
(itemHolding ?: nullItem).secondaryUse(gc, delta)
|
||||
(itemEquipped[EquipPosition.HAND_GRIP] ?: nullItem).secondaryUse(gc, delta)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ class DroppedItem(private val item: InventoryItem) : ActorWithBody() {
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
item.effectWhenTakenOut(gc, delta)
|
||||
item.effectWhenEquipped(gc, delta)
|
||||
}
|
||||
|
||||
override fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.gameitem.EquipPosition
|
||||
import net.torvald.terrarum.gameitem.InventoryItem
|
||||
import net.torvald.terrarum.gameitem.InventoryItemAdapter
|
||||
import org.luaj.vm2.Globals
|
||||
@@ -42,6 +43,7 @@ open class HumanoidNPC(aiFile: String, born: GameDate) : ActorHumanoid(born), AI
|
||||
// we're having InventoryItem data so that this class could be somewhat universal
|
||||
override var itemData: InventoryItem = object : InventoryItemAdapter() {
|
||||
override var itemID = referenceID
|
||||
override val equipPosition: Int = EquipPosition.HAND_GRIP
|
||||
|
||||
override var mass: Double
|
||||
get() = actorValue.getAsDouble(AVKey.BASEMASS)!!
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.torvald.spriteanimation.SpriteAnimation
|
||||
import com.google.gson.JsonObject
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.gameactors.faction.FactionFactory
|
||||
import net.torvald.terrarum.gameitem.EquipPosition
|
||||
import net.torvald.terrarum.itemproperties.ItemPropCodex
|
||||
import net.torvald.terrarum.mapdrawer.MapDrawer
|
||||
import org.newdawn.slick.SlickException
|
||||
@@ -61,7 +62,7 @@ object PlayerBuilderSigrid {
|
||||
p.actorValue[AVKey.BASEDEFENCE] = 141
|
||||
|
||||
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
|
||||
p.actorValue["__selectedtile"] = 147 // test code; replace with <tile_item>.primaryUse(gc, delta)
|
||||
//p.actorValue["__selectedtile"] = 147 // test code; replace with <tile_item>.primaryUse(gc, delta)
|
||||
p.actorValue["__aimhelper"] = true // TODO when you'll gonna implement it?
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT)!!, 10, 0)
|
||||
@@ -76,7 +77,7 @@ object PlayerBuilderSigrid {
|
||||
|
||||
// Test fill up inventory
|
||||
p.inventory.add(16)
|
||||
p.itemHolding = ItemPropCodex.getProp(16)
|
||||
p.itemEquipped[EquipPosition.HAND_GRIP] = ItemPropCodex.getProp(16)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,13 +10,9 @@ interface Pocketed {
|
||||
|
||||
var inventory: ActorInventory
|
||||
|
||||
/** Item currentry holding, like tools/weapons/scrolls/magic/etc.
|
||||
* Null if not holding anything
|
||||
*/
|
||||
var itemHolding: InventoryItem?
|
||||
/**
|
||||
* List of all equipped items (tools, armours, rings, necklaces, etc.)
|
||||
*/
|
||||
val itemEquipped: ArrayList<InventoryItem>
|
||||
val itemEquipped: Array<InventoryItem?>
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user