mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
working wire cutter (drops no wire)
This commit is contained in:
Binary file not shown.
@@ -3,14 +3,14 @@ package net.torvald.terrarum.gameitem
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Codex
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.ItemValue
|
||||
import net.torvald.terrarum.ReferencingRanges.PREFIX_DYNAMICITEM
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
typealias ItemID = String
|
||||
|
||||
@@ -210,7 +210,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
return "$dynamicID/$originalID"
|
||||
return "GameItem(dynID:$dynamicID,origID:$originalID)"
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
|
||||
@@ -331,6 +331,11 @@ open class GameWorld() : Disposable {
|
||||
val wireNode = wirings[blockAddr]
|
||||
|
||||
if (wireNode != null) {
|
||||
if (!bypassEvent) {
|
||||
Terrarum.ingame?.queueWireChangedEvent(tile, true, x, y)
|
||||
Terrarum.ingame?.modified(LandUtil.LAYER_WIRE, x, y)
|
||||
}
|
||||
|
||||
// figure out wiring graphs
|
||||
val matchingNeighbours = WireActor.WIRE_NEARBY.mapIndexed { index, (tx, ty) ->
|
||||
(getAllWiresFrom(x + tx, y + ty)?.contains(tile) == true).toInt() shl index
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.lock
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import java.math.BigInteger
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-03-16.
|
||||
@@ -109,10 +108,10 @@ open class FixtureInventory() {
|
||||
existingItem.qty = newCount
|
||||
}
|
||||
else {
|
||||
// unequip must be done before the entry removal
|
||||
unequipFun(existingItem)
|
||||
// depleted item; remove entry from inventory
|
||||
itemList.remove(existingItem)
|
||||
// do additional removal job (e.g. unequipping)
|
||||
unequipFun(existingItem)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2,10 +2,10 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.WireCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.faction.FactionFactory
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-03.
|
||||
@@ -77,7 +77,7 @@ object PlayerBuilderSigrid {
|
||||
fun fillTestInventory(inventory: ActorInventory) {
|
||||
|
||||
App.tileMaker.tags.forEach { t, _ ->
|
||||
inventory.add(t, 9995)
|
||||
inventory.add(t, 5)
|
||||
try {
|
||||
inventory.add("wall@"+t, 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ class WireCutterAll(originalID: ItemID) : GameItem(originalID) {
|
||||
override val originalName = "ITEM_WIRE_CUTTER"
|
||||
override var baseMass = 0.1
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var stackable = true
|
||||
override var stackable = false
|
||||
override var inventoryCategory = Category.TOOL
|
||||
override val isUnique = false
|
||||
override val isUnique = true
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
override val itemImage: TextureRegion
|
||||
@@ -35,7 +35,7 @@ class WireCutterAll(originalID: ItemID) : GameItem(originalID) {
|
||||
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)
|
||||
val wires = ingame.world.getAllWiresFrom(mouseTile.x, mouseTile.y)?.cloneToList()
|
||||
|
||||
wires?.forEach {
|
||||
ingame.world.removeTileWire(mouseTile.x, mouseTile.y, it, false)
|
||||
|
||||
@@ -130,6 +130,14 @@ class SortedArrayList<T: Comparable<T>>(initialSize: Int = 10) : MutableCollecti
|
||||
override inline fun forEach(action: Consumer<in T>?) = arrayList.forEach(action)
|
||||
inline fun forEachIndexed(action: (Int, T) -> Unit) = arrayList.forEachIndexed(action)
|
||||
|
||||
fun cloneToList(): List<T> {
|
||||
val ret = ArrayList<T>()
|
||||
forEach {
|
||||
ret.add(it)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
inline fun <reified R> map(transformation: (T) -> R) = arrayList.map(transformation)
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user