Fixed wire connections & nodes resetting when copypasting them

This commit is contained in:
Regalis
2016-12-11 22:33:15 +02:00
parent fdf99cddcb
commit 2871830670
4 changed files with 41 additions and 3 deletions
@@ -538,11 +538,28 @@ namespace Barotrauma.Items.Components
RemoveComponentSpecific();
}
protected virtual void RemoveComponentSpecific()
/// <summary>
/// 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
/// </summary>
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;
@@ -156,6 +156,10 @@ namespace Barotrauma.Items.Components
}
}
}
protected override void ShallowRemoveComponentSpecific()
{
}
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
{
@@ -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()
+5 -1
View File
@@ -1996,6 +1996,10 @@ namespace Barotrauma
return true;
}
/// <summary>
/// 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
/// </summary>
public override void ShallowRemove()
{
base.ShallowRemove();
@@ -2004,7 +2008,7 @@ namespace Barotrauma
foreach (ItemComponent ic in components)
{
ic.Remove();
ic.ShallowRemove();
}
ItemList.Remove(this);