package ru.dbotthepony.mc.otm.capability.energy

import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.core.math.Decimal

class ProfiledEnergyStorage<out E : IMatteryEnergyStorage>(parent: E) : AbstractProfiledStorage<E>(parent), IMatteryEnergyStorage {
	override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal {
		return recordTransfer(parent.extractEnergy(howMuch, simulate), simulate)
	}

	override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal {
		return recordReceive(parent.receiveEnergy(howMuch, simulate), simulate)
	}

	override fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal {
		return recordTransfer(parent.extractEnergyChecked(howMuch, simulate), simulate)
	}

	override fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal {
		return recordReceive(parent.receiveEnergyChecked(howMuch, simulate), simulate)
	}

	override val canSetBatteryLevel: Boolean get() = parent.canSetBatteryLevel
	override val missingPower: Decimal get() = parent.missingPower

	override fun drainBattery(): Boolean {
		return parent.drainBattery()
	}

	override fun fillBattery(): Boolean {
		return parent.fillBattery()
	}

	override var batteryLevel: Decimal
		get() = parent.batteryLevel
		set(value) { parent.batteryLevel = value }

	override val maxBatteryLevel: Decimal get() = parent.maxBatteryLevel
	override val energyFlow: FlowDirection get() = parent.energyFlow
}
