mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
reading material from the module; pixaxes use it
But "dynamic item" created from the pickaxe class is not right
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user