Wires can be dragged from a connection panel to the inventory without dropping them, wire connections & nodes are cleared when taking the wire outside

This commit is contained in:
Regalis
2016-11-02 14:40:05 +02:00
parent 19683e749d
commit 3cc807605e
2 changed files with 14 additions and 12 deletions

View File

@@ -280,6 +280,18 @@ namespace Barotrauma.Items.Components
}
}
if (draggingConnected != null)
{
DrawWire(spriteBatch, draggingConnected, draggingConnected.Item, PlayerInput.MousePosition, new Vector2(x + width / 2, y + height), mouseInRect, false);
if (!PlayerInput.LeftButtonHeld())
{
panel.Item.NewComponentEvent(panel, true, true);
//draggingConnected.Drop(Character);
draggingConnected = null;
}
}
//if the Character using the panel has a wire item equipped
//and the wire hasn't been connected yet, draw it on the panel
if (equippedWire!=null)
@@ -299,17 +311,6 @@ namespace Barotrauma.Items.Components
//stop dragging a wire item if cursor is outside the panel
if (mouseInRect) Inventory.draggingItem = null;
if (draggingConnected != null)
{
DrawWire(spriteBatch, draggingConnected, draggingConnected.Item, PlayerInput.MousePosition, new Vector2(x + width / 2, y + height), mouseInRect, false);
if (!PlayerInput.LeftButtonHeld())
{
panel.Item.NewComponentEvent(panel, true, true);
//draggingConnected.Drop(Character);
draggingConnected = null;
}
}
spriteBatch.Draw(panelTexture, panelRect, new Rectangle(0, 0, width, height), Color.White);

View File

@@ -213,10 +213,11 @@ namespace Barotrauma.Items.Components
if (connections[0] != null && connections[0].Item.Submarine != null) sub = connections[0].Item.Submarine;
if (connections[1] != null && connections[1].Item.Submarine != null) sub = connections[1].Item.Submarine;
if (item.Submarine != null && item.Submarine != sub)
if (item.Submarine != sub)
{
ClearConnections();
Nodes.Clear();
return;
}
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;