From 6aef4073b783d5ac96c684efd72db8ceac73f5c3 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 18 Apr 2019 12:05:43 +0300 Subject: [PATCH] (73782c3bc) Don't prevent selecting items in the sub editor when the cursor is on a wire node, because it makes it very difficult (or impossible) to select items in the wiring mode. + Don't start moving wire nodes unless the cursor is moved by at least 16px from the initial position of the node. --- .../Source/Items/Components/Signal/Wire.cs | 30 +++++++++++-------- .../BarotraumaShared/Source/Items/Item.cs | 4 +++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs index 0f3bfa0d7..9daa403e8 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs @@ -154,11 +154,22 @@ namespace Barotrauma.Items.Components Vector2 nodeWorldPos = GameMain.SubEditorScreen.Cam.ScreenToWorld(PlayerInput.MousePosition) - sub.HiddenSubPosition - sub.Position;// Nodes[(int)selectedNodeIndex]; - nodeWorldPos.X = MathUtils.Round(nodeWorldPos.X, Submarine.GridSize.X / 2.0f); - nodeWorldPos.Y = MathUtils.Round(nodeWorldPos.Y, Submarine.GridSize.Y / 2.0f); + if (selectedNodeIndex.HasValue) + { + nodeWorldPos.X = MathUtils.Round(nodeWorldPos.X, Submarine.GridSize.X / 2.0f); + nodeWorldPos.Y = MathUtils.Round(nodeWorldPos.Y, Submarine.GridSize.Y / 2.0f); + + draggingWire.nodes[(int)selectedNodeIndex] = nodeWorldPos; + draggingWire.UpdateSections(); + } + else + { + if (Vector2.DistanceSquared(nodeWorldPos, draggingWire.nodes[(int)highlightedNodeIndex]) > Submarine.GridSize.X * Submarine.GridSize.X) + { + selectedNodeIndex = highlightedNodeIndex; + } + } - draggingWire.nodes[(int)selectedNodeIndex] = nodeWorldPos; - draggingWire.UpdateSections(); MapEntity.SelectEntity(draggingWire.item); } @@ -213,7 +224,8 @@ namespace Barotrauma.Items.Components Character.Controlled.ClearInputs(); } draggingWire = selectedWire; - selectedNodeIndex = closestIndex; + //selectedNodeIndex = closestIndex; + return; } //remove the node else if (PlayerInput.RightButtonClicked() && closestIndex > 0 && closestIndex < selectedWire.nodes.Count - 1) @@ -264,14 +276,6 @@ namespace Barotrauma.Items.Components if (highlighted != null) { highlighted.item.IsHighlighted = true; - - if (Character.Controlled != null) - { - Character.Controlled.FocusedItem = null; - Character.Controlled.ResetInteract = true; - Character.Controlled.ClearInputs(); - } - if (PlayerInput.LeftButtonClicked()) { MapEntity.DisableSelect = true; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 580b0cbad..71027ab14 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1132,6 +1132,10 @@ namespace Barotrauma { ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime); } + if (!broken) + { + ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime); + } ApplyStatusEffects(!waterProof && inWater ? ActionType.InWater : ActionType.NotInWater, deltaTime); if (body == null || !body.Enabled || !inWater || ParentInventory != null || Removed) { return; }