mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
wire pieces will be 'lit' when it receives power (power propagation not implemented)
This commit is contained in:
@@ -2,11 +2,14 @@
|
|||||||
"8192";"8192";"WIRE_RED";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,9"
|
"8192";"8192";"WIRE_RED";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,9"
|
||||||
"8193";"8193";"WIRE_GREEN";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,10"
|
"8193";"8193";"WIRE_GREEN";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,10"
|
||||||
"8194";"8194";"WIRE_BLUE";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,11"
|
"8194";"8194";"WIRE_BLUE";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,11"
|
||||||
"8195";"8195";"WIRE_BUNDLE";"signal";"digital_3bits";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,2"
|
#"8195";"8195";"WIRE_BUNDLE";"signal";"digital_3bits";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,2"
|
||||||
#"bundlemaker";"bundlemaker";"WIRE_BUNDLEMAKER";"signal";"digital_bit";3;"digital_bit";"digital_3bits";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,9"
|
|
||||||
|
|
||||||
|
|
||||||
# accept: which wiretype (defined elsewhere) the wires acceps. Use comma to separate multiple. N/A for electronic components (aka "not wires")
|
# accept: which wiretype (defined elsewhere) the wires acceps. Use comma to separate multiple. N/A for electronic components (aka "not wires")
|
||||||
# inputcount: how many sides are input (outputcount is deduced from the inputcount). N/A for wires
|
# inputcount: how many sides are input (outputcount is deduced from the inputcount). N/A for wires
|
||||||
# inputtype: which wiretype it accepts. N/A for wires
|
# inputtype: which wiretype it accepts. N/A for wires
|
||||||
# outputtype: which wiretype it emits. N/A for wires
|
# outputtype: which wiretype it emits. N/A for wires
|
||||||
|
#
|
||||||
|
# comments
|
||||||
|
# "digital_3bits" must come right after three wires it bundles
|
||||||
|
# what's the point of WIRE_BUNDLE when you can overlap as many wires as you want? -- Torvald, 2021-08-09
|
||||||
|
Can't render this file because it contains an unexpected character in line 6 and column 2.
|
@@ -156,6 +156,7 @@ object BlockCodex {
|
|||||||
prop.nameKey = record.get("name")
|
prop.nameKey = record.get("name")
|
||||||
|
|
||||||
prop.id = "$modname:$key"
|
prop.id = "$modname:$key"
|
||||||
|
prop.numericID = key
|
||||||
prop.drop = "$modname:${intVal(record, "drop")}"
|
prop.drop = "$modname:${intVal(record, "drop")}"
|
||||||
|
|
||||||
prop.shadeColR = floatVal(record, "shdr")
|
prop.shadeColR = floatVal(record, "shdr")
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.torvald.terrarum.serialise.toLittle
|
|||||||
class BlockProp {
|
class BlockProp {
|
||||||
|
|
||||||
var id: ItemID = ""
|
var id: ItemID = ""
|
||||||
|
var numericID: Int = -1
|
||||||
|
|
||||||
var nameKey: String = ""
|
var nameKey: String = ""
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ object WireCodex {
|
|||||||
prop.nameKey = record.get("name")
|
prop.nameKey = record.get("name")
|
||||||
|
|
||||||
prop.id = "wire@$modname:$key"
|
prop.id = "wire@$modname:$key"
|
||||||
|
prop.numericID = key
|
||||||
prop.renderClass = record.get("renderclass")
|
prop.renderClass = record.get("renderclass")
|
||||||
prop.accepts = record.get("accept")
|
prop.accepts = record.get("accept")
|
||||||
prop.inputCount = intVal(record, "inputcount")
|
prop.inputCount = intVal(record, "inputcount")
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.torvald.terrarum.gameitem.ItemID
|
|||||||
class WireProp {
|
class WireProp {
|
||||||
|
|
||||||
var id: ItemID = ""
|
var id: ItemID = ""
|
||||||
|
var numericID: Int = -1
|
||||||
var nameKey: String = ""
|
var nameKey: String = ""
|
||||||
|
|
||||||
var renderClass: String = ""
|
var renderClass: String = ""
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
|
||||||
import net.torvald.terrarum.BlendMode
|
import net.torvald.terrarum.BlendMode
|
||||||
import net.torvald.terrarum.CommonResourcePool
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
import net.torvald.terrarum.Point2i
|
import net.torvald.terrarum.Point2i
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||||
|
import net.torvald.terrarum.blockproperties.WireCodex
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.gameitem.ItemID
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.toInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2021-07-30.
|
* Created by minjaesong on 2021-07-30.
|
||||||
@@ -29,7 +28,7 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
|
|||||||
setHitboxDimension(2, 2, 0, 0)
|
setHitboxDimension(2, 2, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var oldWireId = ""
|
private var wireID = ""
|
||||||
private var worldX = 0
|
private var worldX = 0
|
||||||
private var worldY = 0
|
private var worldY = 0
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
|
|||||||
fun setWire(itemID: ItemID, worldX: Int, worldY: Int) {
|
fun setWire(itemID: ItemID, worldX: Int, worldY: Int) {
|
||||||
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0)
|
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0)
|
||||||
|
|
||||||
if (oldWireId != itemID) {
|
if (wireID != itemID) {
|
||||||
if (sprite == null) {
|
if (sprite == null) {
|
||||||
makeNewSprite(CommonResourcePool.getAsTextureRegionPack(itemID))
|
makeNewSprite(CommonResourcePool.getAsTextureRegionPack(itemID))
|
||||||
sprite!!.delays = floatArrayOf(1f,1f)
|
sprite!!.delays = floatArrayOf(1f,1f)
|
||||||
@@ -48,7 +47,7 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
|
|||||||
}
|
}
|
||||||
else sprite!!.setSpriteImage(CommonResourcePool.getAsTextureRegionPack(itemID))
|
else sprite!!.setSpriteImage(CommonResourcePool.getAsTextureRegionPack(itemID))
|
||||||
|
|
||||||
oldWireId = itemID
|
wireID = itemID
|
||||||
}
|
}
|
||||||
this.worldX = worldX
|
this.worldX = worldX
|
||||||
this.worldY = worldY
|
this.worldY = worldY
|
||||||
@@ -76,11 +75,24 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun update(delta: Float) {
|
override fun update(delta: Float) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun drawBody(batch: SpriteBatch) {
|
override fun drawBody(batch: SpriteBatch) {
|
||||||
if (isVisible && sprite != null) {
|
if (isVisible && sprite != null) {
|
||||||
|
if (WireCodex[wireID].accepts == "digital_3bits") {
|
||||||
|
// "digital_3bits" must come right after three wires it bundles
|
||||||
|
val rootID = wireID.substringBefore(':') + ":"
|
||||||
|
var row = 0
|
||||||
|
(WireCodex[wireID].numericID - 3 .. WireCodex[wireID].numericID - 1).forEachIndexed { index, it ->
|
||||||
|
val itemID = rootID + it
|
||||||
|
row = row or ((world?.getWireEmitStateOf(worldX, worldY, itemID)?.isNotZero == true).toInt() shl index)
|
||||||
|
}
|
||||||
|
sprite?.currentRow = row
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprite?.currentRow = (world?.getWireEmitStateOf(worldX, worldY, wireID)?.isNotZero == true).toInt()
|
||||||
|
}
|
||||||
|
|
||||||
BlendMode.resolve(drawMode, batch)
|
BlendMode.resolve(drawMode, batch)
|
||||||
drawSpriteInGoodPosition(sprite!!, batch)
|
drawSpriteInGoodPosition(sprite!!, batch)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -536,6 +536,13 @@ class Vector2 {
|
|||||||
val isZero: Boolean
|
val isZero: Boolean
|
||||||
get() = Math.abs(this.x) <= Epsilon.E && Math.abs(this.y) <= Epsilon.E
|
get() = Math.abs(this.x) <= Epsilon.E && Math.abs(this.y) <= Epsilon.E
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns false if this [Vector2] is the zero [Vector2].
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
val isNotZero: Boolean
|
||||||
|
get() = !isZero
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Negates this [Vector2].
|
* Negates this [Vector2].
|
||||||
* @return [Vector2] this vector
|
* @return [Vector2] this vector
|
||||||
|
|||||||
Reference in New Issue
Block a user