Fixed null exception if switching to wiring mode while some item is selected
This commit is contained in:
@@ -508,6 +508,8 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
Wire selectedWire = ((Item)MapEntity.SelectedList[0]).GetComponent<Wire>();
|
Wire selectedWire = ((Item)MapEntity.SelectedList[0]).GetComponent<Wire>();
|
||||||
|
|
||||||
|
if (selectedWire != null)
|
||||||
|
{
|
||||||
Vector2 mousePos = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
Vector2 mousePos = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
if (selectedWire.item.Submarine != null) mousePos -= (selectedWire.item.Submarine.Position + selectedWire.item.Submarine.HiddenSubPosition);
|
if (selectedWire.item.Submarine != null) mousePos -= (selectedWire.item.Submarine.Position + selectedWire.item.Submarine.HiddenSubPosition);
|
||||||
|
|
||||||
@@ -522,7 +524,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (closestSectionIndex > -1)
|
if (closestSectionIndex > -1)
|
||||||
{
|
{
|
||||||
selectedWire.nodes.Insert(closestSectionIndex+1, mousePos);
|
selectedWire.nodes.Insert(closestSectionIndex + 1, mousePos);
|
||||||
selectedWire.UpdateSections();
|
selectedWire.UpdateSections();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,7 +544,7 @@ namespace Barotrauma.Items.Components
|
|||||||
selectedNodeIndex = closestIndex;
|
selectedNodeIndex = closestIndex;
|
||||||
}
|
}
|
||||||
//remove the node
|
//remove the node
|
||||||
else if (PlayerInput.RightButtonClicked() && closestIndex > 0 && closestIndex < selectedWire.nodes.Count-1)
|
else if (PlayerInput.RightButtonClicked() && closestIndex > 0 && closestIndex < selectedWire.nodes.Count - 1)
|
||||||
{
|
{
|
||||||
selectedWire.nodes.RemoveAt(closestIndex);
|
selectedWire.nodes.RemoveAt(closestIndex);
|
||||||
selectedWire.UpdateSections();
|
selectedWire.UpdateSections();
|
||||||
@@ -550,6 +552,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//check which wire is highlighted with the cursor
|
//check which wire is highlighted with the cursor
|
||||||
Wire highlighted = null;
|
Wire highlighted = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user