nonprivate lateinits are bitch

This commit is contained in:
Minjae Song
2018-12-11 16:39:27 +09:00
parent e0f72aafad
commit c7d7ae03c0
6 changed files with 23 additions and 20 deletions

View File

@@ -32,6 +32,7 @@ import org.lwjgl.input.Controllers
import java.io.File
import java.io.IOException
import net.torvald.getcpuname.GetCpuName
import net.torvald.terrarum.modulebasegame.Ingame
@@ -420,16 +421,17 @@ object Terrarum : Screen {
// jump right into the ingame
/*ingame = Ingame(batch)
ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
LoadScreen.screenToLoad = ingame!!
super.setScreen(LoadScreen)*/
val ingame = Ingame(batch)
ingame.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
ingame.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
LoadScreen.screenToLoad = ingame
this.ingame = ingame
setScreen(LoadScreen)
// title screen
AppLoader.getINSTANCE().setScreen(TitleScreen(batch))
//AppLoader.getINSTANCE().setScreen(TitleScreen(batch))
}
fun setScreen(screen: Screen) {

View File

@@ -35,7 +35,7 @@ open class GameWorld {
val layerTerrainLowBits: PairedMapLayer
//val layerThermal: MapLayerHalfFloat // in Kelvins
//val layerAirPressure: MapLayerHalfFloat // (milibar - 1000)
//val layerFluidPressure: MapLayerHalfFloat // (milibar - 1000)
/** Tilewise spawn point */
var spawnX: Int
@@ -59,6 +59,8 @@ open class GameWorld {
constructor(worldIndex: Int, width: Int, height: Int, creationTIME_T: Long, lastPlayTIME_T: Long, totalPlayTime: Int) {
if (width <= 0 || height <= 0) throw IllegalArgumentException("Non-positive width/height: ($width, $height)")
this.worldIndex = worldIndex
this.width = width
this.height = height
@@ -76,10 +78,10 @@ open class GameWorld {
terrainDamages = HashMap<BlockAddress, BlockDamage>()
// temperature layer: 2x2 is one cell
//layerThermal = MapLayerHalfFloat(width / 2, height / 2, averageTemperature)
//layerThermal = MapLayerHalfFloat(width, height, averageTemperature)
// air pressure layer: 4 * 8 is one cell
//layerAirPressure = MapLayerHalfFloat(width / 4, height / 8, 13f) // 1013 mBar
// fluid pressure layer: 4 * 8 is one cell
//layerFluidPressure = MapLayerHalfFloat(width, height, 13f) // 1013 mBar
creationTime = creationTIME_T
@@ -337,13 +339,12 @@ open class GameWorld {
fun getAirPressure(worldTileX: Int, worldTileY: Int): Float? {
return null
//return layerAirPressure.getValue((worldTileX fmod width) / 4, worldTileY / 8)
//return layerFluidPressure.getValue((worldTileX fmod width) / 4, worldTileY / 8)
}
companion object {
@Transient val WALL = 0
@Transient val TERRAIN = 1
@Transient val WIRE = 2
@@ -351,6 +352,8 @@ open class GameWorld {
@Transient val TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE
@Transient val SIZEOF: Byte = MapLayer.SIZEOF
@Transient val LAYERS: Byte = 4 // terrain, wall (layerTerrainLowBits + layerWallLowBits), wire
fun makeNullWorld() = GameWorld(-1, 1, 1, 0, 0, 0)
}
}

View File

@@ -11,13 +11,13 @@ import net.torvald.dataclass.Float16Bits
open class MapLayerHalfFloat(val width: Int, val height: Int) : Iterable<Float16Bits> {
constructor(width: Int, height: Int, init: Float) : this(width, height) {
data = Array(height) { Array(width, { Float16.fromFloat(init) }) }
data = Array(height) { Array(width) { Float16.fromFloat(init) } }
}
internal @Volatile var data: Array<Array<Float16Bits>> // in parallel programming: do not trust your register; always read freshly from RAM!
init {
data = Array(height) { Array(width, { 0.toShort() }) }
data = Array(height) { Array(width) { 0.toShort() } }
}
/**

View File

@@ -47,7 +47,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
private val ACTOR_UPDATE_RANGE = 4096
lateinit var historicalFigureIDBucket: ArrayList<Int>
var historicalFigureIDBucket: ArrayList<Int> = ArrayList<Int>()
/**

View File

@@ -2,7 +2,6 @@ package net.torvald.terrarum.worlddrawer
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.ShaderProgram
import com.badlogic.gdx.math.Matrix4
import net.torvald.terrarum.gameworld.GameWorld
@@ -31,8 +30,8 @@ import java.util.zip.GZIPInputStream
* Created by minjaesong on 2016-01-19.
*/
internal object BlocksDrawer {
lateinit var world: GameWorld
var world: GameWorld = GameWorld.makeNullWorld()
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()

View File

@@ -10,7 +10,6 @@ import net.torvald.terrarum.blockproperties.BlockCodex
import com.jme3.math.FastMath
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameactors.*
@@ -40,7 +39,7 @@ object LightmapRenderer {
// FIXME lightmap shifts to left, ONLY AT x=33.5-34.5
private lateinit var world: GameWorld
private var world: GameWorld = GameWorld.makeNullWorld()
/** do not call this yourself! Let your game renderer handle this! */
fun setWorld(world: GameWorld) {
@@ -486,7 +485,7 @@ object LightmapRenderer {
const val DRAW_FOR_RGB = 0xFFF0
const val DRAW_FOR_ALPHA = 0x000F
lateinit var lightBuffer: Pixmap
var lightBuffer: Pixmap = Pixmap(1, 1, Pixmap.Format.RGBA8888)
private val colourNull = Color(0)