mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 21:14:04 +09:00
more buildingmaker functions
This commit is contained in:
@@ -38,16 +38,13 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
private val menuYaml = Yaml("""
|
private val menuYaml = Yaml("""
|
||||||
- File
|
- File
|
||||||
- New Flat ter.
|
- New Flat ter. : net.torvald.terrarum.modulebasegame.YamlCommandNewFlatTerrain
|
||||||
- New Rand. ter.
|
- New Rand. ter.
|
||||||
- Export… : net.torvald.terrarum.modulebasegame.YamlCommandToolExportTest
|
- Export… : net.torvald.terrarum.modulebasegame.YamlCommandToolExportTest
|
||||||
- Import…
|
- Import…
|
||||||
- Save World…
|
|
||||||
- Load World…
|
|
||||||
- Exit to Title : net.torvald.terrarum.modulebasegame.YamlCommandExit
|
- Exit to Title : net.torvald.terrarum.modulebasegame.YamlCommandExit
|
||||||
- Edit
|
- Edit
|
||||||
- Undo
|
- Clear Selections : net.torvald.terrarum.modulebasegame.YamlCommandClearSelection
|
||||||
- Redo
|
|
||||||
- Time
|
- Time
|
||||||
- Dawn : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeDawn
|
- Dawn : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeDawn
|
||||||
- Sunrise : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeSunrise
|
- Sunrise : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeSunrise
|
||||||
@@ -60,40 +57,18 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
- Set…
|
- Set…
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
|
|
||||||
private val timeNow = System.currentTimeMillis() / 1000
|
lateinit var gameWorld: GameWorld
|
||||||
|
|
||||||
val gameWorld = GameWorld(90*12, 90*4, timeNow, timeNow)
|
|
||||||
|
|
||||||
override val musicGovernor = TerrarumMusicGovernor()
|
override val musicGovernor = TerrarumMusicGovernor()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// ghetto world for building
|
gameUpdateGovernor = ConsistentUpdateRate
|
||||||
|
YamlCommandNewFlatTerrain().invoke(arrayOf(this))
|
||||||
|
}
|
||||||
|
|
||||||
println("[BuildingMaker] Generating builder world...")
|
internal fun reset() {
|
||||||
|
gameUpdateGovernor.reset()
|
||||||
for (y in 0 until gameWorld.height) {
|
WeatherMixer.forceSolarElev = 5.0
|
||||||
gameWorld.setTileWall(0, y, Block.ILLUMINATOR_RED, true)
|
|
||||||
gameWorld.setTileWall(gameWorld.width - 1, y, Block.ILLUMINATOR_RED, true)
|
|
||||||
gameWorld.setTileTerrain(0, y, Block.ILLUMINATOR_RED_OFF, true)
|
|
||||||
gameWorld.setTileTerrain(gameWorld.width - 1, y, Block.ILLUMINATOR_RED_OFF, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (y in 150 until gameWorld.height) {
|
|
||||||
for (x in 1 until gameWorld.width - 1) {
|
|
||||||
// wall layer
|
|
||||||
gameWorld.setTileWall(x, y, Block.DIRT, true)
|
|
||||||
|
|
||||||
// terrain layer
|
|
||||||
gameWorld.setTileTerrain(x, y, if (y == 150) Block.GRASS else Block.DIRT, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set time to summer
|
|
||||||
gameWorld.worldTime.addTime(WorldTime.DAY_LENGTH * 32)
|
|
||||||
|
|
||||||
world = gameWorld
|
|
||||||
|
|
||||||
gameUpdateGovernor = ConsistentUpdateRate.also { it.reset() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,9 +244,6 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
private val essentialOverlays = ArrayList<ActorWithBody>()
|
private val essentialOverlays = ArrayList<ActorWithBody>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
gameWorld.worldTime.setTimeOfToday(WorldTime.HOUR_SEC * 10)
|
|
||||||
gameWorld.globalLight = Cvec(.8f, .8f, .8f, .8f)
|
|
||||||
|
|
||||||
essentialOverlays.add(blockPointingCursor)
|
essentialOverlays.add(blockPointingCursor)
|
||||||
|
|
||||||
uiContainer.add(uiToolbox)
|
uiContainer.add(uiToolbox)
|
||||||
@@ -775,3 +747,52 @@ class YamlCommandToolExportTest : YamlInvokable {
|
|||||||
|
|
||||||
private fun Point2i.toAddr() = toAddr(this.x, this.y)
|
private fun Point2i.toAddr() = toAddr(this.x, this.y)
|
||||||
private fun toAddr(x: Int, y: Int) = (x.toLong().shl(32) or y.toLong().and(0xFFFFFFFFL))
|
private fun toAddr(x: Int, y: Int) = (x.toLong().shl(32) or y.toLong().and(0xFFFFFFFFL))
|
||||||
|
|
||||||
|
class YamlCommandClearSelection : YamlInvokable {
|
||||||
|
override fun invoke(args: Array<Any>) {
|
||||||
|
val ui = (args[0] as BuildingMaker)
|
||||||
|
try {
|
||||||
|
(ui.selection.clone() as ArrayList<Point2i>).forEach { (x, y) ->
|
||||||
|
ui.removeBlockMarker(x, y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e: NullPointerException) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class YamlCommandNewFlatTerrain : YamlInvokable {
|
||||||
|
override fun invoke(args: Array<Any>) {
|
||||||
|
YamlCommandClearSelection().invoke(args)
|
||||||
|
val ui = (args[0] as BuildingMaker)
|
||||||
|
|
||||||
|
println("[BuildingMaker] Generating builder world...")
|
||||||
|
|
||||||
|
val timeNow = System.currentTimeMillis() / 1000
|
||||||
|
ui.gameWorld = GameWorld(90*12, 90*4, timeNow, timeNow)
|
||||||
|
|
||||||
|
for (y in 0 until ui.gameWorld.height) {
|
||||||
|
ui.gameWorld.setTileWall(0, y, Block.ILLUMINATOR_RED, true)
|
||||||
|
ui.gameWorld.setTileWall(ui.gameWorld.width - 1, y, Block.ILLUMINATOR_RED, true)
|
||||||
|
ui.gameWorld.setTileTerrain(0, y, Block.ILLUMINATOR_RED_OFF, true)
|
||||||
|
ui.gameWorld.setTileTerrain(ui.gameWorld.width - 1, y, Block.ILLUMINATOR_RED_OFF, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y in 150 until ui.gameWorld.height) {
|
||||||
|
for (x in 1 until ui.gameWorld.width - 1) {
|
||||||
|
// wall layer
|
||||||
|
ui.gameWorld.setTileWall(x, y, Block.DIRT, true)
|
||||||
|
|
||||||
|
// terrain layer
|
||||||
|
ui.gameWorld.setTileTerrain(x, y, if (y == 150) Block.GRASS else Block.DIRT, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.world = ui.gameWorld
|
||||||
|
|
||||||
|
|
||||||
|
// set time to summer morning
|
||||||
|
ui.gameWorld.worldTime.addTime(WorldTime.DAY_LENGTH * 32)
|
||||||
|
ui.gameWorld.worldTime.setTimeOfToday(18062)
|
||||||
|
|
||||||
|
ui.reset()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user