Fixed relay components not carrying power & deactivated (CanTransfer = false or IsActive = false) PowerTransfer components still carrying power

This commit is contained in:
Joonas Rikkonen
2018-01-17 21:25:52 +02:00
parent f5dbbf0735
commit 965eef365b
3 changed files with 43 additions and 8 deletions
@@ -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