(a00338777) v0.9.2.1
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Barotrauma.Networking;
|
||||
using FarseerPhysics;
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -19,7 +18,9 @@ namespace Barotrauma.Items.Components
|
||||
/// Wires that have been disconnected from the panel, but not removed completely (visible at the bottom of the connection panel).
|
||||
/// </summary>
|
||||
public readonly HashSet<Wire> DisconnectedWires = new HashSet<Wire>();
|
||||
|
||||
|
||||
private List<ushort> disconnectedWireIds;
|
||||
|
||||
[Serialize(false, true), Editable(ToolTip = "Locked connection panels cannot be rewired in-game.")]
|
||||
public bool Locked
|
||||
{
|
||||
@@ -64,6 +65,19 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
c.ConnectLinked();
|
||||
}
|
||||
|
||||
if (disconnectedWireIds != null)
|
||||
{
|
||||
foreach (ushort disconnectedWireId in disconnectedWireIds)
|
||||
{
|
||||
if (!(Entity.FindEntityByID(disconnectedWireId) is Item wireItem)) { continue; }
|
||||
Wire wire = wireItem.GetComponent<Wire>();
|
||||
if (wire != null)
|
||||
{
|
||||
DisconnectedWires.Add(wire);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
@@ -193,6 +207,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
loadedConnections[i].wireId.CopyTo(Connections[i].wireId, 0);
|
||||
}
|
||||
|
||||
disconnectedWireIds = element.GetAttributeUshortArray("disconnectedwires", new ushort[0]).ToList();
|
||||
}
|
||||
|
||||
public override XElement Save(XElement parentElement)
|
||||
@@ -204,6 +220,11 @@ namespace Barotrauma.Items.Components
|
||||
c.Save(componentElement);
|
||||
}
|
||||
|
||||
if (DisconnectedWires.Count > 0)
|
||||
{
|
||||
componentElement.Add(new XAttribute("disconnectedwires", string.Join(",", DisconnectedWires.Select(w => w.Item.ID))));
|
||||
}
|
||||
|
||||
return componentElement;
|
||||
}
|
||||
|
||||
@@ -214,6 +235,14 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
protected override void RemoveComponentSpecific()
|
||||
{
|
||||
foreach (Wire wire in DisconnectedWires.ToList())
|
||||
{
|
||||
if (wire.OtherConnection(null) == null) //wire not connected to anything else
|
||||
{
|
||||
wire.Item.Drop(null);
|
||||
}
|
||||
}
|
||||
|
||||
DisconnectedWires.Clear();
|
||||
foreach (Connection c in Connections)
|
||||
{
|
||||
@@ -233,7 +262,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientWrite(NetBuffer msg, object[] extraData = null)
|
||||
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
|
||||
{
|
||||
foreach (Connection connection in Connections)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user