From c1deeea59e41d3c3bdfbd894273765175be6e8aa Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 14 Nov 2023 00:15:45 +0900 Subject: [PATCH] axe items --- assets/mods/basegame/items/itemid.csv | 4 + .../modulebasegame/gameitems/AxeCore.kt | 120 ++++++++++++++++++ .../gameitems/PickaxeGeneric.kt | 2 +- 3 files changed, 125 insertions(+), 1 deletion(-) diff --git a/assets/mods/basegame/items/itemid.csv b/assets/mods/basegame/items/itemid.csv index d32bfe24e..c4de3857e 100644 --- a/assets/mods/basegame/items/itemid.csv +++ b/assets/mods/basegame/items/itemid.csv @@ -17,6 +17,10 @@ id;classname 16;net.torvald.terrarum.modulebasegame.gameitems.ItemWorkbench 17;net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke 18;net.torvald.terrarum.modulebasegame.gameitems.OreStick +19;net.torvald.terrarum.modulebasegame.gameitems.AxeCopper +20;net.torvald.terrarum.modulebasegame.gameitems.AxeIron +21;net.torvald.terrarum.modulebasegame.gameitems.AxeSteel +22;net.torvald.terrarum.modulebasegame.gameitems.AxeWood # ores 128;net.torvald.terrarum.modulebasegame.gameitems.OreCopper diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/AxeCore.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/AxeCore.kt index 3da9704d0..4b46a4e78 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/AxeCore.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/AxeCore.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum.modulebasegame.gameitems import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.g2d.TextureRegion import net.torvald.terrarum.* import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.blockproperties.Block @@ -15,6 +16,8 @@ import net.torvald.terrarum.itemproperties.Calculate import net.torvald.terrarum.itemproperties.Item import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem +import net.torvald.terrarum.modulebasegame.gameitems.AxeCore.BASE_MASS_AND_SIZE +import net.torvald.terrarum.modulebasegame.gameitems.AxeCore.TOOL_DURABILITY_BASE import net.torvald.terrarum.worlddrawer.CreateTileAtlas import org.dyn4j.geometry.Vector2 import kotlin.math.roundToInt @@ -188,4 +191,121 @@ object AxeCore { const val BASE_MASS_AND_SIZE = 10.0 // of iron pick const val TOOL_DURABILITY_BASE = 350 // of iron pick +} + +/** + * Created by minjaesong on 2023-11-14. + */ +class AxeCopper(originalID: ItemID) : GameItem(originalID) { + internal constructor() : this("-uninitialised-") + + override var baseToolSize: Double? = BASE_MASS_AND_SIZE + override var inventoryCategory = Category.TOOL + override val isDynamic = true + override val materialId = "CUPR" + override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE + override val itemImage: TextureRegion + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(3,0) + + init { + equipPosition = GameItem.EquipPosition.HAND_GRIP + maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() + durability = maxDurability.toFloat() + tags.add("AXE") + originalName = "ITEM_HATCHET_COPPER" + } + + override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = + if (AxeCore.startPrimaryUse(actor, delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L + override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = AxeCore.endPrimaryUse(actor, this) +// override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = AxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY) + override fun effectOnUnequip(actor: ActorWithBody) { INGAME.setTooltipMessage(null) } + +} +/** + * Created by minjaesong on 2023-11-14. + */ +class AxeIron(originalID: ItemID) : GameItem(originalID) { + internal constructor() : this("-uninitialised-") + + override var baseToolSize: Double? = BASE_MASS_AND_SIZE + override var inventoryCategory = Category.TOOL + override val isDynamic = true + override val materialId = "IRON" + override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE + override val itemImage: TextureRegion + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(4,0) + + init { + equipPosition = GameItem.EquipPosition.HAND_GRIP + maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() + durability = maxDurability.toFloat() + tags.add("AXE") + originalName = "ITEM_HATCHET_IRON" + } + + override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = + if (AxeCore.startPrimaryUse(actor, delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L + override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = AxeCore.endPrimaryUse(actor, this) + // override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = AxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY) + override fun effectOnUnequip(actor: ActorWithBody) { INGAME.setTooltipMessage(null) } + +} +/** + * Created by minjaesong on 2023-11-14. + */ +class AxeSteel(originalID: ItemID) : GameItem(originalID) { + internal constructor() : this("-uninitialised-") + + override var baseToolSize: Double? = BASE_MASS_AND_SIZE + override var inventoryCategory = Category.TOOL + override val isDynamic = true + override val materialId = "STAL" + override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE + override val itemImage: TextureRegion + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(5,0) + + init { + equipPosition = GameItem.EquipPosition.HAND_GRIP + maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() + durability = maxDurability.toFloat() + tags.add("AXE") + originalName = "ITEM_HATCHET_STEEL" + } + + override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = + if (AxeCore.startPrimaryUse(actor, delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L + override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = AxeCore.endPrimaryUse(actor, this) + // override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = AxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY) + override fun effectOnUnequip(actor: ActorWithBody) { INGAME.setTooltipMessage(null) } + +} +/** + * Created by minjaesong on 2023-11-14. + */ +class AxeWood(originalID: ItemID) : GameItem(originalID) { + internal constructor() : this("-uninitialised-") + + override var baseToolSize: Double? = BASE_MASS_AND_SIZE + override var inventoryCategory = Category.TOOL + override val isDynamic = true + override val materialId = "WOOD" + override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE + override val itemImage: TextureRegion + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(9,4) + + init { + equipPosition = GameItem.EquipPosition.HAND_GRIP + maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() + durability = maxDurability.toFloat() + tags.add("AXE") + originalName = "ITEM_HATCHET_WOODEN" + } + + override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = + if (AxeCore.startPrimaryUse(actor, delta, this, Terrarum.mouseTileX, Terrarum.mouseTileY)) 0L else -1L + override fun endPrimaryUse(actor: ActorWithBody, delta: Float) = AxeCore.endPrimaryUse(actor, this) + // override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) = AxeCore.showOresTooltip(actor, this, Terrarum.mouseTileX, Terrarum.mouseTileY) + override fun effectOnUnequip(actor: ActorWithBody) { INGAME.setTooltipMessage(null) } + } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt index cb52902ab..89c313b39 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt @@ -313,7 +313,7 @@ class PickaxeWood(originalID: ItemID) : GameItem(originalID) { maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt() durability = maxDurability.toFloat() tags.add("PICK") - originalName = "ITEM_PICK_WOOD" + originalName = "ITEM_PICK_WOODEN" } override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =