buildingmaker markers working again

This commit is contained in:
minjaesong
2023-10-15 01:42:03 +09:00
parent 8613d804e7
commit 35c46d9a91
3 changed files with 62 additions and 23 deletions

View File

@@ -333,10 +333,10 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
protected open fun forceRemoveActor(actor: Actor, caller: Throwable = StackTraceRecorder()) { protected open fun forceRemoveActor(actor: Actor, caller: Throwable = StackTraceRecorder()) {
arrayOf(actorContainerActive, actorContainerInactive).forEach { actorContainer -> arrayOf(actorContainerActive, actorContainerInactive).forEach { actorContainer ->
val indexToDelete = actorContainer.searchFor(actor.referenceID) { it.referenceID } val indexToDelete = actorContainer.searchForIndex(actor.referenceID) { it.referenceID }
if (indexToDelete != null) { if (indexToDelete != null) {
actor.dispose() actor.dispose()
actorContainer.remove(indexToDelete) actorContainer.removeAt(indexToDelete)
} }
} }
} }
@@ -348,7 +348,7 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
throw ReferencedActorAlreadyExistsException(actor, caller) throw ReferencedActorAlreadyExistsException(actor, caller)
} }
else { else {
actorAdditionQueue.add(actor to StackTraceRecorder()) actorContainerActive.add(actor)
} }
} }

View File

@@ -32,27 +32,26 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
private val menuYaml = Yaml(""" private val menuYaml = Yaml("""
- File - File
- New flat ter. - New Flat ter.
- New rand. ter. - New Rand. ter.
- Export… - Export…
- Export sel…
- Import… - Import…
- Save terrain - Save World
- Load terrain - Load World
-
- Exit to Title : net.torvald.terrarum.modulebasegame.YamlCommandExit - Exit to Title : net.torvald.terrarum.modulebasegame.YamlCommandExit
- Edit - Edit
- Undo - Undo
- Redo - Redo
- Time - Time
- Dawn : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeDawn
- Sunrise : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeSunrise
- Morning : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeMorning - Morning : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeMorning
- Noon : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeNoon - Noon : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeNoon
- Dusk : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeDusk - Dusk : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeDusk
- Sunset : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeSunset
- Night : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeNight - Night : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeNight
- Midnight : net.torvald.terrarum.modulebasegame.YamlCommandSetTimeMidnight
- Set… - Set…
- Weather
- Sunny
- Raining
""".trimIndent()) """.trimIndent())
private val timeNow = System.currentTimeMillis() / 1000 private val timeNow = System.currentTimeMillis() / 1000
@@ -216,9 +215,11 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
internal fun addBlockMarker(x: Int, y: Int) { internal fun addBlockMarker(x: Int, y: Int) {
try { try {
val a = generateNewBlockMarkerVisible(x, y) val a = generateNewBlockMarkerVisible(x, y)
queueActorAddition(a) if (!theGameHasActor(a.referenceID)) {
actorsRenderOverlay.add(a) queueActorAddition(a)
selection.add(Point2i(x, y)) actorsRenderOverlay.add(a)
selection.add(Point2i(x, y))
}
} }
catch (e: Error) { } catch (e: Error) { }
} }
@@ -226,11 +227,11 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
internal fun removeBlockMarker(x: Int, y: Int) { internal fun removeBlockMarker(x: Int, y: Int) {
try { try {
val a = getActorByID(blockPosToRefID(x, y)) val a = getActorByID(blockPosToRefID(x, y))
queueActorAddition(a) queueActorRemoval(a)
actorsRenderOverlay.remove(a) actorsRenderOverlay.remove(a)
selection.remove(Point2i(x, y)) selection.remove(Point2i(x, y))
} }
catch (e: IllegalArgumentException) { catch (e: Throwable) {
// no actor to erase, do nothing // no actor to erase, do nothing
} }
} }
@@ -363,6 +364,13 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
uiPenMenu.setAsOpen() uiPenMenu.setAsOpen()
} }
actorAdditionQueue.forEach { forceAddActor(it.first, it.second) }
actorAdditionQueue.clear()
actorRemovalQueue.forEach { forceRemoveActor(it.first, it.second) }
actorRemovalQueue.clear()
BlockPropUtil.dynamicLumFuncTickClock() BlockPropUtil.dynamicLumFuncTickClock()
} }
@@ -581,27 +589,59 @@ class YamlCommandExit : YamlInvokable {
} }
} }
class YamlCommandSetTimeDawn : YamlInvokable {
override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("6h00"))
WeatherMixer.forceSolarElev = -3.0
}
}
class YamlCommandSetTimeSunrise : YamlInvokable {
override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("6h00"))
WeatherMixer.forceSolarElev = 0.0
}
}
class YamlCommandSetTimeMorning : YamlInvokable { class YamlCommandSetTimeMorning : YamlInvokable {
override fun invoke(args: Array<Any>) { override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("7h00")) (args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("6h00"))
WeatherMixer.forceSolarElev = 5.0
} }
} }
class YamlCommandSetTimeNoon : YamlInvokable { class YamlCommandSetTimeNoon : YamlInvokable {
override fun invoke(args: Array<Any>) { override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("12h30")) (args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("12h00"))
WeatherMixer.forceSolarElev = 30.0
} }
} }
class YamlCommandSetTimeDusk : YamlInvokable { class YamlCommandSetTimeDusk : YamlInvokable {
override fun invoke(args: Array<Any>) { override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("18h40")) (args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("18h00"))
WeatherMixer.forceSolarElev = 3.0
}
}
class YamlCommandSetTimeSunset : YamlInvokable {
override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("18h00"))
WeatherMixer.forceSolarElev = 0.0
} }
} }
class YamlCommandSetTimeNight : YamlInvokable { class YamlCommandSetTimeNight : YamlInvokable {
override fun invoke(args: Array<Any>) { override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("0h30")) (args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("18h00"))
WeatherMixer.forceSolarElev = -8.0
}
}
class YamlCommandSetTimeMidnight : YamlInvokable {
override fun invoke(args: Array<Any>) {
(args[0] as BuildingMaker).gameWorld.worldTime.setTimeOfToday(WorldTime.parseTime("0h00"))
WeatherMixer.forceSolarElev = -30.0
} }
} }

View File

@@ -137,7 +137,7 @@ class UINSMenu(
// 2. push the new menu // 2. push the new menu
if (old != new) { if (old != new) {
printdbg(this, "tree.children[new].children = ${tree.children[new].children}") // printdbg(this, "tree.children[new].children = ${tree.children[new].children}")
// push those new menus // push those new menus
if (tree.children[new].children.isNotEmpty()) { if (tree.children[new].children.isNotEmpty()) {
@@ -205,7 +205,6 @@ class UINSMenu(
batch.color = borderCol batch.color = borderCol
blendNormalStraightAlpha(batch) blendNormalStraightAlpha(batch)
Toolkit.fillArea(batch, it.ui.posX + it.ui.width - 1, it.ui.posY - LINE_HEIGHT, 1, LINE_HEIGHT + it.ui.height) Toolkit.fillArea(batch, it.ui.posX + it.ui.width - 1, it.ui.posY - LINE_HEIGHT, 1, LINE_HEIGHT + it.ui.height)
Toolkit.fillArea(batch, it.ui.posX, it.ui.posY + it.ui.height - 1, it.ui.width - 1, 1)
} }
} }