Shortcut when trying to receive/extract zero matter
This commit is contained in:
parent
d534ebbbf2
commit
31cb9973d5
@ -44,25 +44,14 @@ open class MatterStorageImpl @JvmOverloads constructor(
|
||||
|
||||
override var storedMatter = Decimal.ZERO
|
||||
|
||||
private var handler = LazyOptional.of<IMatterStorage> { this }
|
||||
|
||||
fun invalidate() {
|
||||
handler.invalidate()
|
||||
}
|
||||
|
||||
fun revive() {
|
||||
handler = LazyOptional.of { this }
|
||||
}
|
||||
|
||||
fun get(): LazyOptional<IMatterStorage> {
|
||||
return handler
|
||||
}
|
||||
|
||||
open fun canReceiveAll(value: Decimal): Boolean {
|
||||
return maxStoredMatter >= value && storedMatter + value <= maxStoredMatter
|
||||
}
|
||||
|
||||
override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal {
|
||||
if (!howMuch.isPositive)
|
||||
return Decimal.ZERO
|
||||
|
||||
val new: Decimal
|
||||
|
||||
if (maxReceive == null) {
|
||||
@ -82,6 +71,9 @@ open class MatterStorageImpl @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal {
|
||||
if (!howMuch.isPositive)
|
||||
return Decimal.ZERO
|
||||
|
||||
val new: Decimal
|
||||
|
||||
if (maxExtract == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user