From 80c29f871cc2129b19fb256e2310841981b5aaa9 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 10 Mar 2019 23:38:11 +0900 Subject: [PATCH] reading material from the module; pixaxes use it But "dynamic item" created from the pickaxe class is not right --- assets/mods/basegame/blocks/blocks.csv | 2 +- assets/mods/basegame/items/itemid.csv | 6 +- assets/mods/basegame/materialprop.csv | 40 ++++-- src/net/torvald/terrarum/ModMgr.kt | 9 ++ .../terrarum/blockproperties/BlockCodex.kt | 82 ++++++------ .../terrarum/itemproperties/GameItem.kt | 2 - .../terrarum/itemproperties/ItemCodex.kt | 4 +- .../terrarum/itemproperties/Material.kt | 60 ++++++--- .../terrarum/itemproperties/MaterialCodex.kt | 9 -- .../terrarum/modulebasegame/EntryPoint.kt | 27 ++-- .../gameactors/ActorHumanoid.kt | 2 +- .../modulebasegame/gameactors/HumanoidNPC.kt | 2 +- .../gameactors/PlayerBuilderSigrid.kt | 10 +- .../modulebasegame/items/PickaxeGeneric.kt | 126 ++++++++++++++---- .../items/WirePieceSignalWire.kt | 3 +- 15 files changed, 249 insertions(+), 135 deletions(-) delete mode 100644 src/net/torvald/terrarum/itemproperties/MaterialCodex.kt diff --git a/assets/mods/basegame/blocks/blocks.csv b/assets/mods/basegame/blocks/blocks.csv index cf77cbf8b..2043da1e8 100644 --- a/assets/mods/basegame/blocks/blocks.csv +++ b/assets/mods/basegame/blocks/blocks.csv @@ -119,7 +119,7 @@ # # vscs: viscosity, (velocity) / (1 + (n/16)), 16 halves movement speed, can be used to non-fluid tiles (sticky hazard, tarmac road in Terraria) # -# str: strength +# str: strength. Only useful for pickaxes # # dsty: density. As we are putting water an 1000, it is identical to specific gravity. [g/l] # diff --git a/assets/mods/basegame/items/itemid.csv b/assets/mods/basegame/items/itemid.csv index 20237e377..e07f6494f 100644 --- a/assets/mods/basegame/items/itemid.csv +++ b/assets/mods/basegame/items/itemid.csv @@ -1,3 +1,5 @@ "id";"classname" - "8448";"net.torvald.terrarum.modulebasegame.items.PickaxeGeneric" - "8449";"net.torvald.terrarum.modulebasegame.items.WirePieceSignalWire" + "8448";"net.torvald.terrarum.modulebasegame.items.PickaxeCopper" + "8449";"net.torvald.terrarum.modulebasegame.items.PickaxeIron" + "8450";"net.torvald.terrarum.modulebasegame.items.PickaxeSteel" + "8466";"net.torvald.terrarum.modulebasegame.items.WirePieceSignalWire" diff --git a/assets/mods/basegame/materialprop.csv b/assets/mods/basegame/materialprop.csv index bfa7fb0b8..7ac674805 100644 --- a/assets/mods/basegame/materialprop.csv +++ b/assets/mods/basegame/materialprop.csv @@ -1,19 +1,35 @@ -"idst";"dsty";"forcemod";"endurance";"comments" -"ROCK";"2400"; "1"; "0.42"; -"CUPR";"1000"; "2"; "1.00";"copper" -"EGLS";"2500"; "4"; "0.82";"elven glass" -"IRON";"1000"; "5"; "1.42"; -"ARGN";"1000"; "9"; "0.91";"argentum/silver" -"STAL";"1000"; "14"; "1.73";"steel" -"EAUR";"1000"; "21"; "1.36";"elven aurichalcum" -"TIAL";"1000"; "33"; "2.16";"titanium alloy (Ti6Al4V)" -"ADMT";"1000"; "71"; "3.42";"adamant" +"idst";"tens";"impf";"dsty";"fmod";"endurance";"tcond";"comments" +"ROCK"; "15"; "210";"3000"; "1"; "0.42"; "10"; +"CUPR"; "210"; "770";"8960"; "2"; "1.00"; "401";"copper" +"EGLS"; "33";"1000";"2325"; "4"; "0.82"; "10";"elven glass/moldavite" +"IRON"; "350";"1085";"7874"; "5"; "1.42"; "10"; +"ARGN"; "170"; "595";"10490"; "9"; "0.91"; "10";"argentum/silver" +"STAL"; "531";"2520";"7874"; "14"; "1.73"; "10";"steel" +"EAUR"; "768"; "0";"8192"; "21"; "1.36"; "10";"elven aurichalcum" +"TIAL"; "900"; "0";"4420"; "33"; "2.16"; "10";"titanium alloy (Ti6Al4V)" +"ADMT";"2000";"4090";"2700"; "71"; "3.42"; "10";"adamant" -# idst: ID_STRING +"OOZE"; "0";"genetic ooze" -# forcemod: related to attack points +# idst: ID_STRING, ALL CAPS + +# tens: tensile strength (= ultimate stringth) + ultimate stringth is technically a tensile strength, but I'm using it anyway because it's easiest to get the value from + that, or DF's tensile fracture divided by 1000 (I think Toady and I are both using values posted on Wikipedia, e.g. Silver) + +# impf: Dwarf Fortress impact fracture divided by 1000 (likely not being used) + +# dsty: density (grams per litre) + +# fmod: forcemod -- related to attack points # Attack points = `4 * forcemod.sqrt()` for each strike # endurance: multiplier, using copper as reference; determines durability of tools/weapons/armours/etc. + the base value for endurance differes to tool to tool. When integer is used, resulting value must be ROUNDED. + +# tcond: thermal conductivity # Comments: do nothing; do not parse + + +## These values are being used by the phys simulator (blocks) and for attack power calculation (items) diff --git a/src/net/torvald/terrarum/ModMgr.kt b/src/net/torvald/terrarum/ModMgr.kt index c434405f7..40c32ad89 100644 --- a/src/net/torvald/terrarum/ModMgr.kt +++ b/src/net/torvald/terrarum/ModMgr.kt @@ -8,6 +8,7 @@ import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.itemproperties.ItemCodex import net.torvald.terrarum.itemproperties.ItemID +import net.torvald.terrarum.itemproperties.MaterialCodex import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.utils.CSVFetcher import net.torvald.terrarum.utils.JsonFetcher @@ -249,4 +250,12 @@ object ModMgr { Lang.load(getPath(module, langPath)) } } + + object GameMaterialLoader { + val matePath = "materials/" + + @JvmStatic operator fun invoke(module: String) { + MaterialCodex(module, matePath + "materials.csv") + } + } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/blockproperties/BlockCodex.kt b/src/net/torvald/terrarum/blockproperties/BlockCodex.kt index 36a70313f..bc50ae7fc 100644 --- a/src/net/torvald/terrarum/blockproperties/BlockCodex.kt +++ b/src/net/torvald/terrarum/blockproperties/BlockCodex.kt @@ -139,45 +139,45 @@ object BlockCodex { print("${intVal(record, "id")}") println("\t" + prop.nameKey) } - - private fun str16ToInt(rec: CSVRecord, s: String): Int { - var ret = 0 - try { - ret = rec.get(s).toLong(16).toInt() - } - catch (e: NumberFormatException) { - } - catch (e1: IllegalStateException) { - } - - return ret - } - - private fun intVal(rec: CSVRecord, s: String): Int { - var ret = -1 - try { - ret = rec.get(s).toInt() - } - catch (e: NumberFormatException) { - } - catch (e1: IllegalStateException) { - } - - return ret - } - - private fun floatVal(rec: CSVRecord, s: String): Float { - var ret = -1f - try { - ret = rec.get(s).toFloat() - } - catch (e: NumberFormatException) { - } - catch (e1: IllegalStateException) { - } - - return ret - } - - private fun boolVal(rec: CSVRecord, s: String) = intVal(rec, s) != 0 } + +fun str16ToInt(rec: CSVRecord, s: String): Int { + var ret = 0 + try { + ret = rec.get(s).toLong(16).toInt() + } + catch (e: NumberFormatException) { + } + catch (e1: IllegalStateException) { + } + + return ret +} + +fun intVal(rec: CSVRecord, s: String): Int { + var ret = -1 + try { + ret = rec.get(s).toInt() + } + catch (e: NumberFormatException) { + } + catch (e1: IllegalStateException) { + } + + return ret +} + +fun floatVal(rec: CSVRecord, s: String): Float { + var ret = -1f + try { + ret = rec.get(s).toFloat() + } + catch (e: NumberFormatException) { + } + catch (e1: IllegalStateException) { + } + + return ret +} + +fun boolVal(rec: CSVRecord, s: String) = intVal(rec, s) != 0 \ No newline at end of file diff --git a/src/net/torvald/terrarum/itemproperties/GameItem.kt b/src/net/torvald/terrarum/itemproperties/GameItem.kt index 1d0b49be1..1b682eefe 100644 --- a/src/net/torvald/terrarum/itemproperties/GameItem.kt +++ b/src/net/torvald/terrarum/itemproperties/GameItem.kt @@ -298,8 +298,6 @@ abstract class GameItem : Comparable, Cloneable { return ret } - - val NULL_MATERIAL = Material(0,0,0,0,0,0,0,0,1,0.0) } } diff --git a/src/net/torvald/terrarum/itemproperties/ItemCodex.kt b/src/net/torvald/terrarum/itemproperties/ItemCodex.kt index af8d993f7..bfa296364 100644 --- a/src/net/torvald/terrarum/itemproperties/ItemCodex.kt +++ b/src/net/torvald/terrarum/itemproperties/ItemCodex.kt @@ -188,7 +188,7 @@ object ItemCodex { override var stackable: Boolean = false override val isDynamic: Boolean = false - override val material: Material = Material(1,1,1,1,1,1,1,1,1,1.0) + override val material: Material = Material() init { equipPosition = EquipPosition.HAND_GRIP @@ -217,7 +217,7 @@ object ItemCodex { override var stackable: Boolean = false override val isDynamic: Boolean = false - override val material: Material = Material(1,1,1,1,1,1,1,1,1,1.0) + override val material: Material = Material() init { equipPosition = EquipPosition.HAND_GRIP diff --git a/src/net/torvald/terrarum/itemproperties/Material.kt b/src/net/torvald/terrarum/itemproperties/Material.kt index 7aefec4a1..32246f5da 100644 --- a/src/net/torvald/terrarum/itemproperties/Material.kt +++ b/src/net/torvald/terrarum/itemproperties/Material.kt @@ -1,36 +1,56 @@ package net.torvald.terrarum.itemproperties +import net.torvald.terrarum.AppLoader.printdbg +import net.torvald.terrarum.blockproperties.floatVal +import net.torvald.terrarum.blockproperties.intVal +import net.torvald.terrarum.utils.CSVFetcher +import java.io.IOException + /** * To be used with items AND TILES (electricity resistance, thermal conductivity) * * Created by minjaesong on 2016-03-18. */ -data class Material ( - //var maxEdge: Int, // i think weapSharpnessMod would cut it // arbitrary unit - var hardness: Int, // arbitrary unit - var density: Int, // grams per litre +class Material { + var strength: Int = 1 // actually tensile strength + var density: Int = 1000 // grams per litre - // impact force: force applied by sudden strike, e.g. hammer/axe/sword strike - var impactRigidness: Int, // arbitrary unit (rigid <-> soft) a weapon made of soft material will inflict less damage - var impactFractureForce: Int, // pascal (N/m^2); if the item (e.g. sword) receives a force that exceeds this value, the item will be destroyed + var thermalConductivity: Float = 10f // watts per metre-kelven - // compressive force: force applied by exerting pressure on an object, e.g. sword/spear stab - var compressiveRigidness: Int, // arbitrary unit (rigid <-> soft) a weapon made of soft material will inflict less damage - var compressiveFractureForce: Int, // pascal (N/m^2); if the item (e.g. sword) receives a force that exceeds this value, the item will be destroyed + var forceMod: Int = 1 // arbitrary unit. See Pickaxe_Power.xlsx + var enduranceMod: Float = 1f // multiplier. Copper as 1.0 + //var armourMod: Float // multiplier. Copper as 1.0 - // remarks: - // we won't need elasticity, even if we have glass - // some examples: - // - glass sword works as the material has high compressive fracture, but prone to shatter - // (hit mobs 5-6 times and it's gone) as it shatters easily as it has low impact fracture + var durability: Int = 0 // tools only +} +object MaterialCodex { + private var materialProps = HashMap() + private val nullMaterial = Material() - var electricityResistance: Int, // ohm - var thermalConductivity: Int, // pascal (N/m^2); if the item (e.g. sword) receives a force that exceeds this value, the item will be destroyed + operator fun invoke(module: String, path: String) { + try { + val records = CSVFetcher.readFromModule(module, path) + printdbg(this, "Building materials table") + records.forEach { + val prop = Material() + prop.strength = intVal(it, "tens") + prop.density = intVal(it, "dsty") + prop.forceMod = intVal(it, "forcemod") + prop.enduranceMod = floatVal(it, "endurance") + prop.thermalConductivity = floatVal(it, "tcond") - var forceMod: Int, // arbitrary unit. See Pickaxe_Power.xlsx - var armourMod: Double // multiplier -) \ No newline at end of file + materialProps[it.get("idst").toUpperCase()] = prop + } + } + catch (e: IOException) { + e.printStackTrace() + } + } + + operator fun get(identifier: String) = materialProps[identifier.toUpperCase()] ?: nullMaterial + +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/itemproperties/MaterialCodex.kt b/src/net/torvald/terrarum/itemproperties/MaterialCodex.kt deleted file mode 100644 index 7a86c1b60..000000000 --- a/src/net/torvald/terrarum/itemproperties/MaterialCodex.kt +++ /dev/null @@ -1,9 +0,0 @@ -package net.torvald.terrarum.itemproperties - -/** - * Created by minjaesong on 2016-03-18. - */ -object MaterialCodex { - val CSV_PATH = "./src/com/torvald/terrarum/itemproperties/materialprop.csv" - -} \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt b/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt index 2f4b53f43..c60ea5d5a 100644 --- a/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt +++ b/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt @@ -7,7 +7,7 @@ import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.gameactors.ActorWBMovable import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.itemproperties.ItemCodex -import net.torvald.terrarum.itemproperties.Material +import net.torvald.terrarum.itemproperties.MaterialCodex import net.torvald.terrarum.modulebasegame.imagefont.WatchFont import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack @@ -18,22 +18,27 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack */ class EntryPoint : ModuleEntryPoint() { + private val moduleName = "basegame" + override fun invoke() { - ModMgr.GameBlockLoader.invoke("basegame") - ModMgr.GameItemLoader.invoke("basegame") - ModMgr.GameLanguageLoader.invoke("basegame") + // the order of invocation is important! Material should be the first as blocks and items are depend on it. + ModMgr.GameMaterialLoader.invoke(moduleName) + ModMgr.GameBlockLoader.invoke(moduleName) + ModMgr.GameItemLoader.invoke(moduleName) + ModMgr.GameLanguageLoader.invoke(moduleName) + // load common resources to the AssetsManager - AppLoader.resourcePool.addToLoadingList("basegame.items16", TextureRegionPack.javaClass) { - TextureRegionPack(ModMgr.getGdxFile("basegame", "items/items.tga"), 16, 16) + AppLoader.resourcePool.addToLoadingList("$moduleName.items16", TextureRegionPack.javaClass) { + TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items.tga"), 16, 16) } - AppLoader.resourcePool.addToLoadingList("basegame.items24", TextureRegionPack.javaClass) { - TextureRegionPack(ModMgr.getGdxFile("basegame", "items/items24.tga"), 24, 24) + AppLoader.resourcePool.addToLoadingList("$moduleName.items24", TextureRegionPack.javaClass) { + TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items24.tga"), 24, 24) } - AppLoader.resourcePool.addToLoadingList("basegame.items48", TextureRegionPack.javaClass) { - TextureRegionPack(ModMgr.getGdxFile("basegame", "items/items48.tga"), 48, 48) + AppLoader.resourcePool.addToLoadingList("$moduleName.items48", TextureRegionPack.javaClass) { + TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items48.tga"), 48, 48) } @@ -59,7 +64,7 @@ class EntryPoint : ModuleEntryPoint() { override var stackable = true override var inventoryCategory = if (i in ItemCodex.ITEM_TILES) Category.BLOCK else Category.WALL override var isDynamic = false - override val material = Material(0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0) + override val material = MaterialCodex[blockProp.material] init { equipPosition = EquipPosition.HAND_GRIP diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt index bcd71a2b4..fddc22f32 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt @@ -164,7 +164,7 @@ open class ActorHumanoid( override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "(no name)" override var stackable = false override val isDynamic = false - override val material = Material(0,0,0,0,0,0,0,0,0,0.0) + override val material = Material() } init { diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/HumanoidNPC.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/HumanoidNPC.kt index dc5628b6b..e6d657f62 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/HumanoidNPC.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/HumanoidNPC.kt @@ -46,7 +46,7 @@ open class HumanoidNPC( override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "NPC" override var stackable = true override val isDynamic = false - override val material = Material(0,0,0,0,0,0,0,0,0,0.0) + override val material = Material() override fun startPrimaryUse(delta: Float): Boolean { try { diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt index ac3ad8301..9498ef8c8 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt @@ -4,7 +4,6 @@ import net.torvald.terrarum.ModMgr import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.faction.FactionFactory -import net.torvald.terrarum.itemproperties.ItemCodex import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** @@ -96,8 +95,11 @@ object PlayerBuilderSigrid { ) blocks.forEach { inventory.add(it, 9995) } walls.forEach { inventory.add(it + 4096, 9995) } - inventory.add(ItemCodex.ITEM_STATIC.first) - inventory.add(9000) - inventory.add(9001) + inventory.add(8448) // copper pick + inventory.add(8449) // iron pick + inventory.add(8450) // steel pick + inventory.add(8466) // wire piece + inventory.add(9000) // TEST water bucket + inventory.add(9001) // TEST lava bucket } } diff --git a/src/net/torvald/terrarum/modulebasegame/items/PickaxeGeneric.kt b/src/net/torvald/terrarum/modulebasegame/items/PickaxeGeneric.kt index 9929a571c..69b0aeeed 100644 --- a/src/net/torvald/terrarum/modulebasegame/items/PickaxeGeneric.kt +++ b/src/net/torvald/terrarum/modulebasegame/items/PickaxeGeneric.kt @@ -10,35 +10,18 @@ import net.torvald.terrarum.gameactors.ActorWBMovable import net.torvald.terrarum.itemproperties.Calculate import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.itemproperties.ItemID -import net.torvald.terrarum.itemproperties.Material +import net.torvald.terrarum.itemproperties.MaterialCodex import net.torvald.terrarum.modulebasegame.Ingame +import net.torvald.terrarum.modulebasegame.items.PickaxeCore.BASE_MASS_AND_SIZE +import net.torvald.terrarum.modulebasegame.items.PickaxeCore.TOOL_DURABILITY_BASE import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack +import kotlin.math.roundToInt /** - * Created by minjaesong on 2017-07-17. + * Created by minjaesong on 2019-03-10. */ -class PickaxeGeneric(override val originalID: ItemID) : GameItem() { - - override var dynamicID: ItemID = originalID - override val originalName = "PACKAGED_PICK" - override var baseMass = 10.0 - override var baseToolSize: Double? = 10.0 - override var stackable = true - override var inventoryCategory = Category.TOOL - override val isUnique = false - override val isDynamic = true - override var material = Material(0,0,0,0,0,0,0,0,1,0.0) - override val itemImage: TextureRegion? - get() = (AppLoader.resourcePool["basegame.items24"] as TextureRegionPack).get(2,0) - - init { - super.equipPosition = GameItem.EquipPosition.HAND_GRIP - super.maxDurability = 147 - super.durability = maxDurability.toFloat() - super.name = "Builtin Pickaxe" - } - - override fun startPrimaryUse(delta: Float): Boolean { +object PickaxeCore { + fun startPrimaryUse(delta: Float, item: GameItem): Boolean { val player = (Terrarum.ingame!! as Ingame).actorNowPlaying if (player == null) return false @@ -48,7 +31,7 @@ class PickaxeGeneric(override val originalID: ItemID) : GameItem() { val mousePoint = Point2d(mouseTileX.toDouble(), mouseTileY.toDouble()) val actorvalue = player.actorValue - using = true + item.using = true // linear search filter (check for intersection with tilewise mouse point and tilewise hitbox) // return false if hitting actors @@ -66,19 +49,106 @@ class PickaxeGeneric(override val originalID: ItemID) : GameItem() { (Terrarum.ingame!!.world).inflictTerrainDamage( mouseTileX, mouseTileY, - Calculate.pickaxePower(player, material) * swingDmgToFrameDmg + Calculate.pickaxePower(player, item.material) * swingDmgToFrameDmg ) return true } - override fun endPrimaryUse(delta: Float): Boolean { + fun endPrimaryUse(delta: Float, item: GameItem): Boolean { val player = (Terrarum.ingame!! as Ingame).actorNowPlaying if (player == null) return false - using = false + item.using = false // reset action timer to zero player.actorValue.set(AVKey.__ACTION_TIMER, 0.0) return true } + + const val BASE_MASS_AND_SIZE = 10.0 // of iron pick + const val TOOL_DURABILITY_BASE = 350 // of iron pick +} + +/** + * Created by minjaesong on 2017-07-17. + */ +class PickaxeCopper(override val originalID: ItemID) : GameItem() { + + override var dynamicID: ItemID = originalID + override val originalName = "PACKAGED_PICK" + override var baseToolSize: Double? = BASE_MASS_AND_SIZE + override var stackable = true + override var inventoryCategory = Category.TOOL + override val isUnique = false + override val isDynamic = true + override var material = MaterialCodex["CUPR"] + override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE + override val itemImage: TextureRegion? + get() = (AppLoader.resourcePool["basegame.items24"] as TextureRegionPack).get(0,0) + + init { + super.equipPosition = GameItem.EquipPosition.HAND_GRIP + super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() + super.durability = maxDurability.toFloat() + super.name = "Copper Pickaxe" + } + + override fun startPrimaryUse(delta: Float) = PickaxeCore.startPrimaryUse(delta, this) + override fun endPrimaryUse(delta: Float) = PickaxeCore.endPrimaryUse(delta, this) +} + +/** + * Created by minjaesong on 2019-03-10. + */ +class PickaxeIron(override val originalID: ItemID) : GameItem() { + + override var dynamicID: ItemID = originalID + override val originalName = "PACKAGED_PICK" + override var baseToolSize: Double? = BASE_MASS_AND_SIZE + override var stackable = true + override var inventoryCategory = Category.TOOL + override val isUnique = false + override val isDynamic = true + override var material = MaterialCodex["IRON"] + override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE + override val itemImage: TextureRegion? + get() = (AppLoader.resourcePool["basegame.items24"] as TextureRegionPack).get(1,0) + + init { + super.equipPosition = GameItem.EquipPosition.HAND_GRIP + super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() + super.durability = maxDurability.toFloat() + super.name = "Iron Pickaxe" + } + + override fun startPrimaryUse(delta: Float) = PickaxeCore.startPrimaryUse(delta, this) + override fun endPrimaryUse(delta: Float) = PickaxeCore.endPrimaryUse(delta, this) +} + +/** + * Created by minjaesong on 2019-03-10. + */ +class PickaxeSteel(override val originalID: ItemID) : GameItem() { + + override var dynamicID: ItemID = originalID + override val originalName = "PACKAGED_PICK" + override var baseToolSize: Double? = BASE_MASS_AND_SIZE + override var stackable = true + override var inventoryCategory = Category.TOOL + override val isUnique = false + override val isDynamic = true + override var material = MaterialCodex["STAL"] + override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE + override val itemImage: TextureRegion? + get() = (AppLoader.resourcePool["basegame.items24"] as TextureRegionPack).get(2,0) + + init { + super.equipPosition = GameItem.EquipPosition.HAND_GRIP + super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() + super.durability = maxDurability.toFloat() + super.name = "Steel Pickaxe" + } + + override fun startPrimaryUse(delta: Float) = PickaxeCore.startPrimaryUse(delta, this) + override fun endPrimaryUse(delta: Float) = PickaxeCore.endPrimaryUse(delta, this) } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/items/WirePieceSignalWire.kt b/src/net/torvald/terrarum/modulebasegame/items/WirePieceSignalWire.kt index 44c9eb676..3462b734e 100644 --- a/src/net/torvald/terrarum/modulebasegame/items/WirePieceSignalWire.kt +++ b/src/net/torvald/terrarum/modulebasegame/items/WirePieceSignalWire.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion import net.torvald.terrarum.AppLoader import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.itemproperties.ItemID +import net.torvald.terrarum.itemproperties.Material import net.torvald.terrarum.modulebasegame.IngameRenderer import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack @@ -20,7 +21,7 @@ class WirePieceSignalWire(override val originalID: ItemID) : GameItem() { override var inventoryCategory = Category.WIRE override val isUnique = false override val isDynamic = false - override val material = GameItem.NULL_MATERIAL + override val material = Material() override val itemImage: TextureRegion? get() = (AppLoader.resourcePool["basegame.items16"] as TextureRegionPack).get(1,9)