From 3cc807605e8d1710c82da2f89c8f6428b77efff9 Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 2 Nov 2016 14:40:05 +0200 Subject: [PATCH] Wires can be dragged from a connection panel to the inventory without dropping them, wire connections & nodes are cleared when taking the wire outside --- .../Items/Components/Signal/Connection.cs | 23 ++++++++++--------- .../Source/Items/Components/Signal/Wire.cs | 3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Subsurface/Source/Items/Components/Signal/Connection.cs b/Subsurface/Source/Items/Components/Signal/Connection.cs index af4d2a540..08b461a23 100644 --- a/Subsurface/Source/Items/Components/Signal/Connection.cs +++ b/Subsurface/Source/Items/Components/Signal/Connection.cs @@ -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); diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index db99be805..1aa9ecdd8 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -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;