mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
item is useable (wall is not!); tile breakage works confirmed
This commit is contained in:
@@ -239,7 +239,7 @@ object ModMgr {
|
||||
val internalID: Int = it["id"].toInt()
|
||||
val itemName: String = "item@$module:$internalID"
|
||||
|
||||
printdbg(this, "Reading item #$internalID with className $className")
|
||||
printdbg(this, "Reading item ${itemName} <<- internal #$internalID with className $className")
|
||||
|
||||
val loadedClass = Class.forName(className)
|
||||
val loadedClassConstructor = loadedClass.getConstructor(ItemID::class.java)
|
||||
|
||||
@@ -39,133 +39,6 @@ object ItemCodex {
|
||||
private val itemImagePlaceholder: TextureRegion
|
||||
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_24") // copper pickaxe
|
||||
|
||||
init {
|
||||
//val ingame = Terrarum.ingame!! as Ingame // WARNING you can't put this here, ExceptionInInitializerError
|
||||
|
||||
|
||||
println("[ItemCodex] recording item ID ")
|
||||
|
||||
// test copper pickaxe
|
||||
/*itemCodex[ITEM_STATIC.first] = object : GameItem() {
|
||||
override val originalID = ITEM_STATIC.first
|
||||
override var dynamicID = originalID
|
||||
override val isUnique = false
|
||||
override val originalName = ""
|
||||
override var baseMass = 10.0
|
||||
override var baseToolSize: Double? = 10.0
|
||||
override var stackable = true
|
||||
override var maxDurability = 147//606
|
||||
override var durability = maxDurability.toFloat()
|
||||
override var equipPosition = EquipPosition.HAND_GRIP
|
||||
override var inventoryCategory = Category.TOOL
|
||||
override val isDynamic = true
|
||||
override val material = Material(0,0,0,0,0,0,0,0,1,0.0)
|
||||
|
||||
init {
|
||||
itemProperties[IVKey.ITEMTYPE] = IVKey.ItemType.PICK
|
||||
name = "Stone pickaxe"
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
val mousePoint = Point2d(Terrarum.mouseTileX.toDouble(), Terrarum.mouseTileY.toDouble())
|
||||
val actorvalue = ingame.actorNowPlaying.actorValue
|
||||
|
||||
|
||||
using = true
|
||||
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
ingame.actorContainerActive.forEach {
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
}
|
||||
|
||||
// return false if there's no tile
|
||||
if (Block.AIR == ingame.world.getTileFromTerrain(Terrarum.mouseTileX, Terrarum.mouseTileY))
|
||||
return false
|
||||
|
||||
|
||||
// filter passed, do the job
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
|
||||
ingame.world.inflictTerrainDamage(
|
||||
Terrarum.mouseTileX,
|
||||
Terrarum.mouseTileY,
|
||||
Calculate.pickaxePower(ingame.actorNowPlaying, material) * swingDmgToFrameDmg
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun endPrimaryUse(delta: Float): Boolean {
|
||||
using = false
|
||||
// reset action timer to zero
|
||||
ingame.actorNowPlaying.actorValue[AVKey.__ACTION_TIMER] = 0.0
|
||||
return true
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// test water bucket
|
||||
/*itemCodex[9000] = object : GameItem(9000) {
|
||||
|
||||
override val isUnique: Boolean = true
|
||||
override val originalName: String = "Infinite Water Bucket"
|
||||
|
||||
override var baseMass: Double = 1000.0
|
||||
override var baseToolSize: Double? = null
|
||||
|
||||
override var inventoryCategory: String = "tool"
|
||||
override var stackable: Boolean = false
|
||||
|
||||
override val isDynamic: Boolean = false
|
||||
override val material: Material = Material()
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
val ingame = Terrarum.ingame!! as TerrarumIngame // must be in here
|
||||
ingame.world.setFluid(Terrarum.mouseTileX, Terrarum.mouseTileY, Fluid.WATER, 4f)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// test lava bucket
|
||||
itemCodex[9001] = object : GameItem(9001) {
|
||||
|
||||
override val isUnique: Boolean = true
|
||||
override val originalName: String = "Infinite Lava Bucket"
|
||||
|
||||
override var baseMass: Double = 1000.0
|
||||
override var baseToolSize: Double? = null
|
||||
|
||||
override var inventoryCategory: String = "tool"
|
||||
override var stackable: Boolean = false
|
||||
|
||||
override val isDynamic: Boolean = false
|
||||
override val material: Material = Material()
|
||||
|
||||
init {
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
val ingame = Terrarum.ingame!! as TerrarumIngame // must be in here
|
||||
ingame.world.setFluid(Terrarum.mouseTileX, Terrarum.mouseTileY, Fluid.LAVA, 4f)
|
||||
return true
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// read from save (if applicable) and fill dynamicItemDescription
|
||||
|
||||
|
||||
|
||||
println()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param: dynamicID string of "dyn:<random id>"
|
||||
*/
|
||||
@@ -194,7 +67,7 @@ object ItemCodex {
|
||||
//throw IllegalArgumentException("Attempted to get item data of actor that cannot be an item. ($a)")
|
||||
}
|
||||
else // generic item
|
||||
return itemCodex[code]!!.clone() // from CSV
|
||||
return itemCodex[code]?.clone() // from CSV
|
||||
}
|
||||
|
||||
fun dynamicToStaticID(dynamicID: ItemID) = dynamicToStaticTable[dynamicID]!!
|
||||
@@ -225,7 +98,7 @@ object ItemCodex {
|
||||
}
|
||||
// item
|
||||
else if (itemID.startsWith("item@")) {
|
||||
return getItemImage(itemID)
|
||||
return itemCodex[itemID]?.itemImage
|
||||
}
|
||||
// TODO: wires
|
||||
// wall
|
||||
|
||||
@@ -45,7 +45,7 @@ class ActorInventory(@Transient val actor: Pocketed, var maxCapacity: Int, var c
|
||||
init {
|
||||
}
|
||||
|
||||
fun add(itemID: ItemID, count: Int = 1) = add(ItemCodex[itemID]!!, count)
|
||||
fun add(itemID: ItemID, count: Int = 1) = if (ItemCodex[itemID] == null) throw NullPointerException("Item not found: "+itemID) else add(ItemCodex[itemID]!!, count)
|
||||
fun add(item: GameItem, count: Int = 1) {
|
||||
|
||||
println("[ActorInventory] add $item, $count")
|
||||
|
||||
@@ -84,13 +84,13 @@ object PlayerBuilderSigrid {
|
||||
}
|
||||
|
||||
// item ids are defined in <module>/items/itemid.csv
|
||||
/*
|
||||
inventory.add("item@basegame:0", 16) // copper pick
|
||||
inventory.add("item@basegame:1") // iron pick
|
||||
inventory.add("item@basegame:2") // steel pick
|
||||
inventory.add("item@basegame:3", 9995) // wire piece
|
||||
inventory.add("item@basegame:4", 385930603) // test tiki torch
|
||||
inventory.add("item@basegame:5", 95) // crafting table
|
||||
*/
|
||||
|
||||
inventory.add("item@basegame:1", 16) // copper pick
|
||||
inventory.add("item@basegame:2") // iron pick
|
||||
inventory.add("item@basegame:3") // steel pick
|
||||
inventory.add("item@basegame:4", 9995) // wire piece
|
||||
inventory.add("item@basegame:5", 385930603) // test tiki torch
|
||||
//inventory.add("item@basegame:6", 95) // crafting table
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user