package ru.dbotthepony.mc.otm.capability.matter

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

class ProfiledMatterStorage<out M : IMatterStorage>(parent: M) : AbstractProfiledStorage<M>(parent), IMatterStorage {
	override var storedMatter by parent::storedMatter

	override val maxStoredMatter: Decimal
		get() = parent.maxStoredMatter

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

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

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

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

	override val matterFlow: FlowDirection
		get() = parent.matterFlow

	override val canSetMatterLevel: Boolean
		get() = parent.canSetMatterLevel

	override fun drainMatter() {
		parent.drainMatter()
	}

	override fun fillMatter() {
		parent.fillMatter()
	}

	override val missingMatter: Decimal
		get() = parent.missingMatter
}
