mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
thermal stuffs
This commit is contained in:
@@ -16,7 +16,7 @@ id;classname;tags
|
||||
15;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerWood;TOOL,HAMMER
|
||||
16;net.torvald.terrarum.modulebasegame.gameitems.ItemWorkbench;FIXTURE,CRAFTING
|
||||
17;net.torvald.terrarum.modulebasegame.gameitems.ItemSmelterBasic;FIXTURE,STATION
|
||||
18;net.torvald.terrarum.modulebasegame.gameitems.OreStick;BURNABLE
|
||||
18;net.torvald.terrarum.modulebasegame.gameitems.OreStick;COMBUSTIBLE
|
||||
19;net.torvald.terrarum.modulebasegame.gameitems.AxeCopper;TOOL,AXE
|
||||
20;net.torvald.terrarum.modulebasegame.gameitems.AxeIron;TOOL,AXE
|
||||
21;net.torvald.terrarum.modulebasegame.gameitems.AxeSteel;TOOL,AXE
|
||||
@@ -31,7 +31,7 @@ id;classname;tags
|
||||
26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel;INGOT
|
||||
112;net.torvald.terrarum.modulebasegame.gameitems.IngotCopper;INGOT
|
||||
113;net.torvald.terrarum.modulebasegame.gameitems.IngotIron;INGOT
|
||||
114;net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke;INGOT,BURNABLE
|
||||
114;net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke;INGOT,COMBUSTIBLE
|
||||
115;net.torvald.terrarum.modulebasegame.gameitems.IngotZinc;INGOT
|
||||
116;net.torvald.terrarum.modulebasegame.gameitems.IngotTin;INGOT
|
||||
117;net.torvald.terrarum.modulebasegame.gameitems.IngotGold;INGOT
|
||||
@@ -41,7 +41,7 @@ id;classname;tags
|
||||
# ores
|
||||
128;net.torvald.terrarum.modulebasegame.gameitems.OreCopper;SMELTABLE
|
||||
129;net.torvald.terrarum.modulebasegame.gameitems.OreIron;SMELTABLE
|
||||
130;net.torvald.terrarum.modulebasegame.gameitems.OreCoal;SMELTABLE,BURNABLE
|
||||
130;net.torvald.terrarum.modulebasegame.gameitems.OreCoal;SMELTABLE,COMBUSTIBLE
|
||||
131;net.torvald.terrarum.modulebasegame.gameitems.OreZinc;SMELTABLE
|
||||
132;net.torvald.terrarum.modulebasegame.gameitems.OreTin;SMELTABLE
|
||||
133;net.torvald.terrarum.modulebasegame.gameitems.OreGold;SMELTABLE
|
||||
@@ -59,10 +59,10 @@ id;classname;tags
|
||||
163;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedRosewood;SEEDLING
|
||||
|
||||
# tree logs
|
||||
168;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsOak;
|
||||
169;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsEbony;
|
||||
170;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsBirch;
|
||||
171;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsRosewood;
|
||||
168;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsOak;COMBUSTIBLE
|
||||
169;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsEbony;COMBUSTIBLE
|
||||
170;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsBirch;COMBUSTIBLE
|
||||
171;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsRosewood;COMBUSTIBLE
|
||||
|
||||
|
||||
256;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorOak;FIXTURE
|
||||
|
||||
|
@@ -28,6 +28,22 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
|
||||
constructor() : this("-uninitialised-")
|
||||
|
||||
/**
|
||||
* For items with COMBUSTIBLE tag only
|
||||
*
|
||||
* If it burns for 80 seconds in the furnace, the calories value would be 80*60=4800, assuming tickrate of 60.
|
||||
* Assuming one item weighs 10 kilograms, 1 game-calories is about 5 watt-hours.
|
||||
*/
|
||||
open var calories = 0.0
|
||||
|
||||
/**
|
||||
* For items with COMBUSTIBLE tag only
|
||||
*
|
||||
* Lower=more smoky. How likely it would produce smokes when burned on a furnace. Smokiness = 0.25 means the furnace would
|
||||
* emit smoke particle every 0.25 seconds.
|
||||
*/
|
||||
open var smokiness = Float.POSITIVE_INFINITY
|
||||
|
||||
open var dynamicID: ItemID = originalID
|
||||
/**
|
||||
* if the ID is a Actor range, it's an actor contained in a pocket.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
@@ -24,8 +25,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
|
||||
var fuelCaloriesNow = 0f
|
||||
var fuelCaloriesMax: Float? = null
|
||||
var fuelCaloriesNow = 0.0 // arbitrary number, may as well be watts or joules
|
||||
var fuelCaloriesMax: Double? = null
|
||||
var temperature = 0f // 0f..1f
|
||||
var progress = 0f // 0f..1f
|
||||
|
||||
@@ -83,27 +84,63 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
}
|
||||
}
|
||||
|
||||
private var nextDelay = 0.25f
|
||||
private var nextDelayBase = 0.25f // use smokiness value of the item
|
||||
private var nextDelay = 0.25f // use smokiness value of the item
|
||||
private var spawnTimer = 0f
|
||||
|
||||
@Transient private val FUEL_CONSUMPTION = 1f
|
||||
|
||||
@Transient private val RNG = HQRNG()
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
// consume fuel
|
||||
if (fuelCaloriesNow > 0f) {
|
||||
fuelCaloriesNow -= FUEL_CONSUMPTION
|
||||
|
||||
// emit smokes TODO: only when hot
|
||||
// raise temperature
|
||||
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
|
||||
nextDelay = (nextDelayBase * (1.0 + RNG.nextTriangularBal() * 0.1)).toFloat()
|
||||
|
||||
fireboxItem!!.qty -= 1L
|
||||
if (fireboxItem!!.qty == 0L) {
|
||||
fireboxItem = null
|
||||
}
|
||||
}
|
||||
// no item on the slot
|
||||
else if (fuelCaloriesNow <= 0f && fireboxItem == null) {
|
||||
nextDelayBase = Float.POSITIVE_INFINITY
|
||||
nextDelay = Float.POSITIVE_INFINITY
|
||||
}
|
||||
|
||||
// tick a thermal loss
|
||||
temperature -= 1f / 4096f
|
||||
temperature = temperature.coerceIn(0f, 1f)
|
||||
|
||||
|
||||
// emit smokes only when there is something burning
|
||||
if (spawnTimer >= nextDelay) {
|
||||
(Terrarum.ingame as TerrarumIngame).addParticle(
|
||||
ParticleVanishingSprite(
|
||||
CommonResourcePool.getAsTextureRegionPack("particles-tiki_smoke.tga"),
|
||||
25f, true, hitbox.startX + TILE_SIZED, hitbox.startY + 16, false, (Math.random() * 256).toInt()
|
||||
))
|
||||
CommonResourcePool.getAsTextureRegionPack("particles-tiki_smoke.tga"),
|
||||
25f, true, hitbox.startX + TILE_SIZED, hitbox.startY + 16, false, (Math.random() * 256).toInt()
|
||||
)
|
||||
)
|
||||
|
||||
spawnTimer -= nextDelay
|
||||
nextDelay = Math.random().toFloat() * 0.25f + 0.25f
|
||||
nextDelay = (nextDelayBase * (1.0 + RNG.nextTriangularBal() * 0.1)).toFloat()
|
||||
|
||||
(sprite as? SheetSpriteAnimation)?.delays?.set(0, Math.random().toFloat() * 0.4f + 0.1f)
|
||||
}
|
||||
|
||||
|
||||
spawnTimer += delta
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ open class OreItemBase(originalID: ItemID) : GameItem(originalID) {
|
||||
class ItemLogsOak(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_LOGS_OAK"
|
||||
override val materialId = "WOOD"
|
||||
override var calories = 1920.0
|
||||
override var smokiness = 0.2f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,10)
|
||||
|
||||
@@ -44,6 +46,8 @@ class ItemLogsOak(originalID: ItemID) : OreItemBase(originalID) {
|
||||
class ItemLogsEbony(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_LOGS_EBONY"
|
||||
override val materialId = "WOOD"
|
||||
override var calories = 1920.0
|
||||
override var smokiness = 0.2f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(1,10)
|
||||
|
||||
@@ -55,6 +59,8 @@ class ItemLogsEbony(originalID: ItemID) : OreItemBase(originalID) {
|
||||
class ItemLogsBirch(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_LOGS_BIRCH"
|
||||
override val materialId = "WOOD"
|
||||
override var calories = 1920.0
|
||||
override var smokiness = 0.2f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(2,10)
|
||||
|
||||
@@ -66,6 +72,8 @@ class ItemLogsBirch(originalID: ItemID) : OreItemBase(originalID) {
|
||||
class ItemLogsRosewood(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_LOGS_ROSEWOOD"
|
||||
override val materialId = "WOOD"
|
||||
override var calories = 1920.0
|
||||
override var smokiness = 0.2f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(3,10)
|
||||
|
||||
@@ -107,6 +115,8 @@ class ItemSeedRosewood(originalID: ItemID) : OreItemBase(originalID) {
|
||||
class OreStick(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_WOOD_STICK"
|
||||
override val materialId = "WOOD"
|
||||
override var calories = 600.0
|
||||
override var smokiness = 0.2f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,6)
|
||||
}
|
||||
@@ -122,6 +132,8 @@ class OreIron(originalID: ItemID) : OreItemBase(originalID) {
|
||||
}
|
||||
class OreCoal(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_COAL"
|
||||
override var calories = 4800.0
|
||||
override var smokiness = 0.3f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(3,6)
|
||||
}
|
||||
@@ -155,6 +167,8 @@ class OreLead(originalID: ItemID) : OreItemBase(originalID) {
|
||||
|
||||
class ItemCoalCoke(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_COAL_COKE"
|
||||
override var calories = 4800.0
|
||||
override var smokiness = 0.4f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(9,6)
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
clickedOn = 2
|
||||
self.forceHighlighted = true
|
||||
oreItemSlot.forceHighlighted = false
|
||||
itemListUpdate { ItemCodex.hasTag(it.itm, "BURNABLE") }
|
||||
itemListUpdate { ItemCodex.hasTag(it.itm, "COMBUSTIBLE") }
|
||||
}
|
||||
else if (smelter.fireboxItem != null) {
|
||||
val removeCount = if (button == App.getConfigInt("config_mouseprimary"))
|
||||
@@ -512,7 +512,7 @@ class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
uiItems.forEach { it.render(frameDelta, batch, camera) }
|
||||
|
||||
drawProgressGauge(batch, oreItemSlot.posX, oreItemSlot.posY, smelter.progress)
|
||||
drawProgressGauge(batch, fireboxItemSlot.posX, fireboxItemSlot.posY, smelter.fuelCaloriesNow / (smelter.fuelCaloriesMax ?: Float.POSITIVE_INFINITY))
|
||||
drawProgressGauge(batch, fireboxItemSlot.posX, fireboxItemSlot.posY, (smelter.fuelCaloriesNow / (smelter.fuelCaloriesMax ?: Double.POSITIVE_INFINITY)).toFloat())
|
||||
drawThermoGauge(batch, thermoX, thermoY, smelter.temperature)
|
||||
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ class Biomegen(world: GameWorld, isFinal: Boolean, seed: Long, params: Any, val
|
||||
Worldgen.threadExecutor.renew()
|
||||
submitJob(loadscreen)
|
||||
Worldgen.threadExecutor.join()
|
||||
|
||||
App.printdbg(this, "Waking up Worldgen")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -30,8 +30,6 @@ class Cavegen(world: GameWorld, isFinal: Boolean, val highlandLowlandSelectCache
|
||||
Worldgen.threadExecutor.renew()
|
||||
submitJob(loadscreen)
|
||||
Worldgen.threadExecutor.join()
|
||||
|
||||
App.printdbg(this, "Waking up Worldgen")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@ class Terragen(world: GameWorld, isFinal: Boolean , val highlandLowlandSelectCac
|
||||
Worldgen.threadExecutor.renew()
|
||||
submitJob(loadscreen)
|
||||
Worldgen.threadExecutor.join()
|
||||
|
||||
printdbg(this, "Waking up Worldgen")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ class Treegen(world: GameWorld, isFinal: Boolean, seed: Long, val terragenParams
|
||||
Worldgen.threadExecutor.renew()
|
||||
submitJob(loadscreen)
|
||||
Worldgen.threadExecutor.join()
|
||||
|
||||
App.printdbg(this, "Waking up Worldgen")
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +212,7 @@ class Treegen(world: GameWorld, isFinal: Boolean, seed: Long, val terragenParams
|
||||
val chkP1 = (2..heightSum).any { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid }
|
||||
|
||||
if (chkM1 || chk0 || chkP1) {
|
||||
printdbg(this, "Ceiling not tall enough at $x, $y, aborting")
|
||||
// printdbg(this, "Ceiling not tall enough at $x, $y, aborting")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -246,7 +244,7 @@ class Treegen(world: GameWorld, isFinal: Boolean, seed: Long, val terragenParams
|
||||
val chkP1 = (2..heightSum).any { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid }
|
||||
|
||||
if (chkM1 || chk0 || chkP1) {
|
||||
printdbg(this, "Ceiling not tall enough at $x, $y, aborting")
|
||||
// printdbg(this, "Ceiling not tall enough at $x, $y, aborting")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -255,7 +253,7 @@ class Treegen(world: GameWorld, isFinal: Boolean, seed: Long, val terragenParams
|
||||
val bulb1 = 4 + fudgeN(x, y, 345098)
|
||||
val bulb2 = 3 + fudgeN(x, y, 6093481)
|
||||
val bulb3 = 2 + fudgeN(x, y, 5413879)
|
||||
printdbg(this, "Planting tree at $x, $y; params: $stem, $bulb1, $bulb2, $bulb3")
|
||||
// printdbg(this, "Planting tree at $x, $y; params: $stem, $bulb1, $bulb2, $bulb3")
|
||||
|
||||
// trunk
|
||||
for (i in 0 until stem) {
|
||||
@@ -294,7 +292,7 @@ class Treegen(world: GameWorld, isFinal: Boolean, seed: Long, val terragenParams
|
||||
val chkP2 = (2..heightSum).any { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid }
|
||||
|
||||
if (chkM1 || chk0 || chkP1 || chkP2) {
|
||||
printdbg(this, "Ceiling not tall enough at $x, $y, aborting")
|
||||
// printdbg(this, "Ceiling not tall enough at $x, $y, aborting")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -304,8 +302,7 @@ class Treegen(world: GameWorld, isFinal: Boolean, seed: Long, val terragenParams
|
||||
val bulb2 = 4 + fudgeN(x, y, 98134)
|
||||
val bulb3 = 3 + fudgeN(x, y, 123098)
|
||||
val bulb4 = 2 + fudgeN(x, y, 8712)
|
||||
|
||||
printdbg(this, "Planting tree at $x, $y; params: $stem, $bulb1, $bulb2, $bulb3")
|
||||
// printdbg(this, "Planting tree at $x, $y; params: $stem, $bulb1, $bulb2, $bulb3, $bulb4")
|
||||
|
||||
// soiling
|
||||
val tl1 = world.getTileFromTerrain(x - 1, y)
|
||||
|
||||
Reference in New Issue
Block a user