mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
new layer 'ores'
This commit is contained in:
@@ -85,6 +85,12 @@ open class GameWorld(
|
|||||||
//layers
|
//layers
|
||||||
@Transient lateinit open var layerWall: BlockLayer
|
@Transient lateinit open var layerWall: BlockLayer
|
||||||
@Transient lateinit open var layerTerrain: BlockLayer
|
@Transient lateinit open var layerTerrain: BlockLayer
|
||||||
|
val layerOres = HashedOres() // damage to the block follows `terrainDamages`
|
||||||
|
val wallDamages = HashArray<Float>()
|
||||||
|
val terrainDamages = HashArray<Float>()
|
||||||
|
val layerFluids = HashedFluidTypeAndFills();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//val layerThermal: MapLayerHalfFloat // in Kelvins
|
//val layerThermal: MapLayerHalfFloat // in Kelvins
|
||||||
//val layerFluidPressure: MapLayerHalfFloat // (milibar - 1000)
|
//val layerFluidPressure: MapLayerHalfFloat // (milibar - 1000)
|
||||||
@@ -102,10 +108,7 @@ open class GameWorld(
|
|||||||
}
|
}
|
||||||
var portalPoint: Point2i? = null
|
var portalPoint: Point2i? = null
|
||||||
|
|
||||||
val wallDamages = HashArray<Float>()
|
|
||||||
val terrainDamages = HashArray<Float>()
|
|
||||||
val fluidTypes = HashedFluidType()
|
|
||||||
val fluidFills = HashArray<Float>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Single block can have multiple conduits, different types of conduits are stored separately.
|
* Single block can have multiple conduits, different types of conduits are stored separately.
|
||||||
@@ -358,8 +361,7 @@ open class GameWorld(
|
|||||||
terrainDamages.remove(blockAddr)
|
terrainDamages.remove(blockAddr)
|
||||||
|
|
||||||
if (BlockCodex[itemID].isSolid) {
|
if (BlockCodex[itemID].isSolid) {
|
||||||
fluidFills.remove(blockAddr)
|
layerFluids.remove(blockAddr)
|
||||||
fluidTypes.remove(blockAddr)
|
|
||||||
}
|
}
|
||||||
// fluid tiles-item should be modified so that they will also place fluid onto their respective map
|
// fluid tiles-item should be modified so that they will also place fluid onto their respective map
|
||||||
|
|
||||||
@@ -669,13 +671,10 @@ open class GameWorld(
|
|||||||
|
|
||||||
if (fill > WorldSimulator.FLUID_MIN_MASS) {
|
if (fill > WorldSimulator.FLUID_MIN_MASS) {
|
||||||
//setTileTerrain(x, y, fluidTypeToBlock(fluidType))
|
//setTileTerrain(x, y, fluidTypeToBlock(fluidType))
|
||||||
fluidFills[addr] = fill
|
layerFluids[addr] = Fill(fluidType, fill)
|
||||||
fluidTypes[addr] = fluidType
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fluidFills.remove(addr)
|
layerFluids.remove(addr)
|
||||||
fluidTypes.remove(addr)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -688,8 +687,8 @@ open class GameWorld(
|
|||||||
|
|
||||||
fun getFluid(x: Int, y: Int): FluidInfo {
|
fun getFluid(x: Int, y: Int): FluidInfo {
|
||||||
val addr = LandUtil.getBlockAddr(this, x, y)
|
val addr = LandUtil.getBlockAddr(this, x, y)
|
||||||
val fill = fluidFills[addr]
|
val type = layerFluids[addr]?.item
|
||||||
val type = fluidTypes[addr]
|
val fill = layerFluids[addr]?.amount
|
||||||
return if (type == null) FluidInfo(Fluid.NULL, 0f) else FluidInfo(type, fill!!)
|
return if (type == null) FluidInfo(Fluid.NULL, 0f) else FluidInfo(type, fill!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.utils.Json
|
|||||||
import com.badlogic.gdx.utils.JsonValue
|
import com.badlogic.gdx.utils.JsonValue
|
||||||
import com.badlogic.gdx.utils.JsonWriter
|
import com.badlogic.gdx.utils.JsonWriter
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration
|
import net.torvald.terrarum.TerrarumAppConfiguration
|
||||||
import net.torvald.terrarum.console.EchoError
|
import net.torvald.terrarum.console.EchoError
|
||||||
import net.torvald.terrarum.gameworld.BlockLayer
|
import net.torvald.terrarum.gameworld.BlockLayer
|
||||||
@@ -265,6 +266,28 @@ object Common {
|
|||||||
return WeatherMixer.weatherDict[jsonData.asString()]!!
|
return WeatherMixer.weatherDict[jsonData.asString()]!!
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Fill
|
||||||
|
jsoner.setSerializer(Fill::class.java, object : Json.Serializer<Fill> {
|
||||||
|
override fun write(json: Json, obj: Fill, knownType: Class<*>?) {
|
||||||
|
json.writeValue("${obj.item};${obj.amount}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): Fill {
|
||||||
|
val csv = jsonData.asString().split(',')
|
||||||
|
return Fill(csv[0], csv[1].toFloat())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// OrePlacement
|
||||||
|
jsoner.setSerializer(OrePlacement::class.java, object : Json.Serializer<OrePlacement> {
|
||||||
|
override fun write(json: Json, obj: OrePlacement, knownType: Class<*>?) {
|
||||||
|
json.writeValue("${obj.item};${obj.tilePlacement}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): OrePlacement {
|
||||||
|
val csv = jsonData.asString().split(',')
|
||||||
|
return OrePlacement(csv[0], csv[1].toInt())
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.torvald.terrarum.utils
|
package net.torvald.terrarum.utils
|
||||||
|
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.Json
|
||||||
|
import com.badlogic.gdx.utils.JsonValue
|
||||||
import net.torvald.terrarum.gameactors.ActorValue
|
import net.torvald.terrarum.gameactors.ActorValue
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
import net.torvald.terrarum.gameworld.BlockAddress
|
import net.torvald.terrarum.gameworld.BlockAddress
|
||||||
@@ -17,7 +19,6 @@ class HashArray<R>: HashMap<Long, R>() // primitives are working just fine tho
|
|||||||
|
|
||||||
// Oh for the fucks sake fuck you everyone; json shit won't work with generics
|
// Oh for the fucks sake fuck you everyone; json shit won't work with generics
|
||||||
class WiringGraphMap: HashMap<ItemID, GameWorld.WiringSimCell>()
|
class WiringGraphMap: HashMap<ItemID, GameWorld.WiringSimCell>()
|
||||||
class HashedFluidType: HashMap<BlockAddress, ItemID>()
|
|
||||||
class HashedWirings: HashMap<BlockAddress, GameWorld.WiringNode>()
|
class HashedWirings: HashMap<BlockAddress, GameWorld.WiringNode>()
|
||||||
class HashedWiringGraph: HashMap<BlockAddress, WiringGraphMap>()
|
class HashedWiringGraph: HashMap<BlockAddress, WiringGraphMap>()
|
||||||
class MetaModuleCSVPair: HashMap<String, ZipCodedStr>()
|
class MetaModuleCSVPair: HashMap<String, ZipCodedStr>()
|
||||||
@@ -47,3 +48,15 @@ class PlayerLastStatus() {
|
|||||||
@JvmInline value class ZipCodedStr(val doc: String = "") {
|
@JvmInline value class ZipCodedStr(val doc: String = "") {
|
||||||
override fun toString() = doc
|
override fun toString() = doc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Unused and only exists for the savegame compatibility",
|
||||||
|
ReplaceWith("HashedFluidTypeAndFills")
|
||||||
|
) class HashedFluidType: HashMap<BlockAddress, ItemID>()
|
||||||
|
|
||||||
|
|
||||||
|
data class Fill(var item: ItemID, var amount: Float)
|
||||||
|
data class OrePlacement(var item: ItemID, var tilePlacement: Int)
|
||||||
|
|
||||||
|
class HashedFluidTypeAndFills: HashMap<BlockAddress, Fill>()
|
||||||
|
class HashedOres: HashMap<BlockAddress, OrePlacement>()
|
||||||
Reference in New Issue
Block a user