(965c31410a) Unstable v0.10.4.0

This commit is contained in:
Juan Pablo Arce
2020-07-21 08:57:50 -03:00
parent 4f8bd39789
commit 33d3a41104
546 changed files with 45952 additions and 25762 deletions
@@ -67,10 +67,10 @@ namespace Barotrauma.Items.Components
#if CLIENT
if (connector == null)
{
connector = GUI.Style.GetComponentStyle("ConnectionPanelConnector").Sprites[GUIComponent.ComponentState.None][0].Sprite;
wireVertical = GUI.Style.GetComponentStyle("ConnectionPanelWire").Sprites[GUIComponent.ComponentState.None][0].Sprite;
connectionSprite = GUI.Style.GetComponentStyle("ConnectionPanelConnection").Sprites[GUIComponent.ComponentState.None][0].Sprite;
connectionSpriteHighlight = GUI.Style.GetComponentStyle("ConnectionPanelConnection").Sprites[GUIComponent.ComponentState.Hover][0].Sprite;
connector = GUI.Style.GetComponentStyle("ConnectionPanelConnector").GetDefaultSprite();
wireVertical = GUI.Style.GetComponentStyle("ConnectionPanelWire").GetDefaultSprite();
connectionSprite = GUI.Style.GetComponentStyle("ConnectionPanelConnection").GetDefaultSprite();
connectionSpriteHighlight = GUI.Style.GetComponentStyle("ConnectionPanelConnection").GetSprite(GUIComponent.ComponentState.Hover);
screwSprites = GUI.Style.GetComponentStyle("ConnectionPanelScrew").Sprites[GUIComponent.ComponentState.None].Select(s => s.Sprite).ToList();
}
#endif
@@ -202,16 +202,17 @@ namespace Barotrauma.Items.Components
return -1;
}
public void TryAddLink(Wire wire)
public bool TryAddLink(Wire wire)
{
for (int i = 0; i < MaxLinked; i++)
{
if (wires[i] == null)
{
SetWire(i, wire);
return;
return true;
}
}
return false;
}
public void SetWire(int index, Wire wire)
@@ -64,7 +64,14 @@ namespace Barotrauma.Items.Components
partial void InitProjSpecific(XElement element);
private bool linksInitialized;
public override void OnMapLoaded()
{
if (linksInitialized) { return; }
InitializeLinks();
}
public void InitializeLinks()
{
foreach (Connection c in Connections)
{
@@ -90,6 +97,8 @@ namespace Barotrauma.Items.Components
}
}
}
linksInitialized = true;
}
public override void OnItemLoaded()
@@ -260,6 +269,7 @@ namespace Barotrauma.Items.Components
protected override void RemoveComponentSpecific()
{
base.RemoveComponentSpecific();
foreach (Wire wire in DisconnectedWires.ToList())
{
if (wire.OtherConnection(null) == null) //wire not connected to anything else
@@ -80,6 +80,8 @@ namespace Barotrauma.Items.Components
}
}
public override bool RecreateGUIOnResolutionChange => true;
private List<CustomInterfaceElement> customInterfaceElementList = new List<CustomInterfaceElement>();
public CustomInterface(Item item, XElement element)
@@ -110,7 +110,7 @@ namespace Barotrauma.Items.Components
}
}
[InGameEditable, Serialize("255,255,255,255", true, description: "The color of the emitted light (R,G,B,A).", alwaysUseInstanceValues: true)]
[InGameEditable(FallBackTextTag = "connection.setcolor"), Serialize("255,255,255,255", true, description: "The color of the emitted light (R,G,B,A).", alwaysUseInstanceValues: true)]
public Color LightColor
{
get { return lightColor; }
@@ -45,7 +45,7 @@ namespace Barotrauma.Items.Components
fireInRange = IsFireInRange();
fireCheckTimer = FireCheckInterval;
}
item.SendSignal(0, fireInRange ? "1" : "0", "signal_out", null);
item.SendSignal(0, fireInRange ? Output : FalseOutput, "signal_out", null);
}
}
}
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
@@ -205,11 +206,18 @@ namespace Barotrauma.Items.Components
Channel = newChannel;
}
break;
case "set_range":
if (float.TryParse(signal, NumberStyles.Float, CultureInfo.InvariantCulture, out float newRange))
{
Range = newRange;
}
break;
}
}
protected override void RemoveComponentSpecific()
{
base.RemoveComponentSpecific();
list.Remove(this);
}
}
@@ -59,6 +59,8 @@ namespace Barotrauma.Items.Components
private Vector2 sectionExtents;
private float currLength;
public bool Hidden;
private float removeNodeDelay;
@@ -287,7 +289,7 @@ namespace Barotrauma.Items.Components
Structure attachTarget = Structure.GetAttachTarget(item.WorldPosition);
canPlaceNode = attachTarget != null;
sub = sub ?? attachTarget?.Submarine;
sub ??= attachTarget?.Submarine;
Vector2 attachPos = GetAttachPosition(user);
newNodePos = sub == null ?
attachPos :
@@ -308,20 +310,25 @@ namespace Barotrauma.Items.Components
Vector2 prevNodePos = nodes[nodes.Count - 1];
if (sub != null) { prevNodePos += sub.HiddenSubPosition; }
float currLength = 0.0f;
currLength = 0.0f;
for (int i = 0; i < nodes.Count - 1; i++)
{
currLength += Vector2.Distance(nodes[i], nodes[i + 1]);
}
currLength += Vector2.Distance(nodes[nodes.Count - 1], newNodePos);
Vector2 itemPos = item.Position;
if (sub != null && user.Submarine == null) { prevNodePos += sub.Position; }
currLength += Vector2.Distance(prevNodePos, itemPos);
if (currLength > MaxLength)
{
Vector2 diff = nodes[nodes.Count - 1] - newNodePos;
Vector2 diff = prevNodePos - user.Position;
Vector2 pullBackDir = diff == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(diff);
user.AnimController.Collider.ApplyForce(pullBackDir * user.Mass * 50.0f, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
user.AnimController.UpdateUseItem(true, user.WorldPosition + pullBackDir * 200.0f);
Vector2 forceDir = pullBackDir;
if (!user.AnimController.InWater) { forceDir.Y = 0.0f; }
user.AnimController.Collider.ApplyForce(forceDir * user.Mass * 50.0f, maxVelocity: NetConfig.MaxPhysicsBodyVelocity * 0.5f);
if (diff.LengthSquared() > 50.0f * 50.0f)
{
user.AnimController.UpdateUseItem(true, user.WorldPosition + pullBackDir * Math.Min(150.0f, diff.Length()));
}
if (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer)
{
@@ -564,7 +571,7 @@ namespace Barotrauma.Items.Components
int wireIndex = connections[i].FindWireIndex(item);
if (wireIndex == -1) { continue; }
#if SERVER
if (!connections[i].Item.Removed)
if (!connections[i].Item.Removed && (!connections[i].Item.Submarine?.Loading ?? true) && (!Level.Loaded?.Generating ?? true))
{
connections[i].Item.CreateServerEvent(connections[i].Item.GetComponent<ConnectionPanel>());
}