mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
in preparation of new demoworld creation for future version
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
"id";"drop";"spawn";"name";"shdr";"shdg";"shdb";"shduv";"str";"dsty";"mate";"solid";"wall";"grav";"dlfn";"fv";"fr";"lumr";"lumg";"lumb";"lumuv";"colour";"vscs";"refl";"tags"
|
"id";"drop";"spawn";"name";"shdr";"shdg";"shdb";"shduv";"str";"dsty";"mate";"solid";"wall";"grav";"dlfn";"fv";"fr";"lumr";"lumg";"lumb";"lumuv";"colour";"vscs";"refl";"tags"
|
||||||
"0";"0";"0";"BLOCK_AIR";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"1";"N/A";"0";"0";"4";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"INCONSEQUENTIAL,AIR"
|
"0";"0";"0";"BLOCK_AIR";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"1";"N/A";"0";"0";"4";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"INCONSEQUENTIAL,AIR"
|
||||||
|
"1";"0";"0";"BLOCK_UPDATE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"1";"N/A";"0";"0";"4";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"INTERNAL"
|
||||||
"16";"17";"17";"BLOCK_STONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"ROCK,NATURAL"
|
"16";"17";"17";"BLOCK_STONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"ROCK,NATURAL"
|
||||||
"17";"17";"17";"BLOCK_STONE_QUARRIED";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"ROCK"
|
"17";"17";"17";"BLOCK_STONE_QUARRIED";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"ROCK"
|
||||||
"18";"18";"18";"BLOCK_STONE_TILE_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.18";"STONE"
|
"18";"18";"18";"BLOCK_STONE_TILE_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.18";"STONE"
|
||||||
|
|||||||
|
@@ -3,6 +3,7 @@ CheatWarnTest
|
|||||||
CodexEdictis
|
CodexEdictis
|
||||||
ExportCodices
|
ExportCodices
|
||||||
ExportMap
|
ExportMap
|
||||||
|
ExportWorld
|
||||||
ForceGC
|
ForceGC
|
||||||
GetAV
|
GetAV
|
||||||
GetFaction
|
GetFaction
|
||||||
|
|||||||
|
@@ -6,6 +6,7 @@ package net.torvald.terrarum.blockproperties
|
|||||||
object Block {
|
object Block {
|
||||||
|
|
||||||
const val AIR = "basegame:0" // hard coded; this is the standard
|
const val AIR = "basegame:0" // hard coded; this is the standard
|
||||||
|
const val UPDATE = "basegame:1" // hard coded
|
||||||
|
|
||||||
const val STONE = "basegame:16"
|
const val STONE = "basegame:16"
|
||||||
const val STONE_QUARRIED = "basegame:17"
|
const val STONE_QUARRIED = "basegame:17"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class BlockProp {
|
|||||||
var shadeColB = 0f
|
var shadeColB = 0f
|
||||||
var shadeColA = 0f
|
var shadeColA = 0f
|
||||||
|
|
||||||
lateinit var opacity: Cvec
|
var opacity = Cvec()
|
||||||
|
|
||||||
fun getOpacity(channel: Int) = when (channel) {
|
fun getOpacity(channel: Int) = when (channel) {
|
||||||
0 -> shadeColR
|
0 -> shadeColR
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ class PhysicalStatus() {
|
|||||||
/**
|
/**
|
||||||
* Special version of GameWorld where everything, including layer data, are saved in a single JSON file (i.e. not chunked)
|
* Special version of GameWorld where everything, including layer data, are saved in a single JSON file (i.e. not chunked)
|
||||||
*/
|
*/
|
||||||
class SimpleGameWorld : GameWorld() {
|
class SimpleGameWorld(width: Int, height: Int) : GameWorld(width, height) {
|
||||||
override lateinit var layerWall: BlockLayer
|
override lateinit var layerWall: BlockLayer
|
||||||
override lateinit var layerTerrain: BlockLayer
|
override lateinit var layerTerrain: BlockLayer
|
||||||
|
constructor() : this(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
open class GameWorld(
|
open class GameWorld(
|
||||||
@@ -48,10 +49,14 @@ open class GameWorld(
|
|||||||
) : Disposable {
|
) : Disposable {
|
||||||
|
|
||||||
constructor() : this(UUID.randomUUID())
|
constructor() : this(UUID.randomUUID())
|
||||||
|
constructor(width: Int, height: Int) : this(UUID.randomUUID()) {
|
||||||
|
this.width = width
|
||||||
|
this.height = height
|
||||||
|
}
|
||||||
|
|
||||||
var worldCreator: UUID = UUID(0L,0L) // TODO record a value to this
|
var worldCreator: UUID = UUID(0L,0L) // TODO record a value to this
|
||||||
var width: Int = 999; private set
|
var width: Int = 0; private set
|
||||||
var height: Int = 999; private set
|
var height: Int = 0; private set
|
||||||
|
|
||||||
var playersLastStatus = PlayersLastStatus() // only gets used when the game saves and loads
|
var playersLastStatus = PlayersLastStatus() // only gets used when the game saves and loads
|
||||||
|
|
||||||
@@ -208,17 +213,24 @@ open class GameWorld(
|
|||||||
|
|
||||||
if (App.tileMaker != null) {
|
if (App.tileMaker != null) {
|
||||||
App.tileMaker.tags.forEach {
|
App.tileMaker.tags.forEach {
|
||||||
printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}")
|
if (!forcedTileNumberToNames.contains(it.key)) {
|
||||||
|
printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}")
|
||||||
|
|
||||||
tileNumberToNameMap[it.value.tileNumber.toLong()] = it.key
|
tileNumberToNameMap[it.value.tileNumber.toLong()] = it.key
|
||||||
tileNameToNumberMap[it.key] = it.value.tileNumber
|
tileNameToNumberMap[it.key] = it.value.tileNumber
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
|
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
|
||||||
tileNumberToNameMap[0] = Block.AIR
|
tileNumberToNameMap[0] = Block.AIR
|
||||||
|
tileNumberToNameMap[2] = Block.UPDATE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val forcedTileNumberToNames = hashSetOf(
|
||||||
|
Block.AIR, Block.UPDATE
|
||||||
|
)
|
||||||
|
|
||||||
fun coordInWorld(x: Int, y: Int) = y in 0 until height // ROUNDWORLD implementation
|
fun coordInWorld(x: Int, y: Int) = y in 0 until height // ROUNDWORLD implementation
|
||||||
fun coordInWorldStrict(x: Int, y: Int) = x in 0 until width && y in 0 until height // ROUNDWORLD implementation
|
fun coordInWorldStrict(x: Int, y: Int) = x in 0 until width && y in 0 until height // ROUNDWORLD implementation
|
||||||
|
|
||||||
@@ -242,6 +254,7 @@ open class GameWorld(
|
|||||||
|
|
||||||
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
|
// AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero
|
||||||
tileNumberToNameMap[0] = Block.AIR
|
tileNumberToNameMap[0] = Block.AIR
|
||||||
|
tileNumberToNameMap[2] = Block.UPDATE
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -265,7 +278,7 @@ open class GameWorld(
|
|||||||
*/
|
*/
|
||||||
fun getTileFromWall(rawX: Int, rawY: Int): ItemID {
|
fun getTileFromWall(rawX: Int, rawY: Int): ItemID {
|
||||||
val (x, y) = coerceXY(rawX, rawY)
|
val (x, y) = coerceXY(rawX, rawY)
|
||||||
return tileNumberToNameMap[layerWall.unsafeGetTile(x, y).toLong()] ?: throw NoSuchElementException("No tile name mapping for wall ${layerWall.unsafeGetTile(x, y)} in ($x, $y) from $layerWall")
|
return tileNumberToNameMap[layerWall.unsafeGetTile(x, y).toLong()] ?: Block.UPDATE//throw NoSuchElementException("No tile name mapping for wall ${layerWall.unsafeGetTile(x, y)} in ($x, $y) from $layerWall")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,7 +286,7 @@ open class GameWorld(
|
|||||||
*/
|
*/
|
||||||
fun getTileFromTerrain(rawX: Int, rawY: Int): ItemID {
|
fun getTileFromTerrain(rawX: Int, rawY: Int): ItemID {
|
||||||
val (x, y) = coerceXY(rawX, rawY)
|
val (x, y) = coerceXY(rawX, rawY)
|
||||||
return tileNumberToNameMap[layerTerrain.unsafeGetTile(x, y).toLong()] ?: throw NoSuchElementException("No tile name mapping for terrain ${layerTerrain.unsafeGetTile(x, y)} in ($x, $y) from $layerTerrain")
|
return tileNumberToNameMap[layerTerrain.unsafeGetTile(x, y).toLong()] ?: Block.UPDATE//throw NoSuchElementException("No tile name mapping for terrain ${layerTerrain.unsafeGetTile(x, y)} in ($x, $y) from $layerTerrain")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
|
import net.torvald.terrarum.console.Echo
|
||||||
|
import net.torvald.terrarum.gameworld.SimpleGameWorld
|
||||||
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
|
import net.torvald.terrarum.serialise.WriteSimpleWorld
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to create the titlescreen world
|
||||||
|
*
|
||||||
|
* Created by minjaesong on 2023-10-04.
|
||||||
|
*/
|
||||||
|
object ExportWorld : ConsoleCommand {
|
||||||
|
override fun execute(args: Array<String>) {
|
||||||
|
if (args.size == 2) {
|
||||||
|
try {
|
||||||
|
val ingame = Terrarum.ingame!! as TerrarumIngame
|
||||||
|
val file = File(App.defaultDir + "/Exports/${args[1]}.json")
|
||||||
|
val simpleworld = SimpleGameWorld(ingame.world.width, ingame.world.height).also {
|
||||||
|
it.layerTerrain = ingame.world.layerTerrain
|
||||||
|
it.layerWall = ingame.world.layerWall
|
||||||
|
it.tileNumberToNameMap.putAll(ingame.world.tileNumberToNameMap)
|
||||||
|
}
|
||||||
|
file.writeText(WriteSimpleWorld(ingame, simpleworld, listOf()))
|
||||||
|
Echo("Exportworld: exported the world as ${args[1]}.json")
|
||||||
|
}
|
||||||
|
catch (e: IOException) {
|
||||||
|
Echo("Exportworld: IOException raised.")
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printUsage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun printUsage() {
|
||||||
|
Echo("Usage: exportworld filename-without-extension")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import java.io.File
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Used to debug the titlescreen world
|
||||||
|
*
|
||||||
* Created by minjaesong on 2021-08-25.
|
* Created by minjaesong on 2021-08-25.
|
||||||
*/
|
*/
|
||||||
object ImportWorld : ConsoleCommand {
|
object ImportWorld : ConsoleCommand {
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ object WriteSimpleWorld {
|
|||||||
|
|
||||||
operator fun invoke(ingame: IngameInstance, world: SimpleGameWorld, actorsList: List<Actor>): String {
|
operator fun invoke(ingame: IngameInstance, world: SimpleGameWorld, actorsList: List<Actor>): String {
|
||||||
val time_t = App.getTIME_T()
|
val time_t = App.getTIME_T()
|
||||||
val s = Common.jsoner.toJson(preWrite(ingame, time_t, world, actorsList))
|
preWrite(ingame, time_t, world, actorsList)
|
||||||
|
val s = Common.jsoner.toJson(world)
|
||||||
return """{"genver":${Common.GENVER},${s.substring(1)}"""
|
return """{"genver":${Common.GENVER},${s.substring(1)}"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,8 +551,8 @@ object LightmapRenderer {
|
|||||||
_thisTerrain = world.getTileFromTerrainRaw(worldX, worldY)
|
_thisTerrain = world.getTileFromTerrainRaw(worldX, worldY)
|
||||||
_thisTerrainProp = BlockCodex[world.tileNumberToNameMap[_thisTerrain.toLong()]]
|
_thisTerrainProp = BlockCodex[world.tileNumberToNameMap[_thisTerrain.toLong()]]
|
||||||
|
|
||||||
_reflectanceAccumulator.set(App.tileMaker.terrainTileColourMap[_thisTerrainProp.id]!!)
|
_reflectanceAccumulator.set(App.tileMaker.terrainTileColourMap[_thisTerrainProp.id] ?: Cvec())
|
||||||
_reflectanceAccumulator.a = 0f // temporarily disabled
|
_reflectanceAccumulator.a = 0f // TODO temporarily disabled
|
||||||
_reflectanceAccumulator.mul(_thisTerrainProp.reflectance).mul(giScale)
|
_reflectanceAccumulator.mul(_thisTerrainProp.reflectance).mul(giScale)
|
||||||
|
|
||||||
_mapLightLevelThis.max(lx, ly, _reflectanceAccumulator)
|
_mapLightLevelThis.max(lx, ly, _reflectanceAccumulator)
|
||||||
|
|||||||
Reference in New Issue
Block a user