mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 22:44:04 +09:00
working vital meter for tool durability
This commit is contained in:
36
src/net/torvald/terrarum/AmmoMeterProxy.kt
Normal file
36
src/net/torvald/terrarum/AmmoMeterProxy.kt
Normal file
@@ -0,0 +1,36 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.itemproperties.InventoryItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.ui.UIVitalMetre
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-04-21.
|
||||
*/
|
||||
object AmmoMeterProxy {
|
||||
|
||||
operator fun invoke(actor: ActorHumanoid, meter: UIVitalMetre) {
|
||||
val currentItem = actor.inventory.itemEquipped[InventoryItem.EquipPosition.HAND_GRIP]
|
||||
|
||||
if (currentItem == null) {
|
||||
meter.vitalGetterMax = { null }
|
||||
meter.vitalGetterVal = { null }
|
||||
}
|
||||
else {
|
||||
meter.vitalGetterVal = {
|
||||
if (ItemCodex[currentItem.id].consumable)
|
||||
actor.inventory.getByID(currentItem.id)!!.amount.toFloat()
|
||||
else
|
||||
actor.inventory.getByID(currentItem.id)!!.item.durability
|
||||
}
|
||||
|
||||
meter.vitalGetterMax = {
|
||||
if (ItemCodex[currentItem.id].consumable)
|
||||
500f
|
||||
else
|
||||
actor.inventory.getByID(currentItem.id)!!.item.maxDurability.toFloat()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user