mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 06:24:06 +09:00
trying to load a world
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
package net.torvald.terrarum.serialise
|
||||
|
||||
import com.badlogic.gdx.utils.Json
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameEconomy
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import java.io.InputStream
|
||||
import java.io.Reader
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-08-25.
|
||||
*/
|
||||
open class ReadWorld(val ingame: TerrarumIngame) {
|
||||
|
||||
open fun invoke(worldIndex: Int, metadata: JsonValue, worlddata: JsonValue) {
|
||||
val json = Json()
|
||||
val world = GameWorldExtension(
|
||||
worldIndex,
|
||||
worlddata.getInt("width"),
|
||||
worlddata.getInt("height"),
|
||||
metadata.getLong("creation_t"),
|
||||
metadata.getLong("lastplay_t"),
|
||||
metadata.getInt("playtime_t")
|
||||
)
|
||||
open fun invoke(worldDataStream: InputStream) {
|
||||
postRead(WriteWorld.jsoner.fromJson(GameWorld::class.java, worldDataStream))
|
||||
}
|
||||
|
||||
//world.economy = json.fromJson(GameEconomy::class.java, worlddata.get("basegame.economy").)
|
||||
open fun invoke(worldDataStream: Reader) {
|
||||
postRead(WriteWorld.jsoner.fromJson(GameWorld::class.java, worldDataStream))
|
||||
}
|
||||
|
||||
private fun postRead(world: GameWorld) {
|
||||
world.postLoad()
|
||||
|
||||
ingame.world = world
|
||||
//ingame.actorNowPlaying?.setPosition(3.0, 3.0)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user