mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 12:34:05 +09:00
renaming some files
This commit is contained in:
@@ -2,6 +2,9 @@ package net.torvald.terrarum.gameworld
|
||||
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.gameworld.GameWorld.Companion.TERRAIN
|
||||
import net.torvald.terrarum.gameworld.GameWorld.Companion.WALL
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.archivers.ClusteredFormatDOM
|
||||
import net.torvald.terrarum.serialise.toUint
|
||||
import net.torvald.unsafe.UnsafeHelper
|
||||
import net.torvald.unsafe.UnsafePtr
|
||||
@@ -18,7 +21,20 @@ import net.torvald.unsafe.UnsafePtr
|
||||
*
|
||||
* Note to self: refrain from using shorts--just do away with two bytes: different system have different endianness
|
||||
*/
|
||||
open class BlockLayerI16(override val width: Int, override val height: Int) : BlockLayer {
|
||||
class BlockLayerI16(
|
||||
override val width: Int,
|
||||
override val height: Int,
|
||||
disk: ClusteredFormatDOM,
|
||||
layerNum: Int,
|
||||
world: GameWorld
|
||||
): BlockLayer() {
|
||||
|
||||
override val chunkPool = ChunkPool(disk, layerNum, BYTES_PER_BLOCK, world, when (layerNum) {
|
||||
TERRAIN -> ChunkPool.getRenameFunTerrain(world)
|
||||
WALL -> ChunkPool.getRenameFunTerrain(world)
|
||||
else -> throw IllegalArgumentException("Unknown layer number for I16: $layerNum")
|
||||
})
|
||||
|
||||
override val bytesPerBlock = BYTES_PER_BLOCK
|
||||
|
||||
// for some reason, all the efforts of saving the memory space were futile.
|
||||
@@ -33,14 +49,6 @@ open class BlockLayerI16(override val width: Int, override val height: Int) : Bl
|
||||
ptr.fillWith(-1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data Byte array representation of the layer
|
||||
*/
|
||||
constructor(width: Int, height: Int, data: ByteArray) : this(width, height) {
|
||||
TODO()
|
||||
data.forEachIndexed { index, byte -> UnsafeHelper.unsafe.putByte(ptr.ptr + index, byte) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator over stored bytes.
|
||||
*
|
||||
@@ -42,8 +42,8 @@ class PhysicalStatus() {
|
||||
* Special version of GameWorld where everything, including layer data, are saved in a single JSON file (i.e. not chunked)
|
||||
*/
|
||||
class SimpleGameWorld(width: Int, height: Int) : GameWorld(width, height) {
|
||||
override lateinit var layerWall: BlockLayerI16
|
||||
override lateinit var layerTerrain: BlockLayerI16
|
||||
override lateinit var layerWall: BlockLayerGenericI16
|
||||
override lateinit var layerTerrain: BlockLayerGenericI16
|
||||
constructor() : this(0, 0)
|
||||
override fun dispose() {
|
||||
layerWall.dispose()
|
||||
@@ -89,10 +89,10 @@ open class GameWorld(
|
||||
}
|
||||
|
||||
//layers
|
||||
@Transient open lateinit var layerWall: BlockLayerI16
|
||||
@Transient open lateinit var layerTerrain: BlockLayerI16
|
||||
@Transient open lateinit var layerWall: BlockLayerGenericI16
|
||||
@Transient open lateinit var layerTerrain: BlockLayerGenericI16
|
||||
@Transient open lateinit var layerOres: BlockLayerOresI16I8 // damage to the block follows `terrainDamages`
|
||||
@Transient open lateinit var layerFluids: BlockLayerI16F16
|
||||
@Transient open lateinit var layerFluids: BlockLayerFluidI16F16
|
||||
val wallDamages = HashArray<Float>()
|
||||
val terrainDamages = HashArray<Float>()
|
||||
|
||||
@@ -230,10 +230,10 @@ open class GameWorld(
|
||||
this.spawnX = width / 2
|
||||
this.spawnY = 150
|
||||
|
||||
layerTerrain = BlockLayerI16(width, height)
|
||||
layerWall = BlockLayerI16(width, height)
|
||||
layerTerrain = BlockLayerGenericI16(width, height)
|
||||
layerWall = BlockLayerGenericI16(width, height)
|
||||
layerOres = BlockLayerOresI16I8(width, height)
|
||||
layerFluids = BlockLayerI16F16(width, height)
|
||||
layerFluids = BlockLayerFluidI16F16(width, height)
|
||||
chunkFlags = Array(height / CHUNK_H) { ByteArray(width / CHUNK_W) }
|
||||
|
||||
// temperature layer: 2x2 is one cell
|
||||
@@ -544,7 +544,7 @@ open class GameWorld(
|
||||
|
||||
fun setTileOnLayerUnsafe(layer: Int, x: Int, y: Int, tile: Int) {
|
||||
(getLayer(layer) ?: throw IllegalArgumentException("Unknown layer index: $layer")).let {
|
||||
if (it !is BlockLayerI16) throw IllegalArgumentException("Block layers other than BlockLayer16 is not supported yet)")
|
||||
if (it !is BlockLayerGenericI16) throw IllegalArgumentException("Block layers other than BlockLayer16 is not supported yet)")
|
||||
it.unsafeSetTile(x, y, tile)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user