Significantly reduce memory usage by cells
This commit is contained in:
parent
8afef646ae
commit
8cd84a4501
@ -55,19 +55,11 @@ class ClientWorld(
|
|||||||
val renderRegionsY = size.y / renderRegionHeight
|
val renderRegionsY = size.y / renderRegionHeight
|
||||||
|
|
||||||
fun isValidRenderRegionX(value: Int): Boolean {
|
fun isValidRenderRegionX(value: Int): Boolean {
|
||||||
if (loopX) {
|
return loopX || value in 0 .. renderRegionsX
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return value in 0 .. renderRegionsX
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isValidRenderRegionY(value: Int): Boolean {
|
fun isValidRenderRegionY(value: Int): Boolean {
|
||||||
if (loopY) {
|
return loopY || value in 0 .. renderRegionsY
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return value in 0 .. renderRegionsY
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class RenderRegion(val x: Int, val y: Int) {
|
inner class RenderRegion(val x: Int, val y: Int) {
|
||||||
|
@ -2,6 +2,7 @@ package ru.dbotthepony.kstarbound.world.api
|
|||||||
|
|
||||||
import ru.dbotthepony.kstarbound.Registries
|
import ru.dbotthepony.kstarbound.Registries
|
||||||
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
||||||
|
import ru.dbotthepony.kstarbound.util.HashTableInterner
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
|
||||||
sealed class AbstractLiquidState {
|
sealed class AbstractLiquidState {
|
||||||
|
@ -29,7 +29,10 @@ data class MutableCell(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun immutable(): ImmutableCell {
|
override fun immutable(): ImmutableCell {
|
||||||
return ImmutableCell(foreground.immutable(), background.immutable(), liquid.immutable(), dungeonId, biome, envBiome, isIndestructible)
|
val result = ImmutableCell(foreground.immutable(), background.immutable(), liquid.immutable(), dungeonId, biome, envBiome, isIndestructible)
|
||||||
|
if (result == NULL) return NULL
|
||||||
|
if (result == EMPTY) return EMPTY
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mutable(): MutableCell {
|
override fun mutable(): MutableCell {
|
||||||
|
@ -23,6 +23,8 @@ data class MutableLiquidState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun immutable(): ImmutableLiquidState {
|
override fun immutable(): ImmutableLiquidState {
|
||||||
return ImmutableLiquidState(def, level, pressure, isInfinite)
|
val result = ImmutableLiquidState(def, level, pressure, isInfinite)
|
||||||
|
if (result == EMPTY) return EMPTY
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user