v0.10.6.2

This commit is contained in:
Joonas Rikkonen
2020-10-29 17:55:26 +02:00
parent 20a69375ca
commit bbf06f0984
255 changed files with 6196 additions and 3096 deletions
@@ -271,7 +271,7 @@ namespace Barotrauma.Items.Components
if (wires[i] == null) { continue; }
Connection recipient = wires[i].OtherConnection(this);
if (recipient == null) { continue; }
if (recipient == null || !recipient.IsPower) { continue; }
recipient.item.GetComponent<Powered>()?.ReceivePowerProbeSignal(recipient, source, power);
}
@@ -5,7 +5,7 @@ namespace Barotrauma.Items.Components
{
partial class MemoryComponent : ItemComponent, IServerSerializable
{
const int MaxValueLength = 256;
const int MaxValueLength = ChatMessage.MaxLength;
private string value;
@@ -11,6 +11,7 @@ namespace Barotrauma.Items.Components
private string previousReceivedSignal;
private bool previousResult;
private GroupCollection previousGroups;
private Regex regex;
@@ -19,6 +20,9 @@ namespace Barotrauma.Items.Components
[InGameEditable, Serialize("1", true, description: "The signal this item outputs when the received signal matches the regular expression.", alwaysUseInstanceValues: true)]
public string Output { get; set; }
[InGameEditable, Serialize(false, true, description: "Should the component output a value of a capture group instead of a constant signal.", alwaysUseInstanceValues: true)]
public bool UseCaptureGroup { get; set; }
[Serialize("0", true, description: "The signal this item outputs when the received signal does not match the regular expression.", alwaysUseInstanceValues: true)]
public string FalseOutput { get; set; }
@@ -64,6 +68,7 @@ namespace Barotrauma.Items.Components
{
Match match = regex.Match(receivedSignal);
previousResult = match.Success;
previousGroups = UseCaptureGroup && previousResult ? match.Groups : null;
previousReceivedSignal = receivedSignal;
}
@@ -75,7 +80,30 @@ namespace Barotrauma.Items.Components
}
}
string signalOut = previousResult ? Output : FalseOutput;
string signalOut;
if (previousResult)
{
if (UseCaptureGroup)
{
if (previousGroups != null && previousGroups.TryGetValue(Output, out Group group))
{
signalOut = group.Value;
}
else
{
signalOut = FalseOutput;
}
}
else
{
signalOut = Output;
}
}
else
{
signalOut = FalseOutput;
}
if (ContinuousOutput)
{
if (!string.IsNullOrEmpty(signalOut)) { item.SendSignal(0, signalOut, "signal_out", null); }
@@ -37,7 +37,7 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize(false, true, description: "Can the relay currently pass power and signals through it.", alwaysUseInstanceValues: true)]
[Editable, Serialize(true, true, description: "Can the relay currently pass power and signals through it.", alwaysUseInstanceValues: true)]
public bool IsOn
{
get
@@ -1,10 +1,11 @@
using System.Xml.Linq;
using Barotrauma.Networking;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
partial class Terminal : ItemComponent
{
private const int MaxMessageLength = 150;
private const int MaxMessageLength = ChatMessage.MaxLength;
public string DisplayedWelcomeMessage
{
@@ -21,7 +22,7 @@ namespace Barotrauma.Items.Components
{
if (welcomeMessage == value) { return; }
welcomeMessage = value;
DisplayedWelcomeMessage = TextManager.Get(welcomeMessage, returnNull: true) ?? welcomeMessage;
DisplayedWelcomeMessage = TextManager.Get(welcomeMessage, returnNull: true) ?? welcomeMessage.Replace("\\n", "\n");
}
}
@@ -45,7 +46,9 @@ namespace Barotrauma.Items.Components
{
signal = signal.Substring(0, MaxMessageLength);
}
ShowOnDisplay(signal);
string inputSignal = signal.Replace("\\n", "\n");
ShowOnDisplay(inputSignal);
}
}
}
@@ -63,7 +63,7 @@ namespace Barotrauma.Items.Components
public bool Hidden;
private float removeNodeDelay;
private float editNodeDelay;
private bool locked;
public bool Locked
@@ -198,7 +198,21 @@ namespace Barotrauma.Items.Components
int newNodeIndex = 0;
if (nodes.Count > 1)
{
if (Vector2.DistanceSquared(nodes[nodes.Count - 1], nodePos) < Vector2.DistanceSquared(nodes[0], nodePos))
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))
{
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))
{
newNodeIndex = nodes.Count;
}
}
else if (Vector2.DistanceSquared(nodes[nodes.Count - 1], nodePos) < Vector2.DistanceSquared(nodes[0], nodePos))
{
newNodeIndex = nodes.Count;
}
@@ -276,7 +290,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; }
@@ -402,7 +416,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)
{
@@ -426,6 +442,7 @@ namespace Barotrauma.Items.Components
}
#endif
}
editNodeDelay = 0.1f;
return true;
}
@@ -436,7 +453,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();
@@ -452,7 +469,7 @@ namespace Barotrauma.Items.Components
}
#endif
}
removeNodeDelay = 0.1f;
editNodeDelay = 0.1f;
Drawable = IsActive || sections.Count > 0;
return true;