working create-new-world

This commit is contained in:
minjaesong
2021-10-28 17:32:09 +09:00
parent 1dc7d46c39
commit 3bd7e740d4
6 changed files with 191 additions and 24 deletions

View File

@@ -137,6 +137,12 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
(this.hitbox.endX + world.width >= WorldCamera.x && this.hitbox.startX + world.width <= WorldCamera.xEnd) ||
// x: neither
(this.hitbox.endX >= WorldCamera.x && this.hitbox.startX <= WorldCamera.xEnd))
val SIZE_SMALL = Point2i(6030, 1800)
val SIZE_NORMAL = Point2i(9000, 2250)
val SIZE_LARGE = Point2i(13500, 2970)
val SIZE_HUGE = Point2i(22500, 4500)
val WORLDSIZE = arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE)
}
@@ -1224,14 +1230,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
}
}
override fun pause() {
paused = true
}
override fun resume() {
paused = false
}
override fun hide() {
uiContainer.forEach { it?.handler?.dispose() }
}

View File

@@ -6,12 +6,20 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.random.HQRNG
import net.torvald.random.XXHash64
import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.WorldgenLoadScreen
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
import net.torvald.terrarum.savegame.ByteArray64Reader
import net.torvald.terrarum.savegame.VirtualDisk
import net.torvald.terrarum.serialise.Common
import net.torvald.terrarum.serialise.ReadActor
import net.torvald.terrarum.ui.*
import net.torvald.terrarum.utils.RandomWordsName
@@ -71,6 +79,28 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
goButton.touchDownListener = { _, _, _, _ ->
printdbg(this, "generate! Size=${sizeSelector.selection}, Name=${nameInput.getTextOrPlaceholder()}, Seed=${seedInput.getTextOrPlaceholder()}")
val ingame = TerrarumIngame(App.batch)
val player = ReadActor.invoke(UILoadGovernor.playerDisk!!, ByteArray64Reader(UILoadGovernor.playerDisk!!.getFile(-1L)!!.bytes, Common.CHARSET)) as IngamePlayer
val seed = try {
seedInput.getTextOrPlaceholder().toLong()
}
catch (e: NumberFormatException) {
XXHash64.hash(seedInput.getTextOrPlaceholder().toByteArray(Charsets.UTF_8), 10000)
}
val (wx, wy) = TerrarumIngame.WORLDSIZE[sizeSelector.selection]
val worldParam = TerrarumIngame.NewGameParams(
player, TerrarumIngame.NewWorldParameters(
wx, wy, seed, nameInput.getTextOrPlaceholder()
)
)
ingame.gameLoadInfoPayload = worldParam
ingame.gameLoadMode = TerrarumIngame.GameLoadMode.CREATE_NEW
Terrarum.setCurrentIngameInstance(ingame)
val loadScreen = WorldgenLoadScreen(ingame, wx, wy)
App.setLoadScreen(loadScreen)
}
backButton.touchDownListener = { _, _, _, _ ->
remoCon.openUI(UILoadDemoSavefiles(remoCon, 1))