mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 22:31:52 +09:00
itemised the torch
This commit is contained in:
@@ -133,13 +133,6 @@ class AssembledSpriteAnimation(
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchItemImage(item: GameItem) = if (isEmissive)
|
||||
ItemCodex.getItemImageEmissive(item)
|
||||
else if (isGlow)
|
||||
ItemCodex.getItemImageGlow(item)
|
||||
else
|
||||
ItemCodex.getItemImage(item)
|
||||
|
||||
private fun fetchItemImage(mode: Int, item: GameItem) = when (mode) {
|
||||
0 -> ItemCodex.getItemImage(item)
|
||||
1 -> ItemCodex.getItemImageGlow(item)
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.App.*
|
||||
import net.torvald.terrarum.App.setToGameConfig
|
||||
import net.torvald.terrarum.audio.AudioCodex
|
||||
@@ -537,13 +538,10 @@ object ModMgr {
|
||||
Terrarum.blockCodex.fromModule(module, "blocks/blocks.csv") { tile ->
|
||||
// register blocks as items
|
||||
ItemCodex[tile.id] = makeNewItemObj(tile, false)
|
||||
|
||||
if (IS_DEVELOPMENT_BUILD) print(tile.id+" ")
|
||||
|
||||
if (BlockCodex[tile.id].isWallable) {
|
||||
ItemCodex["wall@" + tile.id] = makeNewItemObj(tile, true).also {
|
||||
it.tags.add("WALL")
|
||||
}
|
||||
ItemCodex["wall@" + tile.id] = makeNewItemObj(tile, true)
|
||||
if (IS_DEVELOPMENT_BUILD) print("wall@" + tile.id + " ")
|
||||
}
|
||||
|
||||
@@ -585,8 +583,12 @@ object ModMgr {
|
||||
// )
|
||||
// }
|
||||
|
||||
@Transient private var isWall1: Boolean = true
|
||||
|
||||
init {
|
||||
isWall1 = isWall
|
||||
tags.addAll(tile.tags)
|
||||
if (isWall) tags.add("WALL")
|
||||
originalName =
|
||||
if (isWall && tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE>>=BLOCK_WALL_NAME_TEMPLATE"
|
||||
else if (isWall) "${tile.nameKey}>>=BLOCK_WALL_NAME_TEMPLATE"
|
||||
@@ -594,6 +596,9 @@ object ModMgr {
|
||||
else tile.nameKey
|
||||
}
|
||||
|
||||
override fun getLumCol() =
|
||||
if (isWall1) Cvec(0)
|
||||
else BlockCodex[originalID].getLumCol(0, 0)
|
||||
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
|
||||
return BlockBase.blockStartPrimaryUse(actor, this, dynamicID, delta)
|
||||
|
||||
@@ -1797,7 +1797,7 @@ open class ActorWithBody : Actor {
|
||||
if (spriteGlow != null)
|
||||
drawSpriteInGoodPosition(frameDelta, spriteGlow!!, batch, 1)
|
||||
else if (sprite != null)
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, 0, Color.BLACK) // use black version of normal sprite as a substitution
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, 1, Color.BLACK) // use black version of normal sprite as a substitution
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1807,7 +1807,7 @@ open class ActorWithBody : Actor {
|
||||
if (spriteEmissive != null)
|
||||
drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 2)
|
||||
else if (sprite != null)
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, 0, Color.BLACK) // use black version of normal sprite as a substitution
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, 2, Color.BLACK) // use black version of normal sprite as a substitution
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.ReferencingRanges.PREFIX_ACTORITEM
|
||||
import net.torvald.terrarum.ReferencingRanges.PREFIX_DYNAMICITEM
|
||||
@@ -28,6 +29,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
|
||||
constructor() : this("-uninitialised-")
|
||||
|
||||
open fun getLumCol(): Cvec = Cvec(0)
|
||||
|
||||
/**
|
||||
* For items with COMBUSTIBLE tag only
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameitems.*
|
||||
import net.torvald.terrarum.weather.WeatherMixer.max
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
@@ -130,12 +131,14 @@ open class DroppedItem : ActorWithBody {
|
||||
else if (itemID.isWall())
|
||||
BlockCodex[itemID.substringAfter('@')].getLumCol(randKey1, randKey2)
|
||||
else {
|
||||
Cvec(
|
||||
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMR) ?: 0f,
|
||||
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMG) ?: 0f,
|
||||
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMB) ?: 0f,
|
||||
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMA) ?: 0f,
|
||||
)
|
||||
val itemprop = ItemCodex[itemID]
|
||||
(itemprop?.getLumCol() ?: Cvec(0)).max(
|
||||
Cvec(
|
||||
itemprop?.itemProperties?.getAsFloat(AVKey.LUMR) ?: 0f,
|
||||
itemprop?.itemProperties?.getAsFloat(AVKey.LUMG) ?: 0f,
|
||||
itemprop?.itemProperties?.getAsFloat(AVKey.LUMB) ?: 0f,
|
||||
itemprop?.itemProperties?.getAsFloat(AVKey.LUMA) ?: 0f,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
|
||||
@@ -47,4 +50,20 @@ class ItemGunpowder(originalID: ItemID) : LightIngredientBase(originalID) {
|
||||
override var originalName = "ITEM_GUNPOWDER"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,12)
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-15.
|
||||
*/
|
||||
class ItemTorch(originalID: ItemID) : LightIngredientBase(originalID) {
|
||||
override var baseMass = 0.8 // from blocks.csv
|
||||
override var inventoryCategory = Category.FIXTURE
|
||||
|
||||
override var originalName = "BLOCK_TORCH"
|
||||
override val itemImage: TextureRegion
|
||||
get() = FixtureItemBase.getItemImageFromSingleImage("basegame", "items/torch.tga")
|
||||
override val itemImageEmissive: TextureRegion
|
||||
get() = FixtureItemBase.getItemImageFromSingleImage("basegame", "items/torch_emsv.tga")
|
||||
|
||||
override fun getLumCol() = BlockCodex[Block.TORCH].getLumCol(0, 0)
|
||||
}
|
||||
@@ -506,7 +506,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
||||
return if (ingredient.keyMode == CraftingCodex.CraftingItemKeyMode.TAG) {
|
||||
candidate.maxByOrNull { it.qty }?.itm ?: (
|
||||
(ItemCodex.itemCodex.firstNotNullOfOrNull { if (it.value.hasTag(ingredient.key)) it.key else null }) ?:
|
||||
throw NullPointerException("Item with tag '${ingredient.key}' not found. Possible cause: game or a module not updated or installed")
|
||||
throw NullPointerException("Item with tag '${ingredient.key}' not found. Possible cause: game or a module not updated or installed (ingredient: $ingredient)")
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -741,8 +741,8 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
}
|
||||
|
||||
private operator fun Cvec.times(other: Float) = Cvec(this.r * other, this.g * other, this.b * other, this.a * other)
|
||||
private infix fun Cvec.max(other: Cvec) = Cvec(
|
||||
operator fun Cvec.times(other: Float) = Cvec(this.r * other, this.g * other, this.b * other, this.a * other)
|
||||
infix fun Cvec.max(other: Cvec) = Cvec(
|
||||
if (this.r > other.r) this.r else other.r,
|
||||
if (this.g > other.g) this.g else other.g,
|
||||
if (this.b > other.b) this.b else other.b,
|
||||
|
||||
@@ -377,10 +377,7 @@ object LightmapRenderer {
|
||||
|
||||
val heldItem = it.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||
|
||||
val light = if (heldItem != null && (heldItem.isBlock()))
|
||||
BlockCodex[heldItem].getLumCol(0, 0)
|
||||
else
|
||||
Cvec(0)
|
||||
val light = ItemCodex[heldItem]?.getLumCol() ?: Cvec(0)
|
||||
|
||||
|
||||
Lightbox(Hitbox(
|
||||
|
||||
Reference in New Issue
Block a user