smelter lightbox depends on its internal temperature

This commit is contained in:
minjaesong
2024-02-03 04:52:37 +09:00
parent 8cb4709cd7
commit f91fbf6cf0
4 changed files with 43 additions and 43 deletions

View File

@@ -13,13 +13,9 @@ 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
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
import net.torvald.terrarum.modulebasegame.ui.UICrafting
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
import net.torvald.terrarum.modulebasegame.ui.UISmelterBasic
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -80,6 +76,8 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
this.mainUI = UISmelterBasic(this)
}
@Transient val light = Cvec(0.5f, 0.18f, 0f, 0f)
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 2*TILE_SIZED, TILE_SIZED * 2, TILE_SIZED * 2), Cvec(0.5f, 0.18f, 0f, 0f)))
@Transient private val actorBlocks = arrayOf(
@@ -265,8 +263,15 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
progress = 0f
}
// update lightbox
lightBoxList.forEach {
it.light = light.cpy().mul(temperature)
}
spawnTimer += delta
if (temperature > 0.001f)
spawnTimer += delta
else
spawnTimer = 0f
}
}

View File

@@ -155,14 +155,9 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
val recipe = recipe as CraftingCodex.CraftingRecipe
// change selected recipe to mostViableRecipe then update the UIs accordingly
// FIXME recipe highlighting will not change correctly!
val selectedItems = ArrayList<ItemID>()
// auto-dial the spinner so that player would just have to click the Craft! button (for the most time, that is)
val howManyRequired = craftMult * amount
val howManyPlayerHas = player.searchByID(gameItem.dynamicID)?.qty ?: 0
val howManyPlayerMightNeed = ceil((howManyRequired - howManyPlayerHas).toDouble() / recipe.moq).toLong()
resetSpinner(howManyPlayerMightNeed.coerceIn(1L, App.getConfigInt("basegame:gameplay_max_crafting").toLong()))
resetSpinner()
ingredients.clear()
recipeClicked = recipe
@@ -372,10 +367,10 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
refreshCraftButtonStatus()
}
private fun resetSpinner(value: Long = 1L) {
private fun resetSpinner() {
spinnerCraftCount.resetToSmallest()
itemListIngredients.numberMultiplier = value
itemListCraftable.numberMultiplier = value
itemListIngredients.numberMultiplier = 1L
itemListCraftable.numberMultiplier = 1L
}
private var openingClickLatched = false

View File

@@ -83,7 +83,7 @@ class UIItemSpinner(
fboUpdateLatch = true
}
private fun changeValueBy(diff: Int) {
fun changeValueBy(diff: Int) {
currentIndex = (currentIndex + diff).coerceIn(values.indices)
value = values[currentIndex]
}