mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
signal blocker spritesheet
This commit is contained in:
Binary file not shown.
BIN
assets/mods/basegame/sprites/fixtures/signal_blocker_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/fixtures/signal_blocker_emsv.tga
LFS
Normal file
Binary file not shown.
@@ -1,7 +1,6 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||||
import net.torvald.terrarum.App.printdbg
|
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||||
@@ -79,13 +78,18 @@ class FixtureSignalBlocker : Electric, Reorientable {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_blocker.tga")
|
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_blocker.tga")
|
||||||
|
val itemImage2 = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/signal_blocker_emsv.tga")
|
||||||
|
|
||||||
density = 1400.0
|
density = 1400.0
|
||||||
setHitboxDimension(2*TILE_SIZE, 2*TILE_SIZE, 0, 1)
|
setHitboxDimension(2*TILE_SIZE, 2*TILE_SIZE, 0, 1)
|
||||||
|
|
||||||
makeNewSprite(TextureRegionPack(itemImage.texture, 2*TILE_SIZE, 2*TILE_SIZE)).let {
|
makeNewSprite(TextureRegionPack(itemImage.texture, 2*TILE_SIZE, 2*TILE_SIZE)).let {
|
||||||
it.setRowsAndFrames(8,4)
|
it.setRowsAndFrames(16,4)
|
||||||
it.delays = floatArrayOf(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)
|
it.delays = FloatArray(8) { Float.POSITIVE_INFINITY }
|
||||||
|
}
|
||||||
|
makeNewSpriteEmissive(TextureRegionPack(itemImage2.texture, 2*TILE_SIZE, 2*TILE_SIZE)).let {
|
||||||
|
it.setRowsAndFrames(16,4)
|
||||||
|
it.delays = FloatArray(8) { Float.POSITIVE_INFINITY }
|
||||||
}
|
}
|
||||||
|
|
||||||
setEmitterAndSink()
|
setEmitterAndSink()
|
||||||
@@ -124,6 +128,17 @@ class FixtureSignalBlocker : Electric, Reorientable {
|
|||||||
else -> throw IllegalStateException("Orientation not in range ($orientation)")
|
else -> throw IllegalStateException("Orientation not in range ($orientation)")
|
||||||
}
|
}
|
||||||
setWireEmissionAt(x, y, Vector2(I nimply J, 0.0))
|
setWireEmissionAt(x, y, Vector2(I nimply J, 0.0))
|
||||||
|
|
||||||
|
// update sprite
|
||||||
|
val one = getWireStateAt(0, 0).x >= ELECTIC_THRESHOLD_HIGH
|
||||||
|
val two = getWireStateAt(1, 0).x >= ELECTIC_THRESHOLD_HIGH
|
||||||
|
val four = getWireStateAt(0, 1).x >= ELECTIC_THRESHOLD_HIGH
|
||||||
|
val eight = getWireStateAt(1, 1).x >= ELECTIC_THRESHOLD_HIGH
|
||||||
|
|
||||||
|
val state = one.toInt(0) or two.toInt(1) or four.toInt(2) or eight.toInt(3)
|
||||||
|
|
||||||
|
(sprite as SheetSpriteAnimation).currentRow = state
|
||||||
|
(spriteEmissive as SheetSpriteAnimation).currentRow = state
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRisingEdge(readFrom: BlockBoxIndex) {
|
override fun onRisingEdge(readFrom: BlockBoxIndex) {
|
||||||
@@ -144,7 +159,4 @@ class FixtureSignalBlocker : Electric, Reorientable {
|
|||||||
|
|
||||||
private infix fun Boolean.nimply(other: Boolean) = (this && !other).toInt().toDouble()
|
private infix fun Boolean.nimply(other: Boolean) = (this && !other).toInt().toDouble()
|
||||||
|
|
||||||
override fun drawBody(frameDelta: Float, batch: SpriteBatch) {
|
|
||||||
super.drawBody(frameDelta, batch)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user