mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
wirecutter wip
This commit is contained in:
@@ -6,3 +6,4 @@
|
||||
"6";"net.torvald.terrarum.modulebasegame.gameitems.ItemStorageChest"
|
||||
"7";"net.torvald.terrarum.modulebasegame.gameitems.WireGraphDebugger"
|
||||
"8";"net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalEmitter"
|
||||
"9";"net.torvald.terrarum.modulebasegame.gameitems.WireCutterAll"
|
||||
|
||||
|
@@ -34,9 +34,7 @@ public class MusicComposerApp extends ApplicationAdapter {
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
fontGame = new GameFontBase("assets/graphics/fonts/terrarum-sans-bitmap", false, true, false,
|
||||
Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest, false, 256, false
|
||||
);
|
||||
fontGame = new GameFontBase("assets/graphics/fonts/terrarum-sans-bitmap", false, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -325,6 +325,29 @@ open class GameWorld() : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
fun removeTileWire(x: Int, y: Int, tile: ItemID, bypassEvent: Boolean) {
|
||||
val (x, y) = coerceXY(x, y)
|
||||
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
||||
val wireNode = wirings[blockAddr]
|
||||
|
||||
if (wireNode != null) {
|
||||
// figure out wiring graphs
|
||||
val matchingNeighbours = WireActor.WIRE_NEARBY.mapIndexed { index, (tx, ty) ->
|
||||
(getAllWiresFrom(x + tx, y + ty)?.contains(tile) == true).toInt() shl index
|
||||
}.sum()
|
||||
for (i in 0..3) {
|
||||
if (matchingNeighbours and WIRE_POS_MAP[i] > 0) {
|
||||
val (tx, ty) = WireActor.WIRE_NEARBY[i]
|
||||
val old = getWireGraphOf(x + tx, y + ty, tile) ?: 0
|
||||
setWireGraphOf(x + tx, y + ty, tile, old and (15 - WIRE_ANTIPOS_MAP[i]))
|
||||
}
|
||||
}
|
||||
|
||||
wiringGraph[blockAddr]!!.remove(tile)
|
||||
wirings[blockAddr]!!.ws.remove(tile)
|
||||
}
|
||||
}
|
||||
|
||||
fun getWireGraphOf(x: Int, y: Int, itemID: ItemID): Int? {
|
||||
val (x, y) = coerceXY(x, y)
|
||||
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
||||
|
||||
@@ -89,12 +89,13 @@ object PlayerBuilderSigrid {
|
||||
// item ids are defined in <module>/items/itemid.csv
|
||||
|
||||
inventory.add("item@basegame:1", 16) // copper pick
|
||||
inventory.add("item@basegame:2") // iron pick
|
||||
inventory.add("item@basegame:3") // steel pick
|
||||
inventory.add("item@basegame:2", 64) // iron pick
|
||||
inventory.add("item@basegame:3", 256) // steel pick
|
||||
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
|
||||
inventory.add("item@basegame:9", 1) // wire cutter
|
||||
|
||||
WireCodex.getAll().forEach {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.Point2i
|
||||
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.modulebasegame.TerrarumIngame
|
||||
|
||||
/**
|
||||
* TEST ITEM; this item cuts every wire on a cell, and has no durability drop
|
||||
*
|
||||
* Created by minjaesong on 2021-09-18.
|
||||
*/
|
||||
class WireCutterAll(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "ITEM_WIRE_CUTTER"
|
||||
override var baseMass = 0.1
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var stackable = true
|
||||
override var inventoryCategory = Category.TOOL
|
||||
override val isUnique = false
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsTextureRegionPack("basegame.items16").get(0, 9)
|
||||
|
||||
init {
|
||||
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
val ingame = Terrarum.ingame!! as TerrarumIngame
|
||||
val mouseTile = Point2i(Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
val wires = ingame.world.getAllWiresFrom(mouseTile.x, mouseTile.y)
|
||||
|
||||
wires?.forEach {
|
||||
ingame.world.removeTileWire(mouseTile.x, mouseTile.y, it, false)
|
||||
} ?: return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun effectWhenEquipped(delta: Float) {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = "wire_render_all"
|
||||
}
|
||||
|
||||
override fun effectOnUnequip(delta: Float) {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ class WirePieceSignalWire(originalID: ItemID, private val atlasID: String, priva
|
||||
|
||||
init {
|
||||
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
|
||||
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user