mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
wire connectivity wip
This commit is contained in:
@@ -66,11 +66,13 @@ class ActorInventory() : FixtureInventory() {
|
||||
|
||||
fun getQuickslotItem(slot: Int): InventoryPair? = searchByID(quickSlot[slot])
|
||||
|
||||
fun consumeItem(item: GameItem) {
|
||||
fun consumeItem(item: GameItem, amount: Long = 1L) {
|
||||
val actor = this.actor as Actor
|
||||
|
||||
if (item.isDynamic && amount != 1L) throw IllegalArgumentException("Dynamic item must be consumed 'once' (expected 1, got $amount)")
|
||||
|
||||
if (item.stackable && !item.isDynamic) {
|
||||
remove(item, 1)
|
||||
remove(item, amount)
|
||||
}
|
||||
else if (item.isUnique) {
|
||||
return // don't consume a bike!
|
||||
|
||||
@@ -49,7 +49,8 @@ open class FixtureInventory() {
|
||||
|
||||
// other invalid values
|
||||
if (count == 0L)
|
||||
throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is zero.")
|
||||
// throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is zero.")
|
||||
return
|
||||
if (count < 0L)
|
||||
throw IllegalArgumentException("Item count is negative number. If you intended removing items, use remove()\n" +
|
||||
"These commands are NOT INTERCHANGEABLE; they handle things differently according to the context.")
|
||||
@@ -94,7 +95,8 @@ open class FixtureInventory() {
|
||||
println("[ActorInventory] remove $item, $count")
|
||||
|
||||
if (count == 0L)
|
||||
throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is zero.")
|
||||
// throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is zero.")
|
||||
return
|
||||
if (count < 0L)
|
||||
throw IllegalArgumentException("[${this.javaClass.canonicalName}] Item count is negative number. If you intended adding items, use add()" +
|
||||
"These commands are NOT INTERCHANGEABLE; they handle things differently according to the context.")
|
||||
|
||||
Reference in New Issue
Block a user