mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
in preparation of new demoworld creation for future version
This commit is contained in:
@@ -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
|
||||
|
||||
/**
|
||||
* Used to debug the titlescreen world
|
||||
*
|
||||
* Created by minjaesong on 2021-08-25.
|
||||
*/
|
||||
object ImportWorld : ConsoleCommand {
|
||||
|
||||
Reference in New Issue
Block a user