save/load fluid layer

This commit is contained in:
minjaesong
2024-08-12 23:18:04 +09:00
parent fdbfad9633
commit 81c75a762b
4 changed files with 17 additions and 13 deletions

View File

@@ -324,6 +324,7 @@ open class GameWorld(
TERRAIN -> layerTerrain
WALL -> layerWall
ORES -> layerOres
FLUID -> layerFluids
else -> null//throw IllegalArgumentException("Unknown layer index: $index")
}
@@ -860,6 +861,7 @@ open class GameWorld(
@Transient const val TERRAIN = 0
@Transient const val WALL = 1
@Transient const val ORES = 2
@Transient const val FLUID = 3
@Transient val TILES_SUPPORTED = ReferencingRanges.TILES.last + 1
//@Transient val SIZEOF: Byte = 2

View File

@@ -858,16 +858,10 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
}
// flipping the sprite
if (walkHeading == LEFT) {
sprite?.flip(true, false)
spriteGlow?.flip(true, false)
spriteEmissive?.flip(true, false)
}
else {
sprite?.flip(false, false)
spriteGlow?.flip(false, false)
spriteEmissive?.flip(false, false)
}
val flip = (walkHeading == LEFT)
sprite?.flip(flip, false)
spriteGlow?.flip(flip, false)
spriteEmissive?.flip(flip, false)
}
override fun reload() {

View File

@@ -3,6 +3,10 @@ package net.torvald.terrarum.modulebasegame.serialise
import net.torvald.gdx.graphics.PixmapIO2
import net.torvald.terrarum.*
import net.torvald.terrarum.gameworld.GameWorld.Companion.CHUNK_LOADED
import net.torvald.terrarum.gameworld.GameWorld.Companion.FLUID
import net.torvald.terrarum.gameworld.GameWorld.Companion.ORES
import net.torvald.terrarum.gameworld.GameWorld.Companion.TERRAIN
import net.torvald.terrarum.gameworld.GameWorld.Companion.WALL
import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase
@@ -25,7 +29,7 @@ class WorldSavingThread(
val ingame: TerrarumIngame,
val isAuto: Boolean,
val callback: () -> Unit,
val errorHandler: (Throwable) -> Unit
errorHandler: (Throwable) -> Unit
) : SavingThread(errorHandler) {
/**
* Will happily overwrite existing entry
@@ -59,7 +63,7 @@ class WorldSavingThread(
val playersList: List<IngamePlayer> = allTheActors.filterIsInstance<IngamePlayer>()
val actorsList = allTheActors.filter { WriteWorld.actorAcceptable(it) }
val layers = intArrayOf(0,1,2).map { ingame.world.getLayer(it) }
val layers = intArrayOf(TERRAIN, WALL, ORES, FLUID).map { ingame.world.getLayer(it) }
val cw = ingame.world.width / LandUtil.CHUNK_W
val ch = ingame.world.height / LandUtil.CHUNK_H

View File

@@ -9,6 +9,10 @@ import net.torvald.terrarum.gameworld.BlockLayerI16F16
import net.torvald.terrarum.gameworld.BlockLayerOresI16I8
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.GameWorld.Companion.CHUNK_LOADED
import net.torvald.terrarum.gameworld.GameWorld.Companion.FLUID
import net.torvald.terrarum.gameworld.GameWorld.Companion.ORES
import net.torvald.terrarum.gameworld.GameWorld.Companion.TERRAIN
import net.torvald.terrarum.gameworld.GameWorld.Companion.WALL
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.FancyWorldReadLoadScreen
import net.torvald.terrarum.modulebasegame.IngameRenderer
@@ -193,7 +197,7 @@ object LoadSavegame {
val cw = LandUtil.CHUNK_W
val ch = LandUtil.CHUNK_H
val chunkCount = world.width * world.height / (cw * ch)
val worldLayer = intArrayOf(0,1,2).map { world.getLayer(it) }
val worldLayer = intArrayOf(TERRAIN, WALL, ORES, FLUID).map { world.getLayer(it) }
for (chunk in 0L until chunkCount) {
for (layer in worldLayer.indices) {
loadscreen.addMessage(Lang["MENU_IO_LOADING"])