Unstable v0.1100.0.4 (November 11th 2020)
This commit is contained in:
@@ -63,7 +63,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public bool Hidden;
|
||||
|
||||
private float removeNodeDelay;
|
||||
private float editNodeDelay;
|
||||
|
||||
private bool locked;
|
||||
public bool Locked
|
||||
@@ -200,14 +200,16 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (connections[0] != null && connections[0] != newConnection)
|
||||
{
|
||||
if (Vector2.DistanceSquared(nodes[0], connections[0].Item.Position - (refSub?.HiddenSubPosition ?? Vector2.Zero)) < Vector2.DistanceSquared(nodes[nodes.Count - 1], nodePos))
|
||||
if (Vector2.DistanceSquared(nodes[0], connections[0].Item.Position - (refSub?.HiddenSubPosition ?? Vector2.Zero)) <
|
||||
Vector2.DistanceSquared(nodes[nodes.Count - 1], connections[0].Item.Position - (refSub?.HiddenSubPosition ?? Vector2.Zero)))
|
||||
{
|
||||
newNodeIndex = nodes.Count;
|
||||
}
|
||||
}
|
||||
else if (connections[1] != null && connections[1] != newConnection)
|
||||
{
|
||||
if (Vector2.DistanceSquared(nodes[0], connections[1].Item.Position - (refSub?.HiddenSubPosition ?? Vector2.Zero)) < Vector2.DistanceSquared(nodes[nodes.Count - 1], nodePos))
|
||||
if (Vector2.DistanceSquared(nodes[0], connections[1].Item.Position - (refSub?.HiddenSubPosition ?? Vector2.Zero)) <
|
||||
Vector2.DistanceSquared(nodes[nodes.Count - 1], connections[1].Item.Position - (refSub?.HiddenSubPosition ?? Vector2.Zero)))
|
||||
{
|
||||
newNodeIndex = nodes.Count;
|
||||
}
|
||||
@@ -290,7 +292,7 @@ namespace Barotrauma.Items.Components
|
||||
if (nodes.Count == 0) { return; }
|
||||
|
||||
Character user = item.ParentInventory?.Owner as Character;
|
||||
removeNodeDelay = (user?.SelectedConstruction == null) ? removeNodeDelay - deltaTime : 0.5f;
|
||||
editNodeDelay = (user?.SelectedConstruction == null) ? editNodeDelay - deltaTime : 0.5f;
|
||||
|
||||
Submarine sub = item.Submarine;
|
||||
if (connections[0] != null && connections[0].Item.Submarine != null) { sub = connections[0].Item.Submarine; }
|
||||
@@ -416,7 +418,9 @@ namespace Barotrauma.Items.Components
|
||||
#endif
|
||||
//clients communicate node addition/removal with network events
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer) { return false; }
|
||||
if (newNodePos != Vector2.Zero && canPlaceNode && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > MinNodeDistance)
|
||||
|
||||
if (newNodePos != Vector2.Zero && canPlaceNode && editNodeDelay <= 0.0f && nodes.Count > 0 &&
|
||||
Vector2.DistanceSquared(newNodePos, nodes[nodes.Count - 1]) > MinNodeDistance * MinNodeDistance)
|
||||
{
|
||||
if (nodes.Count >= MaxNodeCount)
|
||||
{
|
||||
@@ -440,6 +444,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
#endif
|
||||
}
|
||||
editNodeDelay = 0.1f;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -450,7 +455,7 @@ namespace Barotrauma.Items.Components
|
||||
//clients communicate node addition/removal with network events
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer) { return false; }
|
||||
|
||||
if (nodes.Count > 1 && removeNodeDelay <= 0.0f)
|
||||
if (nodes.Count > 1 && editNodeDelay <= 0.0f)
|
||||
{
|
||||
nodes.RemoveAt(nodes.Count - 1);
|
||||
UpdateSections();
|
||||
@@ -466,7 +471,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
#endif
|
||||
}
|
||||
removeNodeDelay = 0.1f;
|
||||
editNodeDelay = 0.1f;
|
||||
|
||||
Drawable = IsActive || sections.Count > 0;
|
||||
return true;
|
||||
@@ -617,8 +622,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (connections[i]?.Item != null)
|
||||
{
|
||||
var pt = connections[i].Item.GetComponent<PowerTransfer>();
|
||||
if (pt != null) pt.SetConnectionDirty(connections[i]);
|
||||
connections[i].Item.GetComponent<PowerTransfer>()?.SetConnectionDirty(connections[i]);
|
||||
connections[i].SetRecipientsDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -648,17 +653,29 @@ namespace Barotrauma.Items.Components
|
||||
} while (removed);
|
||||
}
|
||||
|
||||
private void FixNodeEnds()
|
||||
public void FixNodeEnds()
|
||||
{
|
||||
if (connections[0] == null || connections[1] == null || nodes.Count == 0) { return; }
|
||||
Item item0 = connections[0]?.Item;
|
||||
Item item1 = connections[1]?.Item;
|
||||
|
||||
if (item0 == null && item1 != null)
|
||||
{
|
||||
item0 = Item.ItemList.Find(it => it.GetComponent<ConnectionPanel>()?.DisconnectedWires.Contains(this) ?? false);
|
||||
}
|
||||
else if (item0 != null && item1 == null)
|
||||
{
|
||||
item1 = Item.ItemList.Find(it => it.GetComponent<ConnectionPanel>()?.DisconnectedWires.Contains(this) ?? false);
|
||||
}
|
||||
|
||||
if (item0 == null || item1 == null || nodes.Count == 0) { return; }
|
||||
|
||||
Vector2 nodePos = nodes[0];
|
||||
|
||||
Submarine refSub = connections[0].Item.Submarine ?? connections[1].Item.Submarine;
|
||||
Submarine refSub = item0.Submarine ?? item1.Submarine;
|
||||
if (refSub != null) { nodePos += refSub.HiddenSubPosition; }
|
||||
|
||||
float dist1 = Vector2.DistanceSquared(connections[0].Item.Position, nodePos);
|
||||
float dist2 = Vector2.DistanceSquared(connections[1].Item.Position, nodePos);
|
||||
float dist1 = Vector2.DistanceSquared(item0.Position, nodePos);
|
||||
float dist2 = Vector2.DistanceSquared(item1.Position, nodePos);
|
||||
|
||||
//first node is closer to the second item
|
||||
//= the nodes are "backwards", need to reverse them
|
||||
@@ -747,9 +764,9 @@ namespace Barotrauma.Items.Components
|
||||
UpdateSections();
|
||||
}
|
||||
|
||||
public override void Load(XElement componentElement, bool usePrefabValues)
|
||||
public override void Load(XElement componentElement, bool usePrefabValues, IdRemap idRemap)
|
||||
{
|
||||
base.Load(componentElement, usePrefabValues);
|
||||
base.Load(componentElement, usePrefabValues, idRemap);
|
||||
|
||||
string nodeString = componentElement.GetAttributeString("nodes", "");
|
||||
if (nodeString == "") return;
|
||||
|
||||
Reference in New Issue
Block a user