mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
make quickslots work with dynamic items
This commit is contained in:
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
@@ -205,9 +206,19 @@ class UIItemInventoryElem(
|
||||
|
||||
if (item != ItemCodex[player.inventory.itemEquipped.get(itemEquipSlot)]) { // if this item is unequipped, equip it
|
||||
player.equipItem(item!!)
|
||||
|
||||
// also equip on the quickslot
|
||||
player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
player.inventory.setQuickBar(it, item!!.dynamicID)
|
||||
}
|
||||
}
|
||||
else { // if not, unequip it
|
||||
player.unequipItem(item!!)
|
||||
|
||||
// also unequip on the quickslot
|
||||
player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
player.inventory.setQuickBar(it, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
@@ -178,9 +179,19 @@ class UIItemInventoryElemSimple(
|
||||
|
||||
if (item != ItemCodex[player.inventory.itemEquipped.get(itemEquipSlot)]) { // if this item is unequipped, equip it
|
||||
player.equipItem(item!!)
|
||||
|
||||
// also equip on the quickslot
|
||||
player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
player.inventory.setQuickBar(it, item!!.dynamicID)
|
||||
}
|
||||
}
|
||||
else { // if not, unequip it
|
||||
player.unequipItem(item!!)
|
||||
|
||||
// also unequip on the quickslot
|
||||
player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
player.inventory.setQuickBar(it, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,10 @@ class ActorInventory(@Transient val actor: Pocketed, var maxCapacity: Int, var c
|
||||
add(newItem)
|
||||
itemEquipped[newItem.equipPosition] = newItem.dynamicID //invSearchByDynamicID(newItem.dynamicID)!!.item // will test if some sketchy code is written. Test fail: kotlinNullpointerException
|
||||
|
||||
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
setQuickBar(it, newItem.dynamicID)
|
||||
}
|
||||
|
||||
// FIXME now damage meter (vital) is broken
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -84,7 +84,7 @@ object PlayerBuilderSigrid {
|
||||
|
||||
// item ids are defined in <module>/items/itemid.csv
|
||||
|
||||
inventory.add(8448) // copper pick
|
||||
inventory.add(8448, 16) // copper pick
|
||||
inventory.add(8449) // iron pick
|
||||
inventory.add(8450) // steel pick
|
||||
inventory.add(8466, 9995) // wire piece
|
||||
|
||||
@@ -28,6 +28,14 @@ interface Pocketed {
|
||||
}
|
||||
|
||||
inventory.itemEquipped[item.equipPosition] = null
|
||||
|
||||
// remove it from the quickslot
|
||||
inventory.quickSlot.forEachIndexed { index, itemID ->
|
||||
if (itemID == item.dynamicID) {
|
||||
inventory.setQuickBar(index, null)
|
||||
}
|
||||
}
|
||||
|
||||
item.effectOnUnequip(AppLoader.UPDATE_RATE)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,13 @@ object PickaxeCore {
|
||||
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
var ret1 = true
|
||||
// ** below is commented out -- don't make actors obstruct the way of digging **
|
||||
/*var ret1 = true
|
||||
Terrarum.ingame!!.actorContainerActive.forEach {
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
ret1 = false // return is not allowed here
|
||||
}
|
||||
if (!ret1) return ret1
|
||||
if (!ret1) return ret1*/
|
||||
|
||||
// return false if here's no tile
|
||||
if (Block.AIR == (Terrarum.ingame!!.world).getTileFromTerrain(mouseTileX, mouseTileY))
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.torvald.terrarum.modulebasegame.icongen
|
||||
|
||||
import net.torvald.terrarum.Point2d
|
||||
|
||||
/**
|
||||
*
|
||||
* . _ end point
|
||||
* / \ _ control point 1 LR
|
||||
* | | _ control point 2 LR
|
||||
* | | _ ...
|
||||
* | | _ control point 8 LR
|
||||
* ===== _ accessory (hilt)
|
||||
* | _ accessory (grip)
|
||||
* O _ accessory (pommel)
|
||||
*
|
||||
* Created by minjaesong on 2020-02-11.
|
||||
*/
|
||||
inline class IconGenMesh(val datapoints: Array<Point2d>) {
|
||||
|
||||
operator fun times(other: PerturbMesh) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline class PerturbMesh(val datapoints: Array<Point2d>) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.torvald.terrarum.modulebasegame.icongen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2020-02-11.
|
||||
*/
|
||||
object Rasteriser {
|
||||
|
||||
operator fun invoke(size: Int, accessories: IcongenOverlays, colour: Color,
|
||||
mesh: IconGenMesh): Texture {
|
||||
|
||||
val retPixmap = Pixmap(size, size, Pixmap.Format.RGBA8888)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
val ret = Texture(retPixmap)
|
||||
retPixmap.dispose()
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// dummy class plz del
|
||||
class IcongenOverlays {
|
||||
|
||||
}
|
||||
|
||||
27
src/net/torvald/terrarum/modulebasegame/icongen/SwordGen.kt
Normal file
27
src/net/torvald/terrarum/modulebasegame/icongen/SwordGen.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package net.torvald.terrarum.modulebasegame.icongen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2020-02-11.
|
||||
*/
|
||||
object SwordGen {
|
||||
|
||||
operator fun invoke(
|
||||
size: Int, accessories: IconGenOverlays, colour: Color, type: SwordGenType,
|
||||
straightness: Double, roughness: Double) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//private fun getBaseArmingSwordMesh
|
||||
|
||||
}
|
||||
|
||||
enum class SwordGenType {
|
||||
ArmingSword, TwoHanded, Mace
|
||||
}
|
||||
|
||||
// dummy class plz del
|
||||
class IconGenOverlays {}
|
||||
Reference in New Issue
Block a user