Fixed relays burning out when connected to the main power grid. The changes in bb98767 caused relay components to be considered parts of whichever power grid they're connected to, causing their power and load to match the rest of the grid which usually causes them to go over the max power value. Closes #279

+ Fixed "powerConnections" field not being updated when creating PowerTransfer components mid-round, which made fabricated relays unusable for power transfer.
This commit is contained in:
Joonas Rikkonen
2018-02-24 20:46:28 +02:00
parent 127cc28af3
commit 6fcf2f573b
3 changed files with 56 additions and 57 deletions
@@ -44,25 +44,14 @@ namespace Barotrauma.Items.Components
{
IsActive = true;
}
public override void OnMapLoaded()
{
base.OnMapLoaded();
ConnectionPanel connectionPanel = item.GetComponent<ConnectionPanel>();
var powerIn = connectionPanel.Connections.Find(c => c.Name == "power_in");
var powerOut = connectionPanel.Connections.Find(c => c.Name == "power_out");
if (powerIn != null) powerIn.InternalConnection = powerOut;
}
public override void Update(float deltaTime, Camera cam)
{
base.Update(deltaTime, cam);
item.SendSignal(0, IsOn ? "1" : "0", "state_out", null);
if (-currPowerConsumption > maxPower) item.Condition = 0.0f;
if (Math.Min(-currPowerConsumption, PowerLoad) > maxPower) item.Condition = 0.0f;
}
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f)
@@ -82,7 +71,7 @@ namespace Barotrauma.Items.Components
if (connectionNumber > 0) outConnection += connectionNumber;
item.SendSignal(stepsTaken, signal, outConnection, sender, power);
item.SendSignal(stepsTaken, signal, outConnection, sender, power);
}
else if (connection.Name == "toggle")
{