Skip to content

Commit

Permalink
fixed a bug where signal emitter wouldn't work after save reload
Browse files Browse the repository at this point in the history
  • Loading branch information
curioustorvald committed Jan 24, 2022
1 parent ee8da4d commit a213cba
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 83 deletions.
74 changes: 0 additions & 74 deletions .idea/artifacts/Runtime.xml

This file was deleted.

6 changes: 3 additions & 3 deletions src/net/torvald/terrarum/gameworld/WorldSimulator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ object WorldSimulator {
* @return List of FixtureBases, safe to cast into Electric
*/
private fun wiresimGetSourceBlocks(): List<FixtureBase> =
INGAME.actorContainerActive.filter {
it is FixtureBase && it is Electric && it.inUpdateRange(world) && it.wireEmitterTypes.isNotEmpty()
} as List<FixtureBase>
INGAME.actorContainerActive.filterIsInstance<FixtureBase>().filter {
it is Electric && it.inUpdateRange(world) && it.wireEmitterTypes.isNotEmpty()
}

private val wireSimMarked = HashSet<Long>()
private val wireSimPoints = Queue<WireGraphCursor>()
Expand Down
5 changes: 2 additions & 3 deletions src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -855,9 +855,8 @@ object IngameRenderer : Disposable {
shaderBlendGlow.dispose()
shaderAlphaDither.dispose()

try {
fboRGBexport.dispose()
}
try { fboRGBexport.dispose() }
catch (e: GdxRuntimeException) {}
catch (e: UninitializedPropertyAccessException) {}
catch (e: Throwable) { e.printStackTrace(System.out) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
}

private var updateAkku = 0f
private var autosaveTimer = 0f
internal var autosaveTimer = 0f

override fun render(`_`: Float) {
// Q&D solution for LoadScreen and Ingame, where while LoadScreen is working, Ingame now no longer has GL Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ class FixtureLogicSignalEmitter : FixtureBase, Electric {
}
CommonResourcePool.loadAll()


density = 1400.0
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, -1)

makeNewSprite(TextureRegionPack(CommonResourcePool.getAsTextureRegion("basegame-sprites-fixtures-signal_source.tga").texture, TILE_SIZE, TILE_SIZE))
sprite!!.setRowsAndFrames(1, 1)

actorValue[AVKey.BASEMASS] = MASS
}

override fun update(delta: Float) {
// the values does not get preserved on save reload??
wireEmitterTypes["digital_bit"] = 0
wireEmission[0] = Vector2(1.0, 0.0)

super.update(delta)
}

override fun dispose() { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.torvald.terrarum.modulebasegame.ui

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
Expand Down Expand Up @@ -122,6 +121,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
screen = 0
full.handler.unlockToggle()
full.unlockTransition()
(INGAME as TerrarumIngame).autosaveTimer = 0f
}
}

Expand Down

0 comments on commit a213cba

Please sign in to comment.