mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-13 07:06:06 +09:00
radar reading rcs from materials
This commit is contained in:
@@ -29,6 +29,8 @@ class Material {
|
||||
|
||||
var toolReach: Int = 6
|
||||
|
||||
var rcs: Int = 10
|
||||
|
||||
/**
|
||||
* Mainly intended to be used by third-party modules
|
||||
*/
|
||||
@@ -70,6 +72,7 @@ class MaterialCodex {
|
||||
prop.thermalConductivity = it.floatVal("tcond")
|
||||
prop.identifier = it.get("idst").toUpperCase()
|
||||
prop.toolReach = it.intVal("reach")
|
||||
prop.rcs = it.intVal("rcs")
|
||||
|
||||
materialProps[prop.identifier] = prop
|
||||
|
||||
@@ -86,6 +89,6 @@ class MaterialCodex {
|
||||
throw NullPointerException("Material with id $identifier does not exist.")
|
||||
}
|
||||
|
||||
fun getOrDefault(identifier: String) = materialProps[identifier.toUpperCase()] ?: nullMaterial
|
||||
fun getOrDefault(identifier: String?) = materialProps[identifier?.toUpperCase()] ?: nullMaterial
|
||||
|
||||
}
|
||||
@@ -2,13 +2,12 @@ package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.serialise.toUint
|
||||
import net.torvald.terrarum.utils.RasterWriter
|
||||
@@ -27,17 +26,12 @@ import kotlin.math.sign
|
||||
*/
|
||||
internal object ExportMap2 : ConsoleCommand {
|
||||
|
||||
//private var mapData: ByteArray? = null
|
||||
// private var mapDataPointer = 0
|
||||
private fun getOreRCS(ore: ItemID) =
|
||||
ItemCodex[OreCodex.oreProps.getOrElse(ore) { null }?.item]?.material?.rcs ?: MaterialCodex.nullMaterial.rcs
|
||||
private fun getBlockRCS(block: ItemID) =
|
||||
MaterialCodex.getOrDefault(BlockCodex.getOrNull(block)?.material).rcs
|
||||
|
||||
|
||||
private val oreColourMap = hashMapOf(
|
||||
Block.AIR to 0,
|
||||
"ores@basegame:1" to 160,
|
||||
"ores@basegame:2" to 128,
|
||||
"ores@basegame:3" to 96,
|
||||
)
|
||||
|
||||
private fun triangularRand(amp: Float) = (((Math.random() + Math.random()) - 1.0) * amp).toFloat()
|
||||
|
||||
private fun strToRandAmp(str: Float) = FastMath.log(str.absoluteValue.coerceAtLeast(4f), 2f).coerceAtLeast(0f)
|
||||
@@ -52,6 +46,9 @@ internal object ExportMap2 : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
println("Air RCS: ${getBlockRCS(Block.AIR)}")
|
||||
|
||||
|
||||
val world = (INGAME.world)
|
||||
if (args.size == 2) {
|
||||
|
||||
@@ -69,9 +66,7 @@ internal object ExportMap2 : ConsoleCommand {
|
||||
val terr = world.getTileFromTerrain(x, y)
|
||||
val ore = world.getTileFromOre(x, y).item
|
||||
|
||||
val colOre = (oreColourMap.get(ore) ?: throw NullPointerException("nullore $ore"))
|
||||
val colFore = (BlockCodex.getOrNull(terr)?.strength ?: throw NullPointerException("nullterr $terr"))
|
||||
val reflection0 = maxOf(colOre, colFore)
|
||||
val reflection0 = maxOf(getOreRCS(ore), getBlockRCS(terr))
|
||||
val reflection = reflection0 + triangularRand(strToRandAmp(reflection0.toFloat()))
|
||||
|
||||
val delta = (reflection - akku).coerceAtLeast(0f)
|
||||
|
||||
@@ -44,19 +44,16 @@ class OreStick(originalID: ItemID) : OreItemBase(originalID) {
|
||||
}
|
||||
class OreCopper(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_MALACHITE"
|
||||
override val materialId = "ROCK"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(2,6)
|
||||
}
|
||||
class OreIron(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_HAEMATITE"
|
||||
override val materialId = "ROCK"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(3,6)
|
||||
}
|
||||
class OreCoal(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_ORE_COAL"
|
||||
override val materialId = "ROCK"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(4,6)
|
||||
}
|
||||
Reference in New Issue
Block a user