// On Demand Fuel Cells Refueled v1.1.0.0
// Transparent Pods (PODS)
// created: 21 Aug 2019
// updated: 17 May 2022

// new style

@PART[monoPod,cycloPod,panoPod]:NEEDS[ODFC]:FOR[TransparentPods]
{
	@cost += 50
	@title ^= :$: <color=#6495ED> ODFC</color>:
	@description ^= :(.)$:$0\n<#6495ED><i>ODFC installed.</i> </size></color>:
	@mass += 0.001
	@tags ^= :$:  odfc demand:

	!MODULE[ModuleResourceConverter] {}
	MODULE,0
	{
		name = ODFC
		// scaleFactor = 1
		// threshold = 0.33
		// rateLimit = 0.75
		// fuelCellIsEnabled = false
		// fuelMode = 2
		MODE
		{
			name = MP
			MaxEC = 1.0
			FUELS
			{
				MonoPropellant = 0.001
			}
		}
		MODE
		{
			name = LFO
			MaxEC = 1.0
			FUELS
			{
				LiquidFuel = 0.001125
				Oxidizer = 0.0030555555555556
			}
		}
		MODE
		{
			name = LFIA
			MaxEC = 1.0
			FUELS
			{
				LiquidFuel = 0.000085
				IntakeAir = 0.0204
			}
		}
		MODE:NEEDS[CommunityResourcePack]
		{
			name = H2OW
			MaxEC = 1.0
			FUELS
			{
				Hydrogen = 0.20852969923455
				Oxygen = 0.1577243965100526
			}
			BYPRODUCTS
			{
				Water = 0.0001686838444
			}
		}
		MODE:NEEDS[CryoTanks]
		{
			name = LH2O
			MaxEC = 1.0
			FUELS
			{
				LqdHydrogen = 0.02063
				Oxidizer = 0.00138
			}
			BYPRODUCTS
			{
				Water = 0.00773
			}
		}
		MODE:NEEDS[CommunityResourcePack]
		{
			name = Hydrazine
			MaxEC = 1.0
			FUELS
			{
				Hydrazine = 0.01564
				Oxygen = 0.01182
			}
			BYPRODUCTS
			{
				Water = 0.00001266
			}
		}
	}
}

// ***************** monoPod *****************
// 0.75 EC/s
@PART[monoPod]:NEEDS[ODFC]:FOR[TransparentPods]
{
	@MODULE[ODFC]
	{
		ODFCMaxEC = 0.75
		//@ODFCMaxEC *= #$../CrewCapacity$
	}
}

// ***************** cycloPod *****************
// 1.5 EC/s
@PART[cycloPod]:NEEDS[ODFC]:FOR[TransparentPods]
{
	@MODULE[ODFC]
	{
		ODFCMaxEC = 1.5
	}
}


// ***************** panoPod *****************
// 4.45 EC/s
@PART[panoPod]:NEEDS[ODFC]:FOR[TransparentPods]
{
	@MODULE[ODFC]
	{
		ODFCMaxEC = 4.45
	}
}


@PART[monoPod,cycloPod,panoPod]:NEEDS[ODFC]:FOR[TransparentPods]
{@MODULE[ODFC]
	{
		ODFCMaxEC = 5
		@ODFCMaxEC *= #$../CrewCapacity$
		@MODE[MP]
		{
			@MaxEC = #$../ODFCMaxEC$
			@FUELS
			{
				@MonoPropellant *= #$../MaxEC$
			}
		}
		@MODE[LFO]
		{
			@MaxEC =#$../ODFCMaxEC$
			@FUELS
			{
				@LiquidFuel *= #$../MaxEC$
				@Oxidizer *= #$../MaxEC$
			}
		}
		@MODE[LFIA]
		{
			@MaxEC = #$../ODFCMaxEC$
			@FUELS
			{
				@LiquidFuel *= #$../MaxEC$
				@IntakeAir *= #$../MaxEC$
			}
		}
		@MODE[H2OW]:NEEDS[CommunityResourcePack]
		{
			@MaxEC = #$../ODFCMaxEC$
			@FUELS
			{
				@Hydrogen *= #$../MaxEC$
				@Oxygen *= #$../MaxEC$
			}
			@BYPRODUCTS
			{
				@Water *= #$../MaxEC$
			}
		}
		@MODE[LH2O]:NEEDS[CryoTanks]
		{
			@MaxEC = #$../ODFCMaxEC$
			@FUELS
			{
				@LqdHydrogen *= #$../MaxEC$
				@Oxidizer *= #$../MaxEC$
			}
			@BYPRODUCTS
			{
				@Water *= #$../MaxEC$
			}
		}
		@MODE[Hydrazine]:NEEDS[CommunityResourcePack]
		{
			@MaxEC = #$../ODFCMaxEC$
			@FUELS
			{
				@Hydrazine *= #$../MaxEC$
				@Oxygen *= #$../MaxEC$
			}
			@BYPRODUCTS
			{
				@Water *= #$../MaxEC$
			}
		}
		// !ODFCMaxEC = dummy // clean up
	}
	
	@RESOURCE[electricCharge]
	{
		%amount = #$/CrewCapacity$
		@amount *= 10
		@amount += #$maxAmount$
		@amount ^= :(\.\d)\d+$:$1: // keep only 1 decimal place
		%maxAmount = #$amount$
	}

	@RESOURCE[MonoPropellant]
	{
		%amount = #$/CrewCapacity$
		@amount *= 5
		@amount += #$maxAmount$
		@amount ^= :(\.\d)\d+$:$1: // keep only 1 decimal place
		%maxAmount = #$amount$
	}
}

// CC BY-SA-4.0 by zer0Kerbal
