Wire nodes are synced when a player adds a new node and when the wire is connected to something

This commit is contained in:
Joonas Rikkonen
2017-07-25 23:27:30 +03:00
parent 431e5bb9b8
commit f062ca0e4d
2 changed files with 7 additions and 4 deletions
@@ -228,7 +228,7 @@ namespace Barotrauma.Items.Components
if (Connections[i].Wires.Contains(newWire)) continue; if (Connections[i].Wires.Contains(newWire)) continue;
Connections[i].TryAddLink(newWire); Connections[i].TryAddLink(newWire);
newWire.Connect(Connections[i]); newWire.Connect(Connections[i], true, true);
var otherConnection = newWire.OtherConnection(Connections[i]); var otherConnection = newWire.OtherConnection(Connections[i]);
@@ -227,14 +227,17 @@ namespace Barotrauma.Items.Components
{ {
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 && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
{ {
nodes.Add(newNodePos); nodes.Add(newNodePos);
UpdateSections(); UpdateSections();
Drawable = true; Drawable = true;
newNodePos = Vector2.Zero; newNodePos = Vector2.Zero;
if (GameMain.Server != null)
{
item.CreateServerEvent(this);
}
} }
return true; return true;
} }