Fixed relay components not carrying power & deactivated (CanTransfer = false or IsActive = false) PowerTransfer components still carrying power
This commit is contained in:
@@ -56,8 +56,15 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
set
|
||||
{
|
||||
if (base.IsActive != value) SetAllConnectionsDirty();
|
||||
if (base.IsActive == value) return;
|
||||
base.IsActive = value;
|
||||
|
||||
SetAllConnectionsDirty();
|
||||
if (!base.IsActive)
|
||||
{
|
||||
//we need to refresh the connections here because Update won't be called on inactive components
|
||||
RefreshConnections();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +91,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
RefreshConnections();
|
||||
if (!CanTransfer) return;
|
||||
|
||||
if (isBroken)
|
||||
@@ -92,8 +100,6 @@ namespace Barotrauma.Items.Components
|
||||
isBroken = false;
|
||||
}
|
||||
|
||||
RefreshConnections();
|
||||
|
||||
if (updateTimer > 0)
|
||||
{
|
||||
//this junction box has already been updated this frame
|
||||
|
||||
@@ -41,10 +41,28 @@ namespace Barotrauma.Items.Components
|
||||
Connection recipient = Wires[i].OtherConnection(this);
|
||||
if (recipient != null) recipients.Add(recipient);
|
||||
}
|
||||
if (internalConnection != null) recipients.Add(internalConnection);
|
||||
return recipients;
|
||||
}
|
||||
}
|
||||
|
||||
//another connection in the same connection panel
|
||||
private Connection internalConnection;
|
||||
public Connection InternalConnection
|
||||
{
|
||||
get
|
||||
{
|
||||
return internalConnection;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (internalConnection != null) internalConnection.internalConnection = null;
|
||||
|
||||
internalConnection = value;
|
||||
if (internalConnection != null) internalConnection.internalConnection = this;
|
||||
}
|
||||
}
|
||||
|
||||
public Item Item
|
||||
{
|
||||
get { return item; }
|
||||
|
||||
@@ -45,21 +45,32 @@ 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;
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power=0.0f)
|
||||
{
|
||||
if (connection.IsPower && connection.Name.Contains("_out")) return;
|
||||
if (connection.IsPower) return;
|
||||
|
||||
if (item.Condition <= 0.0f) return;
|
||||
|
||||
if (power > maxPower) item.Condition = 0.0f;
|
||||
|
||||
|
||||
if (connection.Name.Contains("_in"))
|
||||
{
|
||||
if (!IsOn) return;
|
||||
|
||||
Reference in New Issue
Block a user