From 488fded57fd4158d2e91c95afe510ffc8665e2e9 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 10 Apr 2019 15:13:08 +0300 Subject: [PATCH] (208dc8793) Fixed ElectricalDischarger electricity effect staying visible if the item breaks or the component is deactivated from outside (e.g. via a StatusEffect or the parent component). Closes #1402 --- .../Items/Components/ElectricalDischarger.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ElectricalDischarger.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ElectricalDischarger.cs index 501491c11..001155e91 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ElectricalDischarger.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ElectricalDischarger.cs @@ -34,6 +34,20 @@ namespace Barotrauma.Items.Components } } + public override bool IsActive + { + get { return base.IsActive; } + set + { + base.IsActive = value; + if (!value) + { + nodes.Clear(); + charactersInRange.Clear(); + } + } + } + [Serialize(100.0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 5000.0f)] public float Range { @@ -126,14 +140,19 @@ namespace Barotrauma.Items.Components } else { - nodes.Clear(); - charactersInRange.Clear(); IsActive = false; } voltage = 0.0f; } + public override void UpdateBroken(float deltaTime, Camera cam) + { + base.UpdateBroken(deltaTime, cam); + nodes.Clear(); + charactersInRange.Clear(); + } + private void Discharge() { ApplyStatusEffects(ActionType.OnUse, 1.0f);