mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 22:44:04 +09:00
refactoring the call order of the renderers' init code invocation
This commit is contained in:
@@ -31,7 +31,7 @@ import kotlin.math.roundToInt
|
||||
*/
|
||||
internal object BlocksDrawer {
|
||||
|
||||
var world: GameWorld = GameWorld.makeNullWorld()
|
||||
internal var world: GameWorld = GameWorld.makeNullWorld()
|
||||
|
||||
private val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
private val TILE_SIZEF = CreateTileAtlas.TILE_SIZE.toFloat()
|
||||
@@ -189,7 +189,7 @@ internal object BlocksDrawer {
|
||||
internal fun renderData() {
|
||||
|
||||
try {
|
||||
drawTIME_T = (world as GameWorldExtension).time.TIME_T - (WorldTime.DAY_LENGTH * 15) // offset by -15 days
|
||||
drawTIME_T = (world as GameWorldExtension).worldTime.TIME_T - (WorldTime.DAY_LENGTH * 15) // offset by -15 days
|
||||
val seasonalMonth = (drawTIME_T.div(WorldTime.DAY_LENGTH) fmod WorldTime.YEAR_DAYS.toLong()).toInt() / WorldTime.MONTH_LENGTH + 1
|
||||
|
||||
tilesTerrain = weatherTerrains[seasonalMonth - 1]
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
*/
|
||||
object FeaturesDrawer {
|
||||
lateinit var world: GameWorld
|
||||
internal var world: GameWorld = GameWorld.makeNullWorld()
|
||||
|
||||
//const val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
|
||||
|
||||
@@ -39,11 +39,12 @@ object LightmapRenderer {
|
||||
private const val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
|
||||
private var world: GameWorld = GameWorld.makeNullWorld()
|
||||
|
||||
private lateinit var lightCalcShader: ShaderProgram
|
||||
//private val SHADER_LIGHTING = AppLoader.getConfigBoolean("gpulightcalc")
|
||||
|
||||
/** do not call this yourself! Let your game renderer handle this! */
|
||||
fun setWorld(world: GameWorld) {
|
||||
internal fun internalSetWorld(world: GameWorld) {
|
||||
try {
|
||||
if (this.world != world) {
|
||||
printdbg(this, "World change detected -- old world: ${this.world.hashCode()}, new world: ${world.hashCode()}")
|
||||
@@ -213,9 +214,9 @@ object LightmapRenderer {
|
||||
}
|
||||
catch (e: NullPointerException) {
|
||||
System.err.println("[LightmapRendererNew.fireRecalculateEvent] Attempted to refer destroyed unsafe array " +
|
||||
"(world size: ${world.layerTerrain.width} x ${world.layerTerrain.height}; " +
|
||||
"ptr: 0x${world.layerTerrain.getPtr().toString(16)})")
|
||||
return
|
||||
"(${world.layerTerrain.getPtr()})")
|
||||
e.printStackTrace()
|
||||
return // something's wrong but we'll ignore it like a trustful AK
|
||||
}
|
||||
|
||||
if (world.worldIndex == -1) return
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.worlddrawer
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
@@ -36,7 +36,7 @@ object WorldCamera {
|
||||
|
||||
private val nullVec = Vector2(0.0, 0.0)
|
||||
|
||||
fun update(world: GameWorld, player: ActorWBMovable?) {
|
||||
fun update(world: GameWorld, player: ActorWithBody?) {
|
||||
if (player == null) return
|
||||
|
||||
width = FastMath.ceil(Terrarum.WIDTH / (Terrarum.ingame?.screenZoom ?: 1f)) // div, not mul
|
||||
@@ -46,7 +46,7 @@ object WorldCamera {
|
||||
|
||||
// some hacky equation to position player at the dead centre
|
||||
// implementing the "lag behind" camera the right way
|
||||
val pVecSum = player.externalV + (player.controllerV ?: nullVec)
|
||||
val pVecSum = Vector2(0.0, 0.0)//player.externalV + (player.controllerV ?: nullVec)
|
||||
|
||||
x = ((player.hitbox.centeredX - pVecSum.x).toFloat() - (width / 2)).floorInt() // X only: ROUNDWORLD implementation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user