diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs index ba246c616..26a424436 100644 --- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs @@ -127,45 +127,48 @@ namespace Barotrauma.Items.Components if (it.Condition <= 0.0f) continue; - Powered powered = it.GetComponent(); - if (powered == null || !powered.IsActive) continue; - - if (connectedList.Contains(powered)) continue; - - PowerTransfer powerTransfer = powered as PowerTransfer; - if (powerTransfer != null) + foreach (Powered powered in it.GetComponents()) { - powerTransfer.CheckJunctions(deltaTime); - continue; - } - - PowerContainer powerContainer = powered as PowerContainer; - if (powerContainer != null) - { - if (recipient.Name == "power_in") + if (powered == null || !powered.IsActive) continue; + + if (connectedList.Contains(powered)) continue; + + PowerTransfer powerTransfer = powered as PowerTransfer; + if (powerTransfer != null) { - fullLoad += powerContainer.CurrPowerConsumption; + powerTransfer.CheckJunctions(deltaTime); + continue; + } + + PowerContainer powerContainer = powered as PowerContainer; + if (powerContainer != null) + { + if (recipient.Name == "power_in") + { + fullLoad += powerContainer.CurrPowerConsumption; + } + else + { + fullPower += powerContainer.CurrPowerOutput; + } } else { - fullPower += powerContainer.CurrPowerOutput; - } - } - else - { - connectedList.Add(powered); - //positive power consumption = the construction requires power -> increase load - if (powered.CurrPowerConsumption > 0.0f) - { - fullLoad += powered.CurrPowerConsumption; - } - else if (powered.CurrPowerConsumption < 0.0f) - //negative power consumption = the construction is a - //generator/battery or another junction box - { - fullPower -= powered.CurrPowerConsumption; + connectedList.Add(powered); + //positive power consumption = the construction requires power -> increase load + if (powered.CurrPowerConsumption > 0.0f) + { + fullLoad += powered.CurrPowerConsumption; + } + else if (powered.CurrPowerConsumption < 0.0f) + //negative power consumption = the construction is a + //generator/battery or another junction box + { + fullPower -= powered.CurrPowerConsumption; + } } } + } } }