diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt new file mode 100644 index 000000000..70d345734 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt @@ -0,0 +1,35 @@ +package ru.dbotthepony.mc.otm.capability.energy + +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.math.Decimal + +class ProxiedEnergyStorage(var parent: T? = null) : IMatteryEnergyStorage { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return parent?.extractEnergy(howMuch, simulate) ?: Decimal.ZERO + } + + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return parent?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO + } + + override var batteryLevel: Decimal + get() = parent?.batteryLevel ?: Decimal.ZERO + set(value) { parent?.batteryLevel = value } + override val maxBatteryLevel: Decimal + get() = parent?.maxBatteryLevel ?: Decimal.ZERO + override val energyFlow: FlowDirection + get() = parent?.energyFlow ?: FlowDirection.NONE + + override val canSetBatteryLevel: Boolean + get() = parent?.canSetBatteryLevel ?: false + override val missingPower: Decimal + get() = parent?.missingPower ?: Decimal.ZERO + + override fun drainBattery(): Boolean { + return parent?.drainBattery() ?: false + } + + override fun fillBattery(): Boolean { + return parent?.fillBattery() ?: false + } +}