diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index bdd3a3735..593374bfe 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -538,11 +538,28 @@ namespace Barotrauma.Items.Components RemoveComponentSpecific(); } - protected virtual void RemoveComponentSpecific() + /// + /// Remove the component so that it doesn't appear to exist in the game world (stop sounds, remove bodies etc) + /// but don't reset anything that's required for cloning the item + /// + public void ShallowRemove() { + if (loopingSound != null) + { + Sounds.SoundManager.Stop(loopingSoundIndex); + } + ShallowRemoveComponentSpecific(); } + protected virtual void ShallowRemoveComponentSpecific() + { + RemoveComponentSpecific(); + } + + protected virtual void RemoveComponentSpecific() + { } + public bool HasRequiredSkills(Character character) { Skill temp; diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index a6dbf2f18..b7e8a1bdb 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -156,6 +156,10 @@ namespace Barotrauma.Items.Components } } } + + protected override void ShallowRemoveComponentSpecific() + { + } public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message) { diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index 80e542c2e..b95df3995 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -93,7 +93,7 @@ namespace Barotrauma.Items.Components IsActive = false; } - + public Connection OtherConnection(Connection connection) { if (connection == null) return null; @@ -686,7 +686,20 @@ namespace Barotrauma.Items.Components } Drawable = nodes.Any(); + } + protected override void ShallowRemoveComponentSpecific() + { + for (int i = 0; i < 2; i++) + { + if (connections[i] == null) continue; + int wireIndex = connections[i].FindWireIndex(item); + + if (wireIndex > -1) + { + connections[i].AddLink(wireIndex, null); + } + } } protected override void RemoveComponentSpecific() diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 54fdacdcc..d28873cee 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -1996,6 +1996,10 @@ namespace Barotrauma return true; } + /// + /// Remove the item so that it doesn't appear to exist in the game world (stop sounds, remove bodies etc) + /// but don't reset anything that's required for cloning the item + /// public override void ShallowRemove() { base.ShallowRemove(); @@ -2004,7 +2008,7 @@ namespace Barotrauma foreach (ItemComponent ic in components) { - ic.Remove(); + ic.ShallowRemove(); } ItemList.Remove(this);