mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
sprites
This commit is contained in:
@@ -12,6 +12,7 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
|
||||
override fun invoke() {
|
||||
ModMgr.GameItemLoader.invoke(moduleName)
|
||||
ModMgr.GameBlockLoader.invoke(moduleName)
|
||||
ModMgr.GameWatchdogLoader.register(moduleName, NetFrameWatchdog())
|
||||
println("[${moduleName[0].toUpperCase()}${moduleName.substring(1)}] Dirtboard(tm) go drrrrr")
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package net.torvald.terrarum.modulecomputers.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||
import net.torvald.terrarum.gameactors.drawBodyInGoodPosition
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.BlockBox
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Electric
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -16,7 +12,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
class FixtureComputerConsole : Electric {
|
||||
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsStableFloor = true
|
||||
@Transient override val spawnNeedsWall = false
|
||||
|
||||
constructor() : super(
|
||||
@@ -24,27 +20,31 @@ class FixtureComputerConsole : Electric {
|
||||
nameFun = { Lang["ITEM_COMPUTER_CONSOLE"] }
|
||||
)
|
||||
|
||||
@Transient lateinit var itemImageSheet: TextureRegionPack
|
||||
|
||||
init {
|
||||
itemImageSheet = CommonResourcePool.getOrPut("spritesheet:dwarventech/sprites/fixtures/computers.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("dwarventech", "sprites/fixtures/computers.tga"), TILE_SIZE, TILE_SIZE)
|
||||
} as TextureRegionPack
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun drawBody(frameDelta: Float, batch: SpriteBatch) {
|
||||
super.drawBody(frameDelta, batch)
|
||||
|
||||
val sx = hitbox.startX.toFloat()
|
||||
val sy = hitbox.startY.toFloat()
|
||||
|
||||
drawBodyInGoodPosition(sx, sy) { x, y ->
|
||||
batch.draw(itemImageSheet.get(0, 1), x, y)
|
||||
batch.draw(itemImageSheet.get(1, 1), x + TILE_SIZEF, y)
|
||||
batch.draw(itemImageSheet.get(0, 2), x, y + TILE_SIZEF)
|
||||
batch.draw(itemImageSheet.get(1, 2), x + TILE_SIZEF, y + TILE_SIZEF)
|
||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("dwarventech", "sprites/fixtures/computer_operator_terminal.tga")
|
||||
makeNewSprite(TextureRegionPack(itemImage.texture, 2*TILE_SIZE, 2*TILE_SIZE)).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2025-03-30.
|
||||
*/
|
||||
class FixtureComputerProcessor : Electric {
|
||||
|
||||
@Transient override val spawnNeedsStableFloor = true
|
||||
@Transient override val spawnNeedsWall = false
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 2, 3),
|
||||
nameFun = { Lang["ITEM_COMPUTER_PROCESSOR"] }
|
||||
)
|
||||
|
||||
init {
|
||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("dwarventech", "sprites/fixtures/computer_cpu.tga")
|
||||
makeNewSprite(TextureRegionPack(itemImage.texture, 2*TILE_SIZE, 3*TILE_SIZE)).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package net.torvald.terrarum.modulecomputers.gameitems
|
||||
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
|
||||
@@ -13,11 +11,29 @@ class ItemComputerConsole(originalID: ItemID) : FixtureItemBase(originalID, "net
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 80.0
|
||||
override val canBeDynamic = false
|
||||
override val materialId = ""
|
||||
override val materialId = "STAL"
|
||||
init {
|
||||
// itemImage = FixtureItemBase.getItemImageFromSheet("dwarventech", "sprites/fixtures/desktop_computer.tga", TILE_SIZE, TILE_SIZE)
|
||||
itemImage = FixtureItemBase.getItemImageFromSingleImage("dwarventech", "sprites/fixtures/computer_operator_terminal.tga")
|
||||
}
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var originalName = "ITEM_COMPUTER_CONSOLE"
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2025-03-30.
|
||||
*/
|
||||
class ItemComputerProcessor(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulecomputers.gameactors.FixtureComputerProcessor") {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override var baseMass = 200.0
|
||||
override val canBeDynamic = false
|
||||
override val materialId = "STAL"
|
||||
init {
|
||||
itemImage = FixtureItemBase.getItemImageFromSingleImage("dwarventech", "sprites/fixtures/computer_cpu.tga")
|
||||
}
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var originalName = "ITEM_COMPUTER_PROCESSOR"
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
id;classname;tags
|
||||
#1;net.torvald.terrarum.modulecomputers.gameitems.ItemWearableWorldRadar;
|
||||
#2;net.torvald.terrarum.modulecomputers.gameitems.ItemHomeComputer;
|
||||
16;net.torvald.terrarum.modulecomputers.gameitems.ItemComputerConsole;TAGS
|
||||
256;net.torvald.terrarum.modulecomputers.gameitems.ItemComputerConsole;
|
||||
257;net.torvald.terrarum.modulecomputers.gameitems.ItemComputerProcessor;
|
||||
|
||||
|
BIN
assets/mods/dwarventech/sprites/fixtures/computer_audio_interface.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/computer_audio_interface.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/computer_cpu.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/computer_cpu.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/computer_memory_stack_1.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/computer_memory_stack_1.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/computer_memory_stack_2.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/computer_memory_stack_2.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/computer_network_bridge.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/computer_network_bridge.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/computer_network_interface.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/computer_network_interface.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/computer_operator_terminal.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/computer_operator_terminal.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/holocube.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/holocube.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/holodrive.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/holodrive.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/dwarventech/sprites/fixtures/holovault.tga
LFS
Normal file
BIN
assets/mods/dwarventech/sprites/fixtures/holovault.tga
LFS
Normal file
Binary file not shown.
@@ -27,7 +27,8 @@ typealias BlockBoxIndex = Int
|
||||
open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
|
||||
@Transient open val spawnNeedsWall: Boolean = false
|
||||
@Transient open val spawnNeedsFloor: Boolean = true
|
||||
@Transient open val spawnNeedsFloor: Boolean = true // any floor, including platforms
|
||||
@Transient open val spawnNeedsStableFloor: Boolean = false // solid tiles only (no platforms)
|
||||
@Transient open val spawnNeedsCeiling: Boolean = false
|
||||
|
||||
// if both spawnNeedsWall and spawnNeedsFloor are true, the condition will be interpreted as OR-condition
|
||||
@@ -166,6 +167,14 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
return blockprop.isSolid || blockprop.isPlatform
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition for (if the tile is solid) is always implied regardless of this function. See [canSpawnHere0]
|
||||
*/
|
||||
open fun canSpawnOnThisFloorStable(itemID: ItemID): Boolean {
|
||||
val blockprop = BlockCodex[itemID]
|
||||
return blockprop.isSolid
|
||||
}
|
||||
|
||||
fun canSpawnHere(posX0: Int, posY0: Int): Boolean {
|
||||
val posX = (posX0 - blockBox.width.minus(1).div(2)) fmod world!!.width // width.minus(1) so that spawning position would be same as the ghost's position
|
||||
val posY = posY0 - blockBox.height + 1
|
||||
@@ -215,21 +224,24 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
}
|
||||
|
||||
// check for floors, if spawnNeedsFloor == true
|
||||
if (spawnNeedsFloor || spawnNeedsCeiling) {
|
||||
val yOff = if (spawnNeedsFloor) 1 else -1
|
||||
if (spawnNeedsStableFloor || spawnNeedsFloor || spawnNeedsCeiling) {
|
||||
val yOff = if (spawnNeedsStableFloor || spawnNeedsFloor) 1 else -1
|
||||
cannotSpawnNoFloor = everyBlockboxPos.filter {
|
||||
if (spawnNeedsFloor)
|
||||
if (spawnNeedsStableFloor || spawnNeedsFloor)
|
||||
it.second == posY - oy + blockBox.height - 1
|
||||
else
|
||||
it.second == posY - oy
|
||||
}.any { (x, y) ->
|
||||
world!!.getTileFromTerrain(x, y + yOff).let {
|
||||
if (spawnNeedsStableFloor || spawnNeedsCeiling)
|
||||
!canSpawnOnThisFloorStable(it)
|
||||
else
|
||||
!canSpawnOnThisFloor(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (spawnNeedsWall && (spawnNeedsFloor || spawnNeedsCeiling))
|
||||
if (spawnNeedsWall && (spawnNeedsStableFloor || spawnNeedsFloor || spawnNeedsCeiling))
|
||||
cannotSpawn = cannotSpawn or (cannotSpawnNoWall && cannotSpawnNoFloor)
|
||||
else if (spawnNeedsFloor || spawnNeedsCeiling)
|
||||
cannotSpawn = cannotSpawn or cannotSpawnNoFloor
|
||||
|
||||
Reference in New Issue
Block a user