mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
fixtures can be despawned by "mining" them
This commit is contained in:
@@ -52,7 +52,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
this.inventory = inventory
|
||||
|
||||
if (mainUI != null)
|
||||
App.disposableSingletonsPool.add(mainUI)
|
||||
App.disposables.add(mainUI)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
}
|
||||
|
||||
override fun updateForTerrainChange(cue: IngameInstance.BlockChangeQueueItem) {
|
||||
// TODO check for despawn code here
|
||||
|
||||
}
|
||||
|
||||
private fun fillFillerBlock(bypassEvent: Boolean = false) {
|
||||
@@ -151,14 +151,11 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
* Removes this instance of the fixture from the world
|
||||
*/
|
||||
open fun despawn() {
|
||||
val posX = worldBlockPos!!.x
|
||||
val posY = worldBlockPos!!.y
|
||||
println("${this.javaClass.simpleName} dispose")
|
||||
|
||||
// remove filler block
|
||||
forEachBlockbox { x, y ->
|
||||
if (world!!.getTileFromTerrain(x, y) == blockBox.collisionType) {
|
||||
world!!.setTileTerrain(x, y, Block.AIR, false)
|
||||
}
|
||||
world!!.setTileTerrain(x, y, Block.AIR, false)
|
||||
}
|
||||
|
||||
worldBlockPos = null
|
||||
@@ -166,6 +163,12 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
|
||||
this.isVisible = false
|
||||
|
||||
if (this is Electric) {
|
||||
wireEmitterTypes.clear()
|
||||
wireEmission.clear()
|
||||
wireConsumption.clear()
|
||||
}
|
||||
|
||||
// TODO drop self as an item (instance of DroppedItem)
|
||||
}
|
||||
|
||||
@@ -173,11 +176,16 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
super.update(delta)
|
||||
// if not flagged to despawn and not actually despawned (which sets worldBlockPos as null), always fill up fillerBlock
|
||||
if (!flagDespawn && worldBlockPos != null) {
|
||||
fillFillerBlock(true)
|
||||
}
|
||||
else if (flagDespawn) {
|
||||
despawn()
|
||||
// for removal-by-player because player is removing the filler block by pick
|
||||
forEachBlockbox { x, y ->
|
||||
if (world!!.getTileFromTerrain(x, y) != blockBox.collisionType) {
|
||||
flagDespawn = true
|
||||
}
|
||||
}
|
||||
|
||||
if (flagDespawn) despawn()
|
||||
}
|
||||
// actual actor removal is performed by the TerrarumIngame
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.WireCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -41,15 +40,5 @@ class FixtureLogicSignalEmitter : FixtureBase, Electric {
|
||||
const val MASS = 1.0
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
// set emit
|
||||
/*worldBlockPos?.let { (x, y) ->
|
||||
WireCodex.getAll().filter { it.accepts == "digital_bit" }.forEach { prop ->
|
||||
// only set a state of wire that actually exists on the world
|
||||
if (world?.getWireGraphOf(x, y, prop.id) != null)
|
||||
world?.setWireEmitStateOf(x, y, prop.id, wireEmission[0]!!)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user