(d9829ac) v0.9.4.0

This commit is contained in:
Regalis
2019-10-24 18:05:42 +02:00
parent 9aa12bcac2
commit b39922a074
319 changed files with 12516 additions and 6815 deletions
@@ -11,25 +11,29 @@ namespace Barotrauma.Items.Components
protected float[] timeSinceReceived;
protected float[] receivedSignal;
//the output is sent if both inputs have received a signal within the timeframe
protected float timeFrame;
[InGameEditable(MinValueFloat = -999999.0f, MaxValueFloat = 999999.0f), Serialize(999999.0f, true)]
[Serialize(999999.0f, true, description: "The output of the item is restricted below this value."),
InGameEditable(MinValueFloat = -999999.0f, MaxValueFloat = 999999.0f)]
public float ClampMax
{
get;
set;
}
[InGameEditable(MinValueFloat = -999999.0f, MaxValueFloat = 999999.0f), Serialize(-999999.0f, true)]
[Serialize(-999999.0f, true, description: "The output of the item is restricted above this value."),
InGameEditable(MinValueFloat = -999999.0f, MaxValueFloat = 999999.0f)]
public float ClampMin
{
get;
set;
}
[InGameEditable(DecimalCount = 2), Serialize(0.0f, true)]
[InGameEditable(DecimalCount = 2),
Serialize(0.0f, true, description: "The item must have received signals to both inputs within this timeframe to output the sum of the signals." +
" If set to 0, the inputs must be received at the same time.")]
public float TimeFrame
{
get { return timeFrame; }
@@ -13,7 +13,7 @@ namespace Barotrauma.Items.Components
//the output is sent if both inputs have received a signal within the timeframe
protected float timeFrame;
[InGameEditable(DecimalCount = 2), Serialize(0.0f, true)]
[InGameEditable(DecimalCount = 2), Serialize(0.0f, true, description: "The item sends the output if both inputs have received a non-zero signal within the timeframe. If set to 0, the inputs must receive a signal at the same time.")]
public float TimeFrame
{
get { return timeFrame; }
@@ -23,14 +23,14 @@ namespace Barotrauma.Items.Components
}
}
[InGameEditable, Serialize("1", true)]
[InGameEditable, Serialize("1", true, description: "The signal sent when both inputs have received a non-zero signal.")]
public string Output
{
get { return output; }
set { output = value; }
}
[InGameEditable, Serialize("", true)]
[InGameEditable, Serialize("", true, description: "The signal sent when both inputs have not received a non-zero signal (if empty, no signal is sent).")]
public string FalseOutput
{
get { return falseOutput; }
@@ -21,7 +21,7 @@ namespace Barotrauma.Items.Components
private List<ushort> disconnectedWireIds;
[Serialize(false, true), Editable(ToolTip = "Locked connection panels cannot be rewired in-game.")]
[Editable, Serialize(false, true, description: "Locked connection panels cannot be rewired in-game.")]
public bool Locked
{
get;
@@ -171,9 +171,9 @@ namespace Barotrauma.Items.Components
return true;
}
public override void Load(XElement element)
public override void Load(XElement element, bool usePrefabValues)
{
base.Load(element);
base.Load(element, usePrefabValues);
List<Connection> loadedConnections = new List<Connection>();
@@ -12,9 +12,9 @@ namespace Barotrauma.Items.Components
public bool ContinuousSignal;
public bool State;
public string Connection;
[Serialize("", false, translationTextTag = "Label.")]
[Serialize("", false, translationTextTag: "Label.", description: "The text displayed on this button/tickbox."), Editable]
public string Label { get; set; }
[Serialize("1", false)]
[Serialize("1", false, description: "The signal sent out when this button is pressed or this tickbox checked."), Editable]
public string Signal { get; set; }
public string Name => "CustomInterfaceElement";
@@ -40,7 +40,7 @@ namespace Barotrauma.Items.Components
}
private string[] labels;
[Serialize("", true)]
[Serialize("", true, description: "The texts displayed on the buttons/tickboxes, separated by commas.")]
public string Labels
{
get { return string.Join(",", labels); }
@@ -55,7 +55,7 @@ namespace Barotrauma.Items.Components
}
}
private string[] signals;
[Serialize("", true)]
[Serialize("", true, description: "The signals sent when the buttons are pressed or the tickboxes checked, separated by commas.")]
public string Signals
{
//use semicolon as a separator because comma may be needed in the signals (for color or vector values for example)
@@ -9,9 +9,12 @@ namespace Barotrauma.Items.Components
{
public readonly string Signal;
public readonly float SignalStrength;
public float SendTimer;
//in number of frames
public int SendTimer;
//in number of frames
public int SendDuration;
public DelayedSignal(string signal, float signalStrength, float sendTimer)
public DelayedSignal(string signal, float signalStrength, int sendTimer)
{
Signal = signal;
SignalStrength = signalStrength;
@@ -19,25 +22,35 @@ namespace Barotrauma.Items.Components
}
}
const int SignalQueueSize = 500;
private int signalQueueSize;
private int delayTicks;
private Queue<DelayedSignal> signalQueue;
private DelayedSignal prevQueuedSignal;
[InGameEditable(MinValueFloat = 0.0f, MaxValueFloat = 60.0f, DecimalCount = 2), Serialize(1.0f, true)]
private float delay;
[InGameEditable(MinValueFloat = 0.0f, MaxValueFloat = 60.0f, DecimalCount = 2), Serialize(1.0f, true, description: "How long the item delays the signals (in seconds).")]
public float Delay
{
get;
set;
get { return delay; }
set
{
if (value == delay) { return; }
delay = value;
delayTicks = (int)(delay / Timing.Step);
signalQueueSize = delayTicks * 2;
}
}
[InGameEditable(ToolTip = "Should the component discard previously received signals when a new one is received."), Serialize(false, true)]
[InGameEditable, Serialize(false, true, description: "Should the component discard previously received signals when a new one is received.")]
public bool ResetWhenSignalReceived
{
get;
set;
}
[InGameEditable(ToolTip = "Should the component discard previously received signals when the incoming signal changes."), Serialize(false, true)]
[InGameEditable, Serialize(false, true, description: "Should the component discard previously received signals when the incoming signal changes.")]
public bool ResetWhenDifferentSignalReceived
{
get;
@@ -55,13 +68,15 @@ namespace Barotrauma.Items.Components
{
foreach (var val in signalQueue)
{
val.SendTimer -= deltaTime;
val.SendTimer -= 1;
}
while (signalQueue.Count > 0 && signalQueue.Peek().SendTimer <= 0.0f)
while (signalQueue.Count > 0 && signalQueue.Peek().SendTimer <= 0)
{
var signalOut = signalQueue.Dequeue();
var signalOut = signalQueue.Peek();
signalOut.SendDuration -= 1;
item.SendSignal(0, signalOut.Signal, "signal_out", null, signalStrength: signalOut.SignalStrength);
if (signalOut.SendDuration <= 0) { signalQueue.Dequeue(); } else { break; }
}
}
@@ -70,13 +85,28 @@ namespace Barotrauma.Items.Components
switch (connection.Name)
{
case "signal_in":
if (signalQueue.Count >= SignalQueueSize) return;
if (ResetWhenSignalReceived) signalQueue.Clear();
if (signalQueue.Count >= signalQueueSize) { return; }
if (ResetWhenSignalReceived) { prevQueuedSignal = null; signalQueue.Clear(); }
if (ResetWhenDifferentSignalReceived && signalQueue.Count > 0 && signalQueue.Peek().Signal != signal)
{
prevQueuedSignal = null;
signalQueue.Clear();
}
signalQueue.Enqueue(new DelayedSignal(signal, signalStrength, Delay));
if (prevQueuedSignal != null &&
prevQueuedSignal.Signal == signal &&
MathUtils.NearlyEqual(prevQueuedSignal.SignalStrength, signalStrength) &&
((prevQueuedSignal.SendTimer + prevQueuedSignal.SendDuration == delayTicks) || (prevQueuedSignal.SendTimer <= 0 && prevQueuedSignal.SendDuration > 0)))
{
prevQueuedSignal.SendDuration += 1;
return;
}
prevQueuedSignal = new DelayedSignal(signal, signalStrength, delayTicks)
{
SendDuration = 1
};
signalQueue.Enqueue(prevQueuedSignal);
break;
}
}
@@ -15,21 +15,21 @@ namespace Barotrauma.Items.Components
//the output is sent if both inputs have received a signal within the timeframe
protected float timeFrame;
[InGameEditable, Serialize("1", true)]
[InGameEditable, Serialize("1", true, description: "The signal this item outputs when the received signals are equal.")]
public string Output
{
get { return output; }
set { output = value; }
}
[InGameEditable, Serialize("", true)]
[InGameEditable, Serialize("", true, description: "The signal this item outputs when the received signals are not equal.")]
public string FalseOutput
{
get { return falseOutput; }
set { falseOutput = value; }
}
[InGameEditable(DecimalCount = 2), Serialize(0.0f, true)]
[InGameEditable(DecimalCount = 2), Serialize(0.0f, true, description: "The maximum amount of time between the received signals. If set to 0, the signals must be received at the same time.")]
public float TimeFrame
{
get { return timeFrame; }
@@ -25,7 +25,8 @@ namespace Barotrauma.Items.Components
public PhysicsBody ParentBody;
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)]
[Serialize(100.0f, true, description: "The range of the emitted light. Higher values are more performance-intensive."),
Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f)]
public float Range
{
get { return range; }
@@ -40,8 +41,8 @@ namespace Barotrauma.Items.Components
public float Rotation;
[Editable(ToolTip = "Should structures cast shadows when light from this light source hits them. "+
"Disabling shadows increases the performance of the game, and is recommended for lights with a short range."), Serialize(true, true)]
[Editable, Serialize(true, true, description: "Should structures cast shadows when light from this light source hits them. " +
"Disabling shadows increases the performance of the game, and is recommended for lights with a short range.")]
public bool CastShadows
{
get { return castShadows; }
@@ -54,8 +55,8 @@ namespace Barotrauma.Items.Components
}
}
[Editable(ToolTip = "Lights drawn behind submarines don't cast any shadows and are much faster to draw than shadow-casting lights. "+
"It's recommended to enable this on decorative lights outside the submarine's hull."), Serialize(false, true)]
[Editable, Serialize(false, true, description: "Lights drawn behind submarines don't cast any shadows and are much faster to draw than shadow-casting lights. " +
"It's recommended to enable this on decorative lights outside the submarine's hull.")]
public bool DrawBehindSubs
{
get { return drawBehindSubs; }
@@ -68,7 +69,7 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize(false, true)]
[Editable, Serialize(false, true, description: "Is the light currently on.")]
public bool IsOn
{
get { return IsActive; }
@@ -83,7 +84,7 @@ namespace Barotrauma.Items.Components
}
}
[Serialize(0.0f, false)]
[Serialize(0.0f, false, description: "How heavily the light flickers. 0 = no flickering, 1 = the light will alternate between completely dark and full brightness.")]
public float Flicker
{
get { return flicker; }
@@ -93,7 +94,7 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize(0.0f, true)]
[Editable, Serialize(0.0f, true, description: "How rapidly the light blinks on and off (in Hz). 0 = no blinking.")]
public float BlinkFrequency
{
get { return blinkFrequency; }
@@ -103,7 +104,7 @@ namespace Barotrauma.Items.Components
}
}
[InGameEditable, Serialize("1.0,1.0,1.0,1.0", true)]
[InGameEditable, Serialize("255,255,255,255", true, description: "The color of the emitted light (R,G,B,A).")]
public Color LightColor
{
get { return lightColor; }
@@ -4,7 +4,7 @@ namespace Barotrauma.Items.Components
{
class MemoryComponent : ItemComponent
{
[InGameEditable, Serialize("", true)]
[InGameEditable, Serialize("", true, description: "The currently stored signal the item outputs.")]
public string Value
{
get;
@@ -9,32 +9,23 @@ namespace Barotrauma.Items.Components
partial class MotionSensor : ItemComponent
{
private const float UpdateInterval = 0.1f;
private string output, falseOutput;
private bool motionDetected;
private float rangeX, rangeY;
private Vector2 detectOffset;
private float updateTimer;
[Serialize(false, false)]
public bool MotionDetected
{
get { return motionDetected; }
set { motionDetected = value; }
}
[Serialize(false, false, description: "Has the item currently detected movement. Intended to be used by StatusEffect conditionals (setting this value in XML has no effect).")]
public bool MotionDetected { get; set; }
[Serialize(false, true), Editable]
[Editable, Serialize(false, true, description: "Should the sensor only detect the movement of humans?")]
public bool OnlyHumans
{
get;
set;
}
[InGameEditable, Serialize(0.0f, true)]
[InGameEditable, Serialize(0.0f, true, description: "Horizontal detection range.")]
public float RangeX
{
get { return rangeX; }
@@ -43,7 +34,7 @@ namespace Barotrauma.Items.Components
rangeX = MathHelper.Clamp(value, 0.0f, 1000.0f);
}
}
[InGameEditable, Serialize(0.0f, true)]
[InGameEditable, Serialize(0.0f, true, description: "Vertical movement detection range.")]
public float RangeY
{
get { return rangeY; }
@@ -53,7 +44,7 @@ namespace Barotrauma.Items.Components
}
}
[Serialize("0,0", true), Editable(ToolTip = "The position to detect the movement at relative to the item. For example, 0,100 would detect movement 100 units above the item.")]
[Editable, Serialize("0,0", true, description: "The position to detect the movement at relative to the item. For example, 0,100 would detect movement 100 units above the item.")]
public Vector2 DetectOffset
{
get { return detectOffset; }
@@ -65,21 +56,13 @@ namespace Barotrauma.Items.Components
}
}
[InGameEditable, Serialize("1", true)]
public string Output
{
get { return output; }
set { output = value; }
}
[InGameEditable, Serialize("1", true, description: "The signal the item outputs when it has detected movement.")]
public string Output { get; set; }
[InGameEditable, Serialize("", true)]
public string FalseOutput
{
get { return falseOutput; }
set { falseOutput = value; }
}
[InGameEditable, Serialize("", true, description: "The signal the item outputs when it has not detected movement.")]
public string FalseOutput { get; set; }
[Editable(ToolTip = "How fast the objects within the detector's range have to be moving (in m/s).", DecimalCount = 3), Serialize(0.01f, true)]
[Editable(DecimalCount = 3), Serialize(0.01f, true, description: "How fast the objects within the detector's range have to be moving (in m/s).")]
public float MinimumVelocity
{
get;
@@ -88,7 +71,7 @@ namespace Barotrauma.Items.Components
public MotionSensor(Item item, XElement element)
: base (item, element)
: base(item, element)
{
IsActive = true;
@@ -101,21 +84,21 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
string signalOut = motionDetected ? output : falseOutput;
string signalOut = MotionDetected ? Output : FalseOutput;
if (!string.IsNullOrEmpty(signalOut)) item.SendSignal(1, signalOut, "state_out", null);
updateTimer -= deltaTime;
if (updateTimer > 0.0f) return;
motionDetected = false;
MotionDetected = false;
updateTimer = UpdateInterval;
if (item.body != null && item.body.Enabled)
{
if (Math.Abs(item.body.LinearVelocity.X) > MinimumVelocity || Math.Abs(item.body.LinearVelocity.Y) > MinimumVelocity)
{
motionDetected = true;
MotionDetected = true;
}
}
@@ -126,7 +109,7 @@ namespace Barotrauma.Items.Components
foreach (Character c in Character.CharacterList)
{
if (OnlyHumans && c.ConfigPath != Character.HumanConfigFile) { continue; }
if (OnlyHumans && !c.IsHuman) { continue; }
//do a rough check based on the position of the character's collider first
//before the more accurate limb-based check
@@ -140,11 +123,20 @@ namespace Barotrauma.Items.Components
if (limb.LinearVelocity.LengthSquared() <= MinimumVelocity * MinimumVelocity) continue;
if (MathUtils.CircleIntersectsRectangle(limb.WorldPosition, ConvertUnits.ToDisplayUnits(limb.body.GetMaxExtent()), detectRect))
{
motionDetected = true;
MotionDetected = true;
break;
}
}
}
}
public override void FlipX(bool relativeToSub)
{
detectOffset.X = -detectOffset.X;
}
public override void FlipY(bool relativeToSub)
{
detectOffset.Y = -detectOffset.Y;
}
}
}
@@ -20,14 +20,17 @@ namespace Barotrauma.Items.Components
private float phase;
[InGameEditable, Serialize(WaveType.Pulse, true)]
[InGameEditable, Serialize(WaveType.Pulse, true, description: "What kind of a signal the item outputs." +
" Pulse: periodically sends out a signal of 1." +
" Sine: sends out a sine wave oscillating between -1 and 1." +
" Square: sends out a signal that alternates between 0 and 1.")]
public WaveType OutputType
{
get;
set;
}
[InGameEditable(DecimalCount = 2), Serialize(1.0f, true)]
[InGameEditable(DecimalCount = 2), Serialize(1.0f, true, description: "How fast the signal oscillates, or how fast the pulses are sent (in Hz).")]
public float Frequency
{
get { return frequency; }
@@ -16,16 +16,16 @@ namespace Barotrauma.Items.Components
private bool nonContinuousOutputSent;
[InGameEditable, Serialize("1", true)]
[InGameEditable, Serialize("1", true, description: "The signal this item outputs when the received signal matches the regular expression.")]
public string Output { get; set; }
[InGameEditable, Serialize("0", true)]
[Serialize("0", true, description: "The signal this item outputs when the received signal does not match the regular expression.")]
public string FalseOutput { get; set; }
[Serialize(true, true), InGameEditable(ToolTip = "Should the component keep sending the output even after it stops receiving a signal, or only send an output when it receives a signal.")]
[InGameEditable, Serialize(true, true, description: "Should the component keep sending the output even after it stops receiving a signal, or only send an output when it receives a signal.")]
public bool ContinuousOutput { get; set; }
[InGameEditable, Serialize("", true)]
[InGameEditable, Serialize("", true, description: "The regular expression used to check the incoming signals.")]
public string Expression
{
get { return expression; }
@@ -22,7 +22,7 @@ namespace Barotrauma.Items.Components
{ "signal_in5", "signal_out5" }
};
[Editable, Serialize(1000.0f, true)]
[Editable, Serialize(1000.0f, true, description: "The maximum amount of power that can pass through the item.")]
public float MaxPower
{
get { return maxPower; }
@@ -32,7 +32,7 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize(false, true)]
[Editable, Serialize(false, true, description: "Can the relay currently pass power and signals through it.")]
public bool IsOn
{
get
@@ -4,29 +4,13 @@ namespace Barotrauma.Items.Components
{
class SignalCheckComponent : ItemComponent
{
private string output, falseOutput;
[InGameEditable, Serialize("1", true, description: "The signal this item outputs when the received signal matches the target signal.")]
public string Output { get; set; }
[InGameEditable, Serialize("0", true, description: "The signal this item outputs when the received signal does not match the target signal.")]
public string FalseOutput { get; set; }
private string targetSignal;
[InGameEditable, Serialize("1", true)]
public string Output
{
get { return output; }
set { output = value; }
}
[InGameEditable, Serialize("0", true)]
public string FalseOutput
{
get { return falseOutput; }
set { falseOutput = value; }
}
[InGameEditable, Serialize("", true)]
public string TargetSignal
{
get { return targetSignal; }
set { targetSignal = value; }
}
[InGameEditable, Serialize("", true, description: "The value to compare the received signals against.")]
public string TargetSignal { get; set; }
public SignalCheckComponent(Item item, XElement element)
: base(item, element)
@@ -38,17 +22,17 @@ namespace Barotrauma.Items.Components
switch (connection.Name)
{
case "signal_in":
string signalOut = (signal == targetSignal) ? output : falseOutput;
string signalOut = (signal == TargetSignal) ? Output : FalseOutput;
if (string.IsNullOrWhiteSpace(signalOut)) return;
item.SendSignal(stepsTaken, signalOut, "signal_out", sender, signalStrength);
break;
case "set_output":
output = signal;
Output = signal;
break;
case "set_targetsignal":
targetSignal = signal;
TargetSignal = signal;
break;
}
}
@@ -5,7 +5,7 @@ namespace Barotrauma.Items.Components
{
class SmokeDetector : ItemComponent
{
[Serialize(50.0f, false)]
[Serialize(50.0f, false, description: "How large the fire has to be for the detector to react to it.")]
public float FireSizeThreshold
{
get; set;
@@ -4,27 +4,17 @@ namespace Barotrauma.Items.Components
{
class WaterDetector : ItemComponent
{
private string output, falseOutput;
//how often the detector can switch from state to another
const float StateSwitchInterval = 1.0f;
private bool isInWater;
private float stateSwitchDelay;
[InGameEditable, Serialize("1", true)]
public string Output
{
get { return output; }
set { output = value; }
}
[InGameEditable, Serialize("1", true, description: "The signal the item sends out when it's underwater.")]
public string Output { get; set; }
[InGameEditable, Serialize("0", true)]
public string FalseOutput
{
get { return falseOutput; }
set { falseOutput = value; }
}
[InGameEditable, Serialize("0", true, description: "The signal the item sends out when it's not underwater.")]
public string FalseOutput { get; set; }
public WaterDetector(Item item, XElement element)
: base(item, element)
@@ -64,7 +54,7 @@ namespace Barotrauma.Items.Components
}
}
string signalOut = isInWater ? output : falseOutput;
string signalOut = isInWater ? Output : FalseOutput;
if (!string.IsNullOrEmpty(signalOut))
{
item.SendSignal(0, signalOut, "signal_out", null);
@@ -19,17 +19,17 @@ namespace Barotrauma.Items.Components
private string prevSignal;
[Serialize(Character.TeamType.None, false)]
[Serialize(Character.TeamType.None, false, description: "WiFi components can only communicate with components that have the same Team ID.")]
public Character.TeamType TeamID { get; set; }
[Serialize(20000.0f, false)]
[Serialize(20000.0f, false, description: "How close the recipient has to be to receive a signal from this WiFi component.")]
public float Range
{
get { return range; }
set { range = Math.Max(value, 0.0f); }
}
[InGameEditable, Serialize(1, true)]
[InGameEditable, Serialize(1, true, description: "WiFi components can only communicate with components that use the same channel.")]
public int Channel
{
get { return channel; }
@@ -39,25 +39,24 @@ namespace Barotrauma.Items.Components
}
}
[Editable(ToolTip =
"If enabled, any signals received from another chat-linked wifi component are displayed "+
"as chat messages in the chatbox of the player holding the item."), Serialize(false, false)]
[Editable, Serialize(false, false, description: "If enabled, any signals received from another chat-linked wifi component are displayed " +
"as chat messages in the chatbox of the player holding the item.")]
public bool LinkToChat
{
get;
set;
}
[Editable(ToolTip = "How many seconds have to pass between signals for a message to be displayed in the chatbox. "+
"Setting this to a very low value is not recommended, because it may cause an excessive amount of chat messages to be created "+
"if there are chat-linked wifi components that transmit a continuous signal."), Serialize(1.0f, true)]
[Editable, Serialize(1.0f, true, description: "How many seconds have to pass between signals for a message to be displayed in the chatbox. " +
"Setting this to a very low value is not recommended, because it may cause an excessive amount of chat messages to be created " +
"if there are chat-linked wifi components that transmit a continuous signal.")]
public float MinChatMessageInterval
{
get;
set;
}
[Editable(ToolTip = "If set to true, the component will only create chat messages when the received signal changes."), Serialize(false, true)]
[Editable, Serialize(false, true, description: "If set to true, the component will only create chat messages when the received signal changes.")]
public bool DiscardDuplicateChatMessages
{
get;
@@ -55,6 +55,8 @@ namespace Barotrauma.Items.Components
public bool Hidden;
private float removeNodeDelay;
private bool locked;
public bool Locked
{
@@ -71,7 +73,7 @@ namespace Barotrauma.Items.Components
get { return connections; }
}
[Serialize(5000.0f, false)]
[Serialize(5000.0f, false, description: "The maximum distance the wire can extend (in pixels).")]
public float MaxLength
{
get;
@@ -255,17 +257,18 @@ namespace Barotrauma.Items.Components
public override void Drop(Character dropper)
{
ClearConnections(dropper);
ClearConnections(dropper);
IsActive = false;
}
public override void Update(float deltaTime, Camera cam)
{
if (nodes.Count == 0) return;
removeNodeDelay -= deltaTime;
if (nodes.Count == 0) { return; }
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 (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 (Screen.Selected != GameMain.SubEditorScreen)
{
@@ -354,10 +357,12 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (character == null) return false;
#if CLIENT
if (character == Character.Controlled && character.SelectedConstruction != null) return false;
#endif
if (character == null) { return false; }
if (character == Character.Controlled && character.SelectedConstruction != null) { return false; }
if (Screen.Selected == GameMain.SubEditorScreen && !PlayerInput.LeftButtonClicked())
{
return false;
}
if (newNodePos != Vector2.Zero && canPlaceNode && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
{
@@ -384,11 +389,12 @@ namespace Barotrauma.Items.Components
public override bool SecondaryUse(float deltaTime, Character character = null)
{
if (nodes.Count > 1)
if (nodes.Count > 1 && removeNodeDelay <= 0.0f)
{
nodes.RemoveAt(nodes.Count - 1);
UpdateSections();
}
removeNodeDelay = 0.1f;
Drawable = IsActive || sections.Count > 0;
return true;
@@ -668,9 +674,9 @@ namespace Barotrauma.Items.Components
UpdateSections();
}
public override void Load(XElement componentElement)
public override void Load(XElement componentElement, bool usePrefabValues)
{
base.Load(componentElement);
base.Load(componentElement, usePrefabValues);
string nodeString = componentElement.GetAttributeString("nodes", "");
if (nodeString == "") return;