Cherry-picked 869b725 from dev
This commit is contained in:
@@ -81,6 +81,14 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (IsActive && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
|
if (IsActive && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
|
||||||
{
|
{
|
||||||
|
Submarine sub = null;
|
||||||
|
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 (sub != null)
|
||||||
|
{
|
||||||
|
drawOffset = sub.DrawPosition + sub.HiddenSubPosition;
|
||||||
|
}
|
||||||
|
|
||||||
WireSection.Draw(
|
WireSection.Draw(
|
||||||
spriteBatch,
|
spriteBatch,
|
||||||
new Vector2(nodes[nodes.Count - 1].X, nodes[nodes.Count - 1].Y) + drawOffset,
|
new Vector2(nodes[nodes.Count - 1].X, nodes[nodes.Count - 1].Y) + drawOffset,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
|
using FarseerPhysics;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private Connection[] connections;
|
private Connection[] connections;
|
||||||
|
|
||||||
|
private bool canPlaceNode;
|
||||||
private Vector2 newNodePos;
|
private Vector2 newNodePos;
|
||||||
|
|
||||||
public bool Hidden, Locked;
|
public bool Hidden, Locked;
|
||||||
@@ -158,7 +159,6 @@ namespace Barotrauma.Items.Components
|
|||||||
ic.Drop(null);
|
ic.Drop(null);
|
||||||
}
|
}
|
||||||
if (item.Container != null) item.Container.RemoveContained(this.item);
|
if (item.Container != null) item.Container.RemoveContained(this.item);
|
||||||
|
|
||||||
if (item.body != null) item.body.Enabled = false;
|
if (item.body != null) item.body.Enabled = false;
|
||||||
|
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
@@ -166,6 +166,8 @@ namespace Barotrauma.Items.Components
|
|||||||
CleanNodes();
|
CleanNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.body != null) item.Submarine = newConnection.Item.Submarine;
|
||||||
|
|
||||||
if (sendNetworkEvent)
|
if (sendNetworkEvent)
|
||||||
{
|
{
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
@@ -211,13 +213,31 @@ namespace Barotrauma.Items.Components
|
|||||||
if (connections[0] != null && connections[0].Item.Submarine != null) sub = connections[0].Item.Submarine;
|
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 (connections[1] != null && connections[1].Item.Submarine != null) sub = connections[1].Item.Submarine;
|
||||||
|
|
||||||
if ((item.Submarine != sub || sub == null) && Screen.Selected != GameMain.SubEditorScreen)
|
if (Screen.Selected != GameMain.SubEditorScreen)
|
||||||
{
|
{
|
||||||
ClearConnections();
|
//cannot run wires from sub to another
|
||||||
return;
|
if (sub == null || (item.Submarine != sub && sub != null && item.Submarine != null))
|
||||||
}
|
{
|
||||||
|
ClearConnections();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;
|
if (item.CurrentHull == null)
|
||||||
|
{
|
||||||
|
newNodePos = item.WorldPosition - sub.Position - sub.HiddenSubPosition;
|
||||||
|
canPlaceNode = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;
|
||||||
|
canPlaceNode = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;
|
||||||
|
canPlaceNode = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Use(float deltaTime, Character character = null)
|
public override bool Use(float deltaTime, Character character = null)
|
||||||
@@ -225,7 +245,7 @@ namespace Barotrauma.Items.Components
|
|||||||
if (character == null) return false;
|
if (character == null) return false;
|
||||||
if (character == Character.Controlled && character.SelectedConstruction != null) return false;
|
if (character == Character.Controlled && character.SelectedConstruction != null) return false;
|
||||||
|
|
||||||
if (newNodePos != Vector2.Zero && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
|
if (newNodePos != Vector2.Zero && canPlaceNode && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
|
||||||
{
|
{
|
||||||
nodes.Add(newNodePos);
|
nodes.Add(newNodePos);
|
||||||
UpdateSections();
|
UpdateSections();
|
||||||
|
|||||||
Reference in New Issue
Block a user