mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 21:14:04 +09:00
test copper sign and it has no sprite
This commit is contained in:
@@ -121,7 +121,12 @@ id;classname;tags
|
|||||||
32777;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc09;MUSIC,PHONO
|
32777;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc09;MUSIC,PHONO
|
||||||
|
|
||||||
# data storage (tapestries; 256)
|
# data storage (tapestries; 256)
|
||||||
#33023;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry;FIXTURE
|
#33024;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry;FIXTURE,BASEOBJECT
|
||||||
|
|
||||||
|
# data storage (text signs; 256)
|
||||||
|
33280;net.torvald.terrarum.modulebasegame.gameitems.ItemTextSignCopper;FIXTURE,BASEOBJECT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# fluids on storage
|
# fluids on storage
|
||||||
# preferably autogenerated
|
# preferably autogenerated
|
||||||
|
|||||||
|
Binary file not shown.
@@ -27,6 +27,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
|
|
||||||
@Transient open val spawnNeedsWall: Boolean = false
|
@Transient open val spawnNeedsWall: Boolean = false
|
||||||
@Transient open val spawnNeedsFloor: Boolean = true
|
@Transient open val spawnNeedsFloor: Boolean = true
|
||||||
|
@Transient open val spawnNeedsCeiling: Boolean = false
|
||||||
|
|
||||||
// if both spawnNeedsWall and spawnNeedsFloor are true, the condition will be interpreted as OR-condition
|
// if both spawnNeedsWall and spawnNeedsFloor are true, the condition will be interpreted as OR-condition
|
||||||
|
|
||||||
@@ -178,8 +179,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for floors, if spawnNeedsFloor == true
|
// check for floors, if spawnNeedsFloor == true
|
||||||
if (spawnNeedsFloor) {
|
if (spawnNeedsFloor || spawnNeedsCeiling) {
|
||||||
val y = posY + blockBox.height
|
val y = posY + if (spawnNeedsFloor) blockBox.height else -1
|
||||||
val xs = posX until posX + blockBox.width
|
val xs = posX until posX + blockBox.width
|
||||||
cannotSpawnNoFloor = xs.any { x ->
|
cannotSpawnNoFloor = xs.any { x ->
|
||||||
world!!.getTileFromTerrain(x, y).let {
|
world!!.getTileFromTerrain(x, y).let {
|
||||||
@@ -188,9 +189,9 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spawnNeedsWall && spawnNeedsFloor)
|
if (spawnNeedsWall && (spawnNeedsFloor || spawnNeedsCeiling))
|
||||||
cannotSpawn = cannotSpawn or (cannotSpawnNoWall && cannotSpawnNoFloor)
|
cannotSpawn = cannotSpawn or (cannotSpawnNoWall && cannotSpawnNoFloor)
|
||||||
else if (spawnNeedsFloor)
|
else if (spawnNeedsFloor || spawnNeedsCeiling)
|
||||||
cannotSpawn = cannotSpawn or cannotSpawnNoFloor
|
cannotSpawn = cannotSpawn or cannotSpawnNoFloor
|
||||||
else if (spawnNeedsWall)
|
else if (spawnNeedsWall)
|
||||||
cannotSpawn = cannotSpawn or cannotSpawnNoWall
|
cannotSpawn = cannotSpawn or cannotSpawnNoWall
|
||||||
@@ -210,10 +211,14 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
var soundSource =
|
var soundSource =
|
||||||
if (spawnNeedsWall) 1
|
if (spawnNeedsWall) 1
|
||||||
else if (spawnNeedsFloor) 0
|
else if (spawnNeedsFloor) 0
|
||||||
|
else if (spawnNeedsCeiling) 3
|
||||||
else 2
|
else 2
|
||||||
// 1: wall, 0: floor, 2: if wall is not solid, use wall; else, use floor
|
// 1: wall, 0: floor, 2: if wall is not solid, use wall; else, use floor
|
||||||
val wallTile = world!!.getTileFromWall(posXc, posYb)
|
val wallTile = world!!.getTileFromWall(posXc, posYb)
|
||||||
val terrTile = world!!.getTileFromTerrain(posXc, posYb + 1)
|
val terrTile = if (soundSource == 3)
|
||||||
|
world!!.getTileFromTerrain(posXc, posYb - blockBox.height)
|
||||||
|
else
|
||||||
|
world!!.getTileFromTerrain(posXc, posYb + 1)
|
||||||
|
|
||||||
if (soundSource == 2) {
|
if (soundSource == 2) {
|
||||||
soundSource = if (BlockCodex[wallTile].isSolid)
|
soundSource = if (BlockCodex[wallTile].isSolid)
|
||||||
@@ -224,7 +229,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
|
|
||||||
when (soundSource) {
|
when (soundSource) {
|
||||||
1 -> PickaxeCore.makeNoiseTileBurst(this, wallTile)
|
1 -> PickaxeCore.makeNoiseTileBurst(this, wallTile)
|
||||||
0 -> PickaxeCore.makeNoiseTileBurst(this, terrTile)
|
0, 3 -> PickaxeCore.makeNoiseTileBurst(this, terrTile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make some dust
|
// make some dust
|
||||||
@@ -235,6 +240,13 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
PickaxeCore.makeDust(tile, x, y - 1, 4 + (Math.random() + Math.random()).roundToInt())
|
PickaxeCore.makeDust(tile, x, y - 1, 4 + (Math.random() + Math.random()).roundToInt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (soundSource == 3) {
|
||||||
|
val y = posY
|
||||||
|
for (x in posX until posX + blockBox.width) {
|
||||||
|
val tile = world!!.getTileFromTerrain(x, y)
|
||||||
|
PickaxeCore.makeDust(tile, x, y - 1, 4 + (Math.random() + Math.random()).roundToInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for (y in posY until posY + blockBox.height) {
|
for (y in posY until posY + blockBox.height) {
|
||||||
for (x in posX until posX + blockBox.width) {
|
for (x in posX until posX + blockBox.width) {
|
||||||
|
|||||||
@@ -34,16 +34,16 @@ internal class FixtureTapestry : FixtureBase {
|
|||||||
private var tilewiseHitboxWidth by Delegates.notNull<Int>()
|
private var tilewiseHitboxWidth by Delegates.notNull<Int>()
|
||||||
private var tilewiseHitboxHeight by Delegates.notNull<Int>()
|
private var tilewiseHitboxHeight by Delegates.notNull<Int>()
|
||||||
|
|
||||||
private constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
||||||
renderOrder = RenderOrder.BEHIND,
|
renderOrder = RenderOrder.BEHIND,
|
||||||
nameFun = { Lang["ITEM_TAPESTRY"] }
|
nameFun = { Lang["ITEM_TAPESTRY"] }
|
||||||
)
|
)
|
||||||
|
|
||||||
constructor(rawBytes: ByteArray, framingMaterial: ItemID) : super(
|
constructor(rawBytes: ByteArray, framingMaterial: ItemID) : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
||||||
renderOrder = RenderOrder.BEHIND,
|
renderOrder = RenderOrder.BEHIND,
|
||||||
nameFun = { Lang["ITEM_TAPESTRY"] }
|
nameFun = { Lang["ITEM_TAPESTRY"] }
|
||||||
) {
|
) {
|
||||||
this.rawBytes = rawBytes
|
this.rawBytes = rawBytes
|
||||||
this.frameBlock = framingMaterial
|
this.frameBlock = framingMaterial
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
|
import com.badlogic.gdx.graphics.Texture
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
|
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||||
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
|
import net.torvald.terrarum.ModMgr
|
||||||
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.toInt
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2024-03-20.
|
||||||
|
*/
|
||||||
|
class FixtureTextSignCopper : Electric {
|
||||||
|
|
||||||
|
@Transient override val spawnNeedsCeiling = true
|
||||||
|
@Transient override val spawnNeedsFloor = false
|
||||||
|
@Transient override val spawnNeedsWall = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var text = "헬로 월드!"
|
||||||
|
var panelCount = 5
|
||||||
|
|
||||||
|
constructor() : super(
|
||||||
|
BlockBox(BlockBox.NO_COLLISION, 2, 2),
|
||||||
|
renderOrder = RenderOrder.BEHIND,
|
||||||
|
nameFun = { Lang["ITEM_COPPER_SIGN"] }
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun spawn(posX: Int, posY: Int, installersUUID: UUID?): Boolean = spawn(posX, posY, installersUUID, panelCount.coerceAtLeast(2), 2)
|
||||||
|
|
||||||
|
override fun reload() {
|
||||||
|
super.reload()
|
||||||
|
|
||||||
|
// must be re-spawned on reload to make it visible after load
|
||||||
|
spawn(
|
||||||
|
intTilewiseHitbox.canonicalX.toInt(),
|
||||||
|
intTilewiseHitbox.canonicalY.toInt(),
|
||||||
|
actorThatInstalledThisFixture,
|
||||||
|
panelCount.coerceAtLeast(2),
|
||||||
|
2
|
||||||
|
)
|
||||||
|
setEmitterAndSink()
|
||||||
|
setSprites(panelCount)
|
||||||
|
updateSignal()
|
||||||
|
}
|
||||||
|
private fun setEmitterAndSink() {
|
||||||
|
clearStatus()
|
||||||
|
setWireSinkAt(0, 0, "digital_bit")
|
||||||
|
setWireSinkAt(panelCount - 1, 0, "digital_bit")
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
CommonResourcePool.addToLoadingList("pixmap:copper_sign") {
|
||||||
|
Pixmap(ModMgr.getGdxFile("basegame", "sprites/fixtures/text_sign_glass_copper.tga"))
|
||||||
|
}
|
||||||
|
CommonResourcePool.loadAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transient private var textOverlay: SheetSpriteAnimation? = null
|
||||||
|
@Transient private var textOverlayEmissive: SheetSpriteAnimation? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This only constructs the base panel
|
||||||
|
*/
|
||||||
|
private fun setSprites(panelCount: Int) {
|
||||||
|
val panelCount = panelCount.coerceAtLeast(2)
|
||||||
|
val pixmap = CommonResourcePool.getAs<Pixmap>("pixmap:copper_sign")
|
||||||
|
|
||||||
|
val W = TILE_SIZE
|
||||||
|
val H = 4 * TILE_SIZE
|
||||||
|
val ROW0 = 0
|
||||||
|
val ROW1 = H
|
||||||
|
|
||||||
|
val pixmapSprite = Pixmap(W * panelCount, H, Pixmap.Format.RGBA8888)
|
||||||
|
val pixmapSpriteEmsv = Pixmap(W * panelCount, H, Pixmap.Format.RGBA8888)
|
||||||
|
val pixmapOverlay = Pixmap(W * panelCount, H, Pixmap.Format.RGBA8888)
|
||||||
|
val pixmapOverlayEmsv = Pixmap(W * panelCount, H, Pixmap.Format.RGBA8888)
|
||||||
|
|
||||||
|
pixmapSprite.drawPixmap(pixmap, 0, 0, 0, ROW0, W, H)
|
||||||
|
pixmapSprite.drawPixmap(pixmap, W * (panelCount - 1), 0, 32, ROW0, W, H)
|
||||||
|
pixmapSpriteEmsv.drawPixmap(pixmap, 0, 0, 0, ROW1, W, H)
|
||||||
|
pixmapSpriteEmsv.drawPixmap(pixmap, W * (panelCount - 1), 0, 32, ROW1, W, H)
|
||||||
|
for (mid in 1 until panelCount - 1) {
|
||||||
|
pixmapSprite.drawPixmap(pixmap, W * mid, 0, 16, ROW0, W, H)
|
||||||
|
pixmapSpriteEmsv.drawPixmap(pixmap, W * mid, 0, 16, ROW1, W, H)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tiles in 0 until panelCount) {
|
||||||
|
pixmapOverlay.drawPixmap(pixmap, W * tiles, 0, 48, ROW0, W, H)
|
||||||
|
pixmapOverlayEmsv.drawPixmap(pixmap, W * tiles, 0, 48, ROW1, W, H)
|
||||||
|
}
|
||||||
|
|
||||||
|
makeNewSprite(TextureRegionPack(Texture(pixmapSprite), W * panelCount, H / 2)).let {
|
||||||
|
it.setRowsAndFrames(2, 1)
|
||||||
|
it.delays = FloatArray(1) { Float.POSITIVE_INFINITY }
|
||||||
|
}
|
||||||
|
makeNewSpriteEmissive(TextureRegionPack(Texture(pixmapSpriteEmsv), W * panelCount, H / 2)).let {
|
||||||
|
it.setRowsAndFrames(2, 1)
|
||||||
|
it.delays = FloatArray(1) { Float.POSITIVE_INFINITY }
|
||||||
|
}
|
||||||
|
|
||||||
|
textOverlay = SheetSpriteAnimation(this).also {
|
||||||
|
it.setSpriteImage(TextureRegionPack(Texture(pixmapOverlay), W, H / 2))
|
||||||
|
it.setRowsAndFrames(2, 1)
|
||||||
|
}
|
||||||
|
textOverlayEmissive = SheetSpriteAnimation(this).also {
|
||||||
|
it.setSpriteImage(TextureRegionPack(Texture(pixmapOverlayEmsv), W, H / 2))
|
||||||
|
it.setRowsAndFrames(2, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pixmapSprite.dispose()
|
||||||
|
pixmapSpriteEmsv.dispose()
|
||||||
|
pixmapOverlay.dispose()
|
||||||
|
pixmapOverlayEmsv.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transient var lit = true
|
||||||
|
|
||||||
|
override fun drawEmissive(frameDelta: Float, batch: SpriteBatch) {
|
||||||
|
super.drawEmissive(frameDelta, batch)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun drawBody(frameDelta: Float, batch: SpriteBatch) {
|
||||||
|
super.drawBody(frameDelta, batch)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateSignal() {
|
||||||
|
lit = !(isSignalHigh(0, 0) || isSignalHigh(panelCount - 1, 0)) // isHigh and isLow are not mutually exclusive!
|
||||||
|
|
||||||
|
(sprite as? SheetSpriteAnimation)?.currentRow = 1 - lit.toInt()
|
||||||
|
(spriteEmissive as? SheetSpriteAnimation)?.currentRow = 1 - lit.toInt()
|
||||||
|
textOverlay?.currentRow = 1 - lit.toInt()
|
||||||
|
textOverlayEmissive?.currentRow = 1 - lit.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
super.dispose()
|
||||||
|
if (textOverlay != null) App.disposables.add(textOverlay)
|
||||||
|
if (textOverlayEmissive != null) App.disposables.add(textOverlayEmissive)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.gameitems
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureLogicSignalEmitter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2024-03-20.
|
||||||
|
*/
|
||||||
|
class ItemTextSignCopper(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureTextSignCopper") {
|
||||||
|
|
||||||
|
override var dynamicID: ItemID = originalID
|
||||||
|
override var baseMass = 10.0
|
||||||
|
override val canBeDynamic = false
|
||||||
|
override val materialId = ""
|
||||||
|
override val itemImage: TextureRegion
|
||||||
|
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(10, 3)
|
||||||
|
|
||||||
|
override var baseToolSize: Double? = baseMass
|
||||||
|
override var originalName = "ITEM_COPPER_SIGN"
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user