mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
smelter: working smelting? and working sprite change
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1806,7 +1806,7 @@ open class ActorWithBody : Actor {
|
||||
if (isVisible) {
|
||||
blendNormalStraightAlpha(batch)
|
||||
if (spriteEmissive != null)
|
||||
drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 1)
|
||||
drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 2)
|
||||
else if (sprite != null)
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, 2, Color.BLACK)
|
||||
}
|
||||
@@ -2221,8 +2221,8 @@ open class ActorWithBody : Actor {
|
||||
return if (Math.abs(x) > ceil) ceil else x
|
||||
}
|
||||
|
||||
@Transient private val HITBOX_COLOURS0 = Color(0xFF00FF88.toInt())
|
||||
@Transient private val HITBOX_COLOURS1 = Color(0xFFFF0088.toInt())
|
||||
@Transient internal val HITBOX_COLOURS0 = Color(0xFF00FF88.toInt())
|
||||
@Transient internal val HITBOX_COLOURS1 = Color(0xFFFF0088.toInt())
|
||||
|
||||
|
||||
fun isCloseEnough(a: Double, b: Double) = ((a / b).let { if (it.isNaN()) 0.0 else it } - 1).absoluteValue < PHYS_EPSILON_DIST
|
||||
|
||||
@@ -44,6 +44,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
*/
|
||||
open var smokiness = Float.POSITIVE_INFINITY
|
||||
|
||||
open var smeltingProduct: ItemID? = null
|
||||
|
||||
open var dynamicID: ItemID = originalID
|
||||
/**
|
||||
* if the ID is a Actor range, it's an actor contained in a pocket.
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
@@ -9,6 +12,8 @@ import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Lightbox
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameparticles.ParticleVanishingSprite
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
@@ -39,6 +44,16 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
|
||||
@Transient override val tags = listOf("basicsmelter")
|
||||
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame/sprites/fixtures/smelter_tall.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/smelter_tall.tga"), 48, 64)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("basegame/sprites/fixtures/smelter_tall_emsv.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/smelter_tall_emsv.tga"), 48, 64)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
}
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 3, 4), // temporary value, will be overwritten by spawn()
|
||||
nameFun = { Lang["ITEM_SMELTER_SMALL"] },
|
||||
@@ -49,16 +64,14 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
|
||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall.tga")
|
||||
val itemImage2 = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall_emsv.tga")
|
||||
|
||||
density = BlockCodex[Block.STONE].density.toDouble()
|
||||
setHitboxDimension(itemImage.texture.width, itemImage.texture.height, 0, 0)
|
||||
setHitboxDimension(48, 64, 0, 0)
|
||||
|
||||
makeNewSprite(TextureRegionPack(itemImage.texture, itemImage.texture.width, itemImage.texture.height)).let {
|
||||
makeNewSprite(CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/smelter_tall.tga")).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
makeNewSpriteEmissive(TextureRegionPack(itemImage2.texture, itemImage.texture.width, itemImage.texture.height)).let {
|
||||
makeNewSpriteEmissive(CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/smelter_tall_emsv.tga")).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
|
||||
@@ -88,13 +101,102 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
private var nextDelay = 0.25f // use smokiness value of the item
|
||||
private var spawnTimer = 0f
|
||||
|
||||
@Transient private val FUEL_CONSUMPTION = 1f
|
||||
companion object {
|
||||
@Transient val FUEL_CONSUMPTION = 1f
|
||||
@Transient val CALORIES_PER_ROASTING = 10 * 60 // 10 seconds @ 60 ticks per second
|
||||
}
|
||||
|
||||
@Transient private val RNG = HQRNG()
|
||||
|
||||
fun changeFireboxItemCount(delta: Long) {
|
||||
fireboxItem!!.qty += delta
|
||||
if (fireboxItem!!.qty <= 0L) {
|
||||
fireboxItem = null
|
||||
}
|
||||
}
|
||||
|
||||
fun changeOreItemCount(delta: Long) {
|
||||
oreItem!!.qty += delta
|
||||
if (oreItem!!.qty <= 0L) {
|
||||
oreItem = null
|
||||
}
|
||||
}
|
||||
|
||||
fun changeProductItemCount(delta: Long) {
|
||||
productItem!!.qty += delta
|
||||
if (productItem!!.qty <= 0L) {
|
||||
productItem = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawEmissive(frameDelta: Float, batch: SpriteBatch) {
|
||||
if (isVisible && spriteEmissive != null) {
|
||||
BlendMode.resolve(drawMode, batch)
|
||||
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = 1 // unlit
|
||||
drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 2, Color.WHITE)
|
||||
|
||||
(spriteEmissive as SheetSpriteAnimation).currentFrame = 0 // lit
|
||||
val r = 1f - (temperature - 1f).sqr()
|
||||
val g = (2f * temperature - 1f).coerceIn(0f, 1f)
|
||||
drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 2, Color(r, g, g, 1f))
|
||||
}
|
||||
|
||||
// debug display of hIntTilewiseHitbox
|
||||
if (KeyToggler.isOn(Input.Keys.F9)) {
|
||||
val blockMark = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common").get(0, 0)
|
||||
|
||||
for (y in 0..intTilewiseHitbox.height.toInt() + 1) {
|
||||
batch.color = if (y == intTilewiseHitbox.height.toInt() + 1) HITBOX_COLOURS1 else HITBOX_COLOURS0
|
||||
for (x in 0..intTilewiseHitbox.width.toInt()) {
|
||||
batch.draw(blockMark,
|
||||
(intTilewiseHitbox.startX.toFloat() + x) * TerrarumAppConfiguration.TILE_SIZEF,
|
||||
(intTilewiseHitbox.startY.toFloat() + y) * TerrarumAppConfiguration.TILE_SIZEF
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
batch.color = Color.WHITE
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawBody(frameDelta: Float, batch: SpriteBatch) {
|
||||
if (isVisible && sprite != null) {
|
||||
BlendMode.resolve(drawMode, batch)
|
||||
|
||||
(sprite as SheetSpriteAnimation).currentFrame = 1 // unlit
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, forcedColourFilter = Color.WHITE)
|
||||
|
||||
(sprite as SheetSpriteAnimation).currentFrame = 2 // lit overlay
|
||||
val r = 1f - (temperature - 1f).sqr()
|
||||
val g = (2f * temperature - 1f).coerceIn(0f, 1f)
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, forcedColourFilter = Color(1f, g, g, r))
|
||||
}
|
||||
|
||||
// debug display of hIntTilewiseHitbox
|
||||
if (KeyToggler.isOn(Input.Keys.F9)) {
|
||||
val blockMark = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common").get(0, 0)
|
||||
|
||||
for (y in 0..intTilewiseHitbox.height.toInt() + 1) {
|
||||
batch.color = if (y == intTilewiseHitbox.height.toInt() + 1) HITBOX_COLOURS1 else HITBOX_COLOURS0
|
||||
for (x in 0..intTilewiseHitbox.width.toInt()) {
|
||||
batch.draw(blockMark,
|
||||
(intTilewiseHitbox.startX.toFloat() + x) * TerrarumAppConfiguration.TILE_SIZEF,
|
||||
(intTilewiseHitbox.startY.toFloat() + y) * TerrarumAppConfiguration.TILE_SIZEF
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
batch.color = Color.WHITE
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
val oreItemProp = ItemCodex[oreItem?.itm]
|
||||
val fuelItemProp = ItemCodex[fireboxItem?.itm]
|
||||
|
||||
// consume fuel
|
||||
if (fuelCaloriesNow > 0f) {
|
||||
fuelCaloriesNow -= FUEL_CONSUMPTION
|
||||
@@ -103,16 +205,13 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
temperature += 1f /2048f
|
||||
}
|
||||
// take fuel from the item slot
|
||||
else if (fuelCaloriesNow <= 0f && fireboxItem != null && fireboxItem!!.qty > 0L) {
|
||||
fuelCaloriesNow = ItemCodex[fireboxItem!!.itm]!!.calories
|
||||
fuelCaloriesMax = ItemCodex[fireboxItem!!.itm]!!.calories
|
||||
nextDelayBase = ItemCodex[fireboxItem!!.itm]!!.smokiness
|
||||
else if (fuelCaloriesNow <= 0f && fuelItemProp?.calories != null && fireboxItem!!.qty > 0L) {
|
||||
fuelCaloriesNow = fuelItemProp.calories
|
||||
fuelCaloriesMax = fuelItemProp.calories
|
||||
nextDelayBase = fuelItemProp.smokiness
|
||||
nextDelay = (nextDelayBase * (1.0 + RNG.nextTriangularBal() * 0.1)).toFloat()
|
||||
|
||||
fireboxItem!!.qty -= 1L
|
||||
if (fireboxItem!!.qty == 0L) {
|
||||
fireboxItem = null
|
||||
}
|
||||
changeFireboxItemCount(-1)
|
||||
}
|
||||
// no item on the slot
|
||||
else if (fuelCaloriesNow <= 0f && fireboxItem == null) {
|
||||
@@ -140,6 +239,32 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
(sprite as? SheetSpriteAnimation)?.delays?.set(0, Math.random().toFloat() * 0.4f + 0.1f)
|
||||
}
|
||||
|
||||
// roast items
|
||||
if (oreItem != null &&
|
||||
fuelCaloriesNow > 0f &&
|
||||
oreItemProp?.smeltingProduct != null &&
|
||||
(productItem == null || oreItemProp.smeltingProduct == productItem!!.itm)
|
||||
) {
|
||||
|
||||
progress += temperature * 5f // debug speedup
|
||||
|
||||
if (progress >= CALORIES_PER_ROASTING) {
|
||||
val smeltingProduct = oreItemProp.smeltingProduct!!
|
||||
if (productItem == null)
|
||||
productItem = InventoryPair(smeltingProduct, 1L)
|
||||
else
|
||||
changeProductItemCount(1)
|
||||
|
||||
// take the ore item
|
||||
changeOreItemCount(-1)
|
||||
|
||||
progress = 0f
|
||||
}
|
||||
}
|
||||
else if (oreItem == null) {
|
||||
progress = 0f
|
||||
}
|
||||
|
||||
|
||||
spawnTimer += delta
|
||||
}
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-12-04.
|
||||
*/
|
||||
class ItemSmelterBasic(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic") {
|
||||
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame/sprites/fixtures/smelter_tall.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/smelter_tall.tga"), 48, 64)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("basegame/sprites/fixtures/smelter_tall_emsv.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/smelter_tall_emsv.tga"), 48, 64)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
}
|
||||
|
||||
override var baseMass = 100.0
|
||||
override val isDynamic = false
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall.tga")
|
||||
get() = CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/smelter_tall.tga").get(1, 0)
|
||||
override val itemImageEmissive: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall_emsv.tga")
|
||||
get() = CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/smelter_tall_emsv.tga").get(1, 0)
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var originalName = "ITEM_SMELTER_SMALL"
|
||||
|
||||
@@ -122,16 +122,19 @@ class OreStick(originalID: ItemID) : OreItemBase(originalID) {
|
||||
}
|
||||
class OreCopper(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_MALACHITE"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:112"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(1,6)
|
||||
}
|
||||
class OreIron(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_HAEMATITE"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:113"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(2,6)
|
||||
}
|
||||
class OreCoal(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_COAL"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:114"
|
||||
override var calories = 4800.0
|
||||
override var smokiness = 0.3f
|
||||
override val itemImage: TextureRegion
|
||||
@@ -139,28 +142,33 @@ class OreCoal(originalID: ItemID) : OreItemBase(originalID) {
|
||||
}
|
||||
class OreZinc(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_SPHALERITE"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:115"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(4,6)
|
||||
}
|
||||
class OreTin(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_CASSITERITE"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:116"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(5,6)
|
||||
}
|
||||
class OreGold(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_NATURAL_GOLD"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:117"
|
||||
override val materialId: String = "AURM"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(6, 6)
|
||||
}
|
||||
class OreSilver(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_NATURAL_SILVER"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:118"
|
||||
override val materialId: String = "ARGN"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(7,6)
|
||||
}
|
||||
class OreLead(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_GALENA"
|
||||
override var smeltingProduct: ItemID? = "item@basegame:119"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(8,6)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
}
|
||||
else if (smelter.oreItem!!.itm == gameItem.dynamicID) {
|
||||
getPlayerInventory().remove(gameItem.dynamicID, amount)
|
||||
smelter.oreItem!!.qty += amount
|
||||
smelter.changeOreItemCount(amount)
|
||||
}
|
||||
}
|
||||
// firebox
|
||||
@@ -60,7 +60,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
}
|
||||
else if (smelter.fireboxItem!!.itm == gameItem.dynamicID) {
|
||||
getPlayerInventory().remove(gameItem.dynamicID, amount)
|
||||
smelter.fireboxItem!!.qty += amount
|
||||
smelter.changeFireboxItemCount(amount)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
// add to the inventory slot
|
||||
if (smelter.oreItem != null && addCount1 >= 1L) {
|
||||
getPlayerInventory().add(smelter.oreItem!!.itm, addCount2)
|
||||
smelter.oreItem!!.qty -= addCount2
|
||||
smelter.changeOreItemCount(-addCount2)
|
||||
}
|
||||
// remove from the inventory slot
|
||||
else if (addCount1 <= -1L) {
|
||||
@@ -92,7 +92,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
if (smelter.oreItem == null)
|
||||
smelter.oreItem = InventoryPair(itemToUse, -addCount2)
|
||||
else
|
||||
smelter.oreItem!!.qty -= addCount2
|
||||
smelter.changeOreItemCount(-addCount2)
|
||||
}
|
||||
if (smelter.oreItem != null && smelter.oreItem!!.qty == 0L) smelter.oreItem = null
|
||||
else if (smelter.oreItem != null && smelter.oreItem!!.qty < 0L) throw Error("Item removal count is larger than what was on the slot")
|
||||
@@ -109,7 +109,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
// add to the inventory slot
|
||||
if (smelter.fireboxItem != null && addCount1 >= 1L) {
|
||||
getPlayerInventory().add(smelter.fireboxItem!!.itm, addCount2)
|
||||
smelter.fireboxItem!!.qty -= addCount2
|
||||
smelter.changeFireboxItemCount(-addCount2)
|
||||
}
|
||||
// remove from the inventory slot
|
||||
else if (addCount1 <= -1L) {
|
||||
@@ -117,7 +117,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
if (smelter.fireboxItem == null)
|
||||
smelter.fireboxItem = InventoryPair(itemToUse, -addCount2)
|
||||
else
|
||||
smelter.fireboxItem!!.qty -= addCount2
|
||||
smelter.changeFireboxItemCount(-addCount2)
|
||||
}
|
||||
if (smelter.fireboxItem != null && smelter.fireboxItem!!.qty == 0L) smelter.fireboxItem = null
|
||||
else if (smelter.fireboxItem != null && smelter.fireboxItem!!.qty < 0L) throw Error("Item removal count is larger than what was on the slot")
|
||||
@@ -143,8 +143,8 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
|
||||
private val smelterCellIcons = CommonResourcePool.getAsTextureRegionPack("basegame_gui_smelter_icons")
|
||||
|
||||
private var smelterBackdrop =
|
||||
FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall.tga")
|
||||
private var smelterBackdrops =
|
||||
CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/smelter_tall.tga")
|
||||
|
||||
|
||||
private val leftPanelWidth = playerThings.width
|
||||
@@ -154,8 +154,8 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
|
||||
private val backdropColour = Color(0x999999_c8.toInt())
|
||||
private val backdropZoom = 6
|
||||
private val backdropX = (leftPanelX + (leftPanelWidth - smelterBackdrop.regionWidth * backdropZoom) / 2).toFloat()
|
||||
private val backdropY = (leftPanelY + (leftPanelHeight - smelterBackdrop.regionHeight * backdropZoom) / 2).toFloat()
|
||||
private val backdropX = (leftPanelX + (leftPanelWidth - smelterBackdrops.tileW * backdropZoom) / 2).toFloat()
|
||||
private val backdropY = (leftPanelY + (leftPanelHeight - smelterBackdrops.tileH * backdropZoom) / 2).toFloat()
|
||||
|
||||
private val oreX = backdropX + 12 * backdropZoom + 6
|
||||
private val oreY = backdropY + 23 * backdropZoom + 3
|
||||
@@ -209,8 +209,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
|
||||
if (removeCount != null) {
|
||||
getPlayerInventory().add(smelter.oreItem!!.itm, removeCount)
|
||||
smelter.oreItem!!.qty -= removeCount
|
||||
if (smelter.oreItem!!.qty == 0L) smelter.oreItem = null
|
||||
smelter.changeOreItemCount(-removeCount)
|
||||
}
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
@@ -231,12 +230,12 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
// add to the slot
|
||||
if (removeCount1 >= 1L) {
|
||||
playerInventory.remove(smelter.oreItem!!.itm, removeCount2)
|
||||
smelter.oreItem!!.qty += removeCount2
|
||||
smelter.changeOreItemCount(removeCount2)
|
||||
}
|
||||
// remove from the slot
|
||||
else if (removeCount1 <= -1L) {
|
||||
getPlayerInventory().add(smelter.oreItem!!.itm, -removeCount2)
|
||||
smelter.oreItem!!.qty += removeCount2
|
||||
smelter.changeOreItemCount(removeCount2)
|
||||
}
|
||||
if (smelter.oreItem!!.qty == 0L) smelter.oreItem = null
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
@@ -268,8 +267,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
|
||||
if (removeCount != null) {
|
||||
getPlayerInventory().add(smelter.fireboxItem!!.itm, removeCount)
|
||||
smelter.fireboxItem!!.qty -= removeCount
|
||||
if (smelter.fireboxItem!!.qty == 0L) smelter.fireboxItem = null
|
||||
smelter.changeFireboxItemCount(-removeCount)
|
||||
}
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
@@ -290,12 +288,12 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
// add to the slot
|
||||
if (removeCount1 >= 1L) {
|
||||
playerInventory.remove(smelter.fireboxItem!!.itm, removeCount2)
|
||||
smelter.fireboxItem!!.qty += removeCount2
|
||||
smelter.changeFireboxItemCount(removeCount2)
|
||||
}
|
||||
// remove from the slot
|
||||
else if (removeCount1 <= -1L) {
|
||||
getPlayerInventory().add(smelter.fireboxItem!!.itm, -removeCount2)
|
||||
smelter.fireboxItem!!.qty += removeCount2
|
||||
smelter.changeFireboxItemCount(removeCount2)
|
||||
}
|
||||
if (smelter.fireboxItem!!.qty == 0L) smelter.fireboxItem = null
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
@@ -327,8 +325,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
|
||||
if (removeCount != null) {
|
||||
getPlayerInventory().add(smelter.productItem!!.itm, removeCount)
|
||||
smelter.productItem!!.qty -= removeCount
|
||||
if (smelter.productItem!!.qty == 0L) smelter.productItem = null
|
||||
smelter.changeProductItemCount(-removeCount)
|
||||
}
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
@@ -345,7 +342,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
// remove from the slot
|
||||
if (removeCount1 <= -1L) {
|
||||
getPlayerInventory().add(smelter.productItem!!.itm, -removeCount2)
|
||||
smelter.productItem!!.qty += removeCount2
|
||||
smelter.changeProductItemCount(removeCount2)
|
||||
}
|
||||
if (smelter.productItem!!.qty == 0L) smelter.productItem = null
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
@@ -507,11 +504,13 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
|
||||
override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||
batch.color = backdropColour
|
||||
batch.draw(smelterBackdrop, backdropX, backdropY, smelterBackdrop.regionWidth * 6f, smelterBackdrop.regionHeight * 6f)
|
||||
// batch.draw(smelterBackdrops.get(1,0), backdropX, backdropY, smelterBackdrops.tileW * 6f, smelterBackdrops.tileH * 6f)
|
||||
// batch.color = backdropColour mul Color(1f, 1f, 1f, smelter.temperature)
|
||||
batch.draw(smelterBackdrops.get(0,0), backdropX, backdropY, smelterBackdrops.tileW * 6f, smelterBackdrops.tileH * 6f)
|
||||
|
||||
uiItems.forEach { it.render(frameDelta, batch, camera) }
|
||||
|
||||
drawProgressGauge(batch, oreItemSlot.posX, oreItemSlot.posY, smelter.progress)
|
||||
drawProgressGauge(batch, oreItemSlot.posX, oreItemSlot.posY, smelter.progress.toFloat() / FixtureSmelterBasic.CALORIES_PER_ROASTING)
|
||||
drawProgressGauge(batch, fireboxItemSlot.posX, fireboxItemSlot.posY, (smelter.fuelCaloriesNow / (smelter.fuelCaloriesMax ?: Double.POSITIVE_INFINITY)).toFloat())
|
||||
drawThermoGauge(batch, thermoX, thermoY, smelter.temperature)
|
||||
|
||||
@@ -561,6 +560,8 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
* @param y y-position of the inventory cell that will have the gauge
|
||||
*/
|
||||
private fun drawProgressGauge(batch: SpriteBatch, x: Int, y: Int, percentage: Float) {
|
||||
val percentage = percentage.coerceIn(0f, 1f)
|
||||
|
||||
batch.color = Toolkit.Theme.COL_CELL_FILL
|
||||
Toolkit.fillArea(batch, x - 7, y, 6, UIItemInventoryElemSimple.height)
|
||||
|
||||
@@ -574,6 +575,8 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
}
|
||||
|
||||
private fun drawThermoGauge(batch: SpriteBatch, x: Int, y: Int, percentage: Float) {
|
||||
val percentage = percentage.coerceIn(0f, 1f)
|
||||
|
||||
batch.color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER
|
||||
Toolkit.drawStraightLine(batch, x, y - 1, x + 4, 1, false)
|
||||
Toolkit.drawStraightLine(batch, x, y + UIItemInventoryElemSimple.height + 7, x + 4, 1, false)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user