the placeholder "nullworld" is now singleton

This commit is contained in:
minjaesong
2019-06-11 23:52:17 +09:00
parent c41e60d29f
commit 306f45e7ee
2 changed files with 11 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ import net.torvald.terrarum.controller.GdxControllerAdapter;
import net.torvald.terrarum.controller.TerrarumController;
import net.torvald.terrarum.controller.XinputControllerAdapter;
import net.torvald.terrarum.gamecontroller.KeyToggler;
import net.torvald.terrarum.gameworld.GameWorld;
import net.torvald.terrarum.imagefont.TinyAlphNum;
import net.torvald.terrarum.modulebasegame.Ingame;
import net.torvald.terrarum.utils.JsonFetcher;
@@ -546,6 +547,8 @@ public class AppLoader implements ApplicationListener {
ModMgr.INSTANCE.disposeMods();
GameWorld.Companion.makeNullWorld().dispose();
deleteTempfiles();
}

View File

@@ -475,7 +475,14 @@ open class GameWorld : Disposable {
//@Transient val SIZEOF: Byte = 2
@Transient const val LAYERS: Byte = 4 // terrain, wall (layerTerrainLowBits + layerWallLowBits), wire
fun makeNullWorld() = GameWorld(1, 1, 1, 0, 0, 0)
@Transient private var nullWorldInstance: GameWorld? = null
fun makeNullWorld(): GameWorld {
if (nullWorldInstance == null)
nullWorldInstance = GameWorld(1, 1, 1, 0, 0, 0)
return nullWorldInstance!!
}
}
}