mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +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.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
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
|
if (item != ItemCodex[player.inventory.itemEquipped.get(itemEquipSlot)]) { // if this item is unequipped, equip it
|
||||||
player.equipItem(item!!)
|
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
|
else { // if not, unequip it
|
||||||
player.unequipItem(item!!)
|
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.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameitem.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
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
|
if (item != ItemCodex[player.inventory.itemEquipped.get(itemEquipSlot)]) { // if this item is unequipped, equip it
|
||||||
player.equipItem(item!!)
|
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
|
else { // if not, unequip it
|
||||||
player.unequipItem(item!!)
|
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)
|
add(newItem)
|
||||||
itemEquipped[newItem.equipPosition] = newItem.dynamicID //invSearchByDynamicID(newItem.dynamicID)!!.item // will test if some sketchy code is written. Test fail: kotlinNullpointerException
|
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
|
// FIXME now damage meter (vital) is broken
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ object PlayerBuilderSigrid {
|
|||||||
|
|
||||||
// item ids are defined in <module>/items/itemid.csv
|
// 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(8449) // iron pick
|
||||||
inventory.add(8450) // steel pick
|
inventory.add(8450) // steel pick
|
||||||
inventory.add(8466, 9995) // wire piece
|
inventory.add(8466, 9995) // wire piece
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ interface Pocketed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inventory.itemEquipped[item.equipPosition] = null
|
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)
|
item.effectOnUnequip(AppLoader.UPDATE_RATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ object PickaxeCore {
|
|||||||
|
|
||||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||||
// return false if hitting actors
|
// 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 {
|
Terrarum.ingame!!.actorContainerActive.forEach {
|
||||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||||
ret1 = false // return is not allowed here
|
ret1 = false // return is not allowed here
|
||||||
}
|
}
|
||||||
if (!ret1) return ret1
|
if (!ret1) return ret1*/
|
||||||
|
|
||||||
// return false if here's no tile
|
// return false if here's no tile
|
||||||
if (Block.AIR == (Terrarum.ingame!!.world).getTileFromTerrain(mouseTileX, mouseTileY))
|
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 {}
|
||||||
71
work_files/procedural_sword_gen.gv
Normal file
71
work_files/procedural_sword_gen.gv
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
digraph EnergyFlow {
|
||||||
|
|
||||||
|
graph [compound = true];
|
||||||
|
|
||||||
|
subgraph cluster_resources {
|
||||||
|
hilt1;
|
||||||
|
hilt2;
|
||||||
|
hilt3;
|
||||||
|
grip1;
|
||||||
|
grip2;
|
||||||
|
grip3;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
subgraph cluster_genicon {
|
||||||
|
Size;
|
||||||
|
Accessories;
|
||||||
|
Colour;
|
||||||
|
Type;
|
||||||
|
Straightness;
|
||||||
|
Roughness;
|
||||||
|
}
|
||||||
|
|
||||||
|
subgraph cluster_mesh {
|
||||||
|
"Left Perturb Mesh";
|
||||||
|
"Right Perturb Mesh";
|
||||||
|
"Curve Mesh";
|
||||||
|
}
|
||||||
|
|
||||||
|
subgraph gens {
|
||||||
|
node [style=filled,shape=rect];
|
||||||
|
Curvegen;
|
||||||
|
Jagg;
|
||||||
|
"Accessory\nSelector";
|
||||||
|
Rasterizer;
|
||||||
|
"Base Shape";
|
||||||
|
"Final Mesh";
|
||||||
|
}
|
||||||
|
|
||||||
|
grip1 -> "Accessory\nSelector";
|
||||||
|
grip2 -> "Accessory\nSelector";
|
||||||
|
grip3 -> "Accessory\nSelector";
|
||||||
|
hilt1 -> "Accessory\nSelector";
|
||||||
|
hilt2 -> "Accessory\nSelector";
|
||||||
|
hilt3 -> "Accessory\nSelector";
|
||||||
|
Type -> "Base Shape";
|
||||||
|
|
||||||
|
|
||||||
|
Straightness -> Curvegen -> "Curve Mesh";
|
||||||
|
Roughness -> Jagg;
|
||||||
|
Jagg -> "Left Perturb Mesh";
|
||||||
|
Jagg -> "Right Perturb Mesh";
|
||||||
|
|
||||||
|
|
||||||
|
"Accessory\nSelector" -> Accessories;
|
||||||
|
|
||||||
|
Accessories -> Rasterizer;
|
||||||
|
Size -> Rasterizer;
|
||||||
|
Colour -> Rasterizer;
|
||||||
|
"Base Shape" -> Add;
|
||||||
|
"Curve Mesh" -> Add;
|
||||||
|
Add -> "Final Mesh";
|
||||||
|
"Left Perturb Mesh" -> Mul;
|
||||||
|
"Right Perturb Mesh" -> Mul;
|
||||||
|
"Base Shape" -> Mul;
|
||||||
|
Mul -> "Final Mesh";
|
||||||
|
|
||||||
|
"Final Mesh" -> Rasterizer;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user