itemised the torch

This commit is contained in:
minjaesong
2024-02-16 00:26:13 +09:00
parent 76586baba5
commit 26bdd2253a
14 changed files with 57 additions and 31 deletions

View File

@@ -89,9 +89,9 @@
"164";"164";"164";"BLOCK_PLATFORM_ROSEWOOD";"0.0312";"0.0312";"0.0312";"0.0312";"5";"900";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"PLATFORM,WOODEN" "164";"164";"164";"BLOCK_PLATFORM_ROSEWOOD";"0.0312";"0.0312";"0.0312";"0.0312";"5";"900";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"PLATFORM,WOODEN"
# lights # lights
"176";"176";"176";"BLOCK_TORCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"800";"FXTR";"0";"0";"N/A";"1";"0";"16";"1.0000";"0.6372";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,WOODEN" "176";"item@basegame:33";"item@basegame:33";"BLOCK_TORCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"800";"FXTR";"0";"0";"N/A";"1";"0";"16";"1.0000";"0.6372";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,WOODEN"
#"177";"177";"177";"BLOCK_TORCH_FROST";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1100";"FXTR";"0";"0";"N/A";"1";"0";"16";"0.3048";"0.4848";"1.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,WOODEN" #"177";"177";"177";"BLOCK_TORCH_FROST";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1100";"FXTR";"0";"0";"N/A";"1";"0";"16";"0.3048";"0.4848";"1.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,WOODEN"
"192";"176";"176";"BLOCK_TORCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"800";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL,WOODEN" "192";"item@basegame:33";"item@basegame:33";"BLOCK_TORCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"800";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL,WOODEN"
#"193";"177";"177";"BLOCK_TORCH_FROST";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1100";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL,WOODEN" #"193";"177";"177";"BLOCK_TORCH_FROST";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1100";"FXTR";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,UNLIT,INTERNAL,WOODEN"
"208";"208";"208";"BLOCK_ILLUMINATOR_WHITE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.9270";"0.9414";"0.8519";"0.0000";"N/A";"N/A";"0.0";"LIGHT,NORANDTILE" "208";"208";"208";"BLOCK_ILLUMINATOR_WHITE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"0.9270";"0.9414";"0.8519";"0.0000";"N/A";"N/A";"0.0";"LIGHT,NORANDTILE"
"209";"209";"209";"BLOCK_ILLUMINATOR_YELLOW";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"1.0000";"0.8408";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,NORANDTILE" "209";"209";"209";"BLOCK_ILLUMINATOR_YELLOW";"0.0312";"0.0312";"0.0312";"0.0312";"1";"2500";"GLAS";"1";"1";"N/A";"0";"0";"16";"1.0000";"0.8408";"0.0000";"0.0000";"N/A";"N/A";"0.0";"LIGHT,NORANDTILE"
Can't render this file because it contains an unexpected character in line 18 and column 2.

View File

@@ -1,5 +1,5 @@
{ {
"basegame:176": { /* torch */ "item@basegame:33": { /* torch */
"workbench": "", "workbench": "",
"ingredients": [ "ingredients": [
[5, 1, "item@basegame:18", 1, "item@basegame:130"], /* 5 torches = 1 stick, 1 coal */ [5, 1, "item@basegame:18", 1, "item@basegame:130"], /* 5 torches = 1 stick, 1 coal */
@@ -9,8 +9,7 @@
"item@basegame:5": { /* tiki torch */ "item@basegame:5": { /* tiki torch */
"workbench": "", "workbench": "",
"ingredients": [ "ingredients": [
[1, 1, "$WOOD", 3, "item@basegame:18", 1, "basegame:176"], /* 1 tiki torch = 1 wood, 3 sticks, 1 torch */ [1, 1, "$WOOD", 3, "item@basegame:18", 1, "item@basegame:33"] /* 1 tiki torch = 1 wood, 3 sticks, 1 torch */
[1, 1, "$WOOD", 3, "item@basegame:18", 1, "basegame:192"]
] ]
}, },

View File

@@ -31,6 +31,7 @@ id;classname;tags
30;net.torvald.terrarum.modulebasegame.gameitems.ItemMusicalTurntable;FIXTURE,MUSIC 30;net.torvald.terrarum.modulebasegame.gameitems.ItemMusicalTurntable;FIXTURE,MUSIC
31;net.torvald.terrarum.modulebasegame.gameitems.ItemGunpowder;POWDER,EXPLOSIVE 31;net.torvald.terrarum.modulebasegame.gameitems.ItemGunpowder;POWDER,EXPLOSIVE
32;net.torvald.terrarum.modulebasegame.gameitems.ItemCherryBomb;EXPLOSIVE,THROWABLE 32;net.torvald.terrarum.modulebasegame.gameitems.ItemCherryBomb;EXPLOSIVE,THROWABLE
33;net.torvald.terrarum.modulebasegame.gameitems.ItemTorch;FIXTURE,LIGHT
# ingots # ingots
26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel;INGOT 26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel;INGOT
1 id classname tags
31 31 net.torvald.terrarum.modulebasegame.gameitems.ItemGunpowder POWDER,EXPLOSIVE
32 32 net.torvald.terrarum.modulebasegame.gameitems.ItemCherryBomb EXPLOSIVE,THROWABLE
33 # ingots 33 net.torvald.terrarum.modulebasegame.gameitems.ItemTorch FIXTURE,LIGHT
34 # ingots
35 26 net.torvald.terrarum.modulebasegame.gameitems.IngotSteel INGOT
36 112 net.torvald.terrarum.modulebasegame.gameitems.IngotCopper INGOT
37 113 net.torvald.terrarum.modulebasegame.gameitems.IngotIron INGOT

Binary file not shown.

Binary file not shown.

View File

@@ -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) { private fun fetchItemImage(mode: Int, item: GameItem) = when (mode) {
0 -> ItemCodex.getItemImage(item) 0 -> ItemCodex.getItemImage(item)
1 -> ItemCodex.getItemImageGlow(item) 1 -> ItemCodex.getItemImageGlow(item)

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.utils.JsonValue import com.badlogic.gdx.utils.JsonValue
import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.App.* import net.torvald.terrarum.App.*
import net.torvald.terrarum.App.setToGameConfig import net.torvald.terrarum.App.setToGameConfig
import net.torvald.terrarum.audio.AudioCodex import net.torvald.terrarum.audio.AudioCodex
@@ -537,13 +538,10 @@ object ModMgr {
Terrarum.blockCodex.fromModule(module, "blocks/blocks.csv") { tile -> Terrarum.blockCodex.fromModule(module, "blocks/blocks.csv") { tile ->
// register blocks as items // register blocks as items
ItemCodex[tile.id] = makeNewItemObj(tile, false) ItemCodex[tile.id] = makeNewItemObj(tile, false)
if (IS_DEVELOPMENT_BUILD) print(tile.id+" ") if (IS_DEVELOPMENT_BUILD) print(tile.id+" ")
if (BlockCodex[tile.id].isWallable) { if (BlockCodex[tile.id].isWallable) {
ItemCodex["wall@" + tile.id] = makeNewItemObj(tile, true).also { ItemCodex["wall@" + tile.id] = makeNewItemObj(tile, true)
it.tags.add("WALL")
}
if (IS_DEVELOPMENT_BUILD) print("wall@" + tile.id + " ") if (IS_DEVELOPMENT_BUILD) print("wall@" + tile.id + " ")
} }
@@ -585,8 +583,12 @@ object ModMgr {
// ) // )
// } // }
@Transient private var isWall1: Boolean = true
init { init {
isWall1 = isWall
tags.addAll(tile.tags) tags.addAll(tile.tags)
if (isWall) tags.add("WALL")
originalName = originalName =
if (isWall && tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE>>=BLOCK_WALL_NAME_TEMPLATE" if (isWall && tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE>>=BLOCK_WALL_NAME_TEMPLATE"
else if (isWall) "${tile.nameKey}>>=BLOCK_WALL_NAME_TEMPLATE" else if (isWall) "${tile.nameKey}>>=BLOCK_WALL_NAME_TEMPLATE"
@@ -594,6 +596,9 @@ object ModMgr {
else tile.nameKey else tile.nameKey
} }
override fun getLumCol() =
if (isWall1) Cvec(0)
else BlockCodex[originalID].getLumCol(0, 0)
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long { override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
return BlockBase.blockStartPrimaryUse(actor, this, dynamicID, delta) return BlockBase.blockStartPrimaryUse(actor, this, dynamicID, delta)

View File

@@ -1797,7 +1797,7 @@ open class ActorWithBody : Actor {
if (spriteGlow != null) if (spriteGlow != null)
drawSpriteInGoodPosition(frameDelta, spriteGlow!!, batch, 1) drawSpriteInGoodPosition(frameDelta, spriteGlow!!, batch, 1)
else if (sprite != null) 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) if (spriteEmissive != null)
drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 2) drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 2)
else if (sprite != null) 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
} }
} }

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.gameitems
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.ReferencingRanges.PREFIX_ACTORITEM import net.torvald.terrarum.ReferencingRanges.PREFIX_ACTORITEM
import net.torvald.terrarum.ReferencingRanges.PREFIX_DYNAMICITEM import net.torvald.terrarum.ReferencingRanges.PREFIX_DYNAMICITEM
@@ -28,6 +29,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
constructor() : this("-uninitialised-") constructor() : this("-uninitialised-")
open fun getLumCol(): Cvec = Cvec(0)
/** /**
* For items with COMBUSTIBLE tag only * For items with COMBUSTIBLE tag only
* *

View File

@@ -10,6 +10,7 @@ import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.gameactors.* import net.torvald.terrarum.gameactors.*
import net.torvald.terrarum.gameitems.* import net.torvald.terrarum.gameitems.*
import net.torvald.terrarum.weather.WeatherMixer.max
import org.dyn4j.geometry.Vector2 import org.dyn4j.geometry.Vector2
/** /**
@@ -130,12 +131,14 @@ open class DroppedItem : ActorWithBody {
else if (itemID.isWall()) else if (itemID.isWall())
BlockCodex[itemID.substringAfter('@')].getLumCol(randKey1, randKey2) BlockCodex[itemID.substringAfter('@')].getLumCol(randKey1, randKey2)
else { else {
Cvec( val itemprop = ItemCodex[itemID]
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMR) ?: 0f, (itemprop?.getLumCol() ?: Cvec(0)).max(
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMG) ?: 0f, Cvec(
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMB) ?: 0f, itemprop?.itemProperties?.getAsFloat(AVKey.LUMR) ?: 0f,
ItemCodex[itemID]?.itemProperties?.getAsFloat(AVKey.LUMA) ?: 0f, itemprop?.itemProperties?.getAsFloat(AVKey.LUMG) ?: 0f,
) itemprop?.itemProperties?.getAsFloat(AVKey.LUMB) ?: 0f,
itemprop?.itemProperties?.getAsFloat(AVKey.LUMA) ?: 0f,
))
} }
} }

View File

@@ -1,7 +1,10 @@
package net.torvald.terrarum.modulebasegame.gameitems package net.torvald.terrarum.modulebasegame.gameitems
import com.badlogic.gdx.graphics.g2d.TextureRegion 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.CommonResourcePool
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.gameitems.ItemID import net.torvald.terrarum.gameitems.ItemID
@@ -47,4 +50,20 @@ class ItemGunpowder(originalID: ItemID) : LightIngredientBase(originalID) {
override var originalName = "ITEM_GUNPOWDER" override var originalName = "ITEM_GUNPOWDER"
override val itemImage: TextureRegion override val itemImage: TextureRegion
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,12) 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)
} }

View File

@@ -506,7 +506,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
return if (ingredient.keyMode == CraftingCodex.CraftingItemKeyMode.TAG) { return if (ingredient.keyMode == CraftingCodex.CraftingItemKeyMode.TAG) {
candidate.maxByOrNull { it.qty }?.itm ?: ( candidate.maxByOrNull { it.qty }?.itm ?: (
(ItemCodex.itemCodex.firstNotNullOfOrNull { if (it.value.hasTag(ingredient.key)) it.key else null }) ?: (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 { else {

View File

@@ -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) 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( infix fun Cvec.max(other: Cvec) = Cvec(
if (this.r > other.r) this.r else other.r, if (this.r > other.r) this.r else other.r,
if (this.g > other.g) this.g else other.g, if (this.g > other.g) this.g else other.g,
if (this.b > other.b) this.b else other.b, if (this.b > other.b) this.b else other.b,

View File

@@ -377,10 +377,7 @@ object LightmapRenderer {
val heldItem = it.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP] val heldItem = it.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
val light = if (heldItem != null && (heldItem.isBlock())) val light = ItemCodex[heldItem]?.getLumCol() ?: Cvec(0)
BlockCodex[heldItem].getLumCol(0, 0)
else
Cvec(0)
Lightbox(Hitbox( Lightbox(Hitbox(