All Powered components of an item are taken into account in grid power/load calculations, not just the first one
This commit is contained in:
@@ -127,45 +127,48 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (it.Condition <= 0.0f) continue;
|
if (it.Condition <= 0.0f) continue;
|
||||||
|
|
||||||
Powered powered = it.GetComponent<Powered>();
|
foreach (Powered powered in it.GetComponents<Powered>())
|
||||||
if (powered == null || !powered.IsActive) continue;
|
|
||||||
|
|
||||||
if (connectedList.Contains(powered)) continue;
|
|
||||||
|
|
||||||
PowerTransfer powerTransfer = powered as PowerTransfer;
|
|
||||||
if (powerTransfer != null)
|
|
||||||
{
|
{
|
||||||
powerTransfer.CheckJunctions(deltaTime);
|
if (powered == null || !powered.IsActive) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
PowerContainer powerContainer = powered as PowerContainer;
|
if (connectedList.Contains(powered)) continue;
|
||||||
if (powerContainer != null)
|
|
||||||
{
|
PowerTransfer powerTransfer = powered as PowerTransfer;
|
||||||
if (recipient.Name == "power_in")
|
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
|
else
|
||||||
{
|
{
|
||||||
fullPower += powerContainer.CurrPowerOutput;
|
connectedList.Add(powered);
|
||||||
}
|
//positive power consumption = the construction requires power -> increase load
|
||||||
}
|
if (powered.CurrPowerConsumption > 0.0f)
|
||||||
else
|
{
|
||||||
{
|
fullLoad += powered.CurrPowerConsumption;
|
||||||
connectedList.Add(powered);
|
}
|
||||||
//positive power consumption = the construction requires power -> increase load
|
else if (powered.CurrPowerConsumption < 0.0f)
|
||||||
if (powered.CurrPowerConsumption > 0.0f)
|
//negative power consumption = the construction is a
|
||||||
{
|
//generator/battery or another junction box
|
||||||
fullLoad += powered.CurrPowerConsumption;
|
{
|
||||||
}
|
fullPower -= powered.CurrPowerConsumption;
|
||||||
else if (powered.CurrPowerConsumption < 0.0f)
|
}
|
||||||
//negative power consumption = the construction is a
|
|
||||||
//generator/battery or another junction box
|
|
||||||
{
|
|
||||||
fullPower -= powered.CurrPowerConsumption;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user