mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 12:34:05 +09:00
signal emitter is now a fixture
This commit is contained in:
@@ -12,6 +12,7 @@ import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-06-17.
|
||||
@@ -29,6 +30,9 @@ open class FixtureBase(
|
||||
var blockBox: BlockBox = blockBox0
|
||||
protected set // something like TapestryObject will want to redefine this
|
||||
|
||||
open val wireEmitterType = ""
|
||||
open val wireEmission = Vector2()
|
||||
open val wireConsumption = Vector2()
|
||||
|
||||
/**
|
||||
* Block-wise position of this fixture when it's placed on the world. Null if it's not on the world
|
||||
@@ -103,13 +107,6 @@ open class FixtureBase(
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update code that runs once for every frame
|
||||
*/
|
||||
open fun updateSelf() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this instance of the fixture from the world
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
class FixtureLogicSignalEmitter(nameFun: () -> String) : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 1), nameFun = nameFun) {
|
||||
|
||||
override val wireEmitterType = "digital_bit"
|
||||
override val wireEmission = Vector2(1.0, 0.0)
|
||||
|
||||
init {
|
||||
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 dispose() { }
|
||||
|
||||
companion object {
|
||||
const val MASS = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ object PlayerBuilderSigrid {
|
||||
inventory.add("item@basegame:5", 385930603) // test tiki torch
|
||||
inventory.add("item@basegame:6", 95) // storage chest
|
||||
inventory.add("item@basegame:7", 1) // wire debugger
|
||||
inventory.add("item@basegame:8", 9995) // power source
|
||||
|
||||
WireCodex.getAll().forEach {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureLogicSignalEmitter
|
||||
|
||||
class ItemLogicSignalEmitter(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "ITEM_TIKI_TORCH"
|
||||
override var baseMass = FixtureLogicSignalEmitter.MASS
|
||||
override var stackable = true
|
||||
override var inventoryCategory = Category.FIXTURE
|
||||
override val isUnique = false
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsTextureRegion("basegame-sprites-fixtures-signal_source.tga")
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame-sprites-fixtures-signal_source.tga") {
|
||||
val t = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "sprites/fixtures/signal_source.tga")))
|
||||
t.flip(false, true)
|
||||
/*return*/t
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
val item = FixtureLogicSignalEmitter { Lang[originalName] }
|
||||
|
||||
return item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
// return true when placed, false when cannot be placed
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user