Unstable 0.1500.0.0

This commit is contained in:
Markus Isberg
2021-08-26 21:08:21 +09:00
parent 265a2e7ab3
commit 501e02c026
245 changed files with 9775 additions and 2034 deletions
@@ -350,6 +350,7 @@ namespace Barotrauma.Items.Components
}
}
}
Connections.Clear();
#if CLIENT
rewireSoundChannel?.FadeOutAndDispose();
@@ -12,8 +12,10 @@ namespace Barotrauma.Items.Components
public enum WaveType
{
Pulse,
Sawtooth,
Sine,
Square,
Triangle,
}
private float frequency;
@@ -22,8 +24,11 @@ namespace Barotrauma.Items.Components
[InGameEditable, Serialize(WaveType.Pulse, true, description: "What kind of a signal the item outputs." +
" Pulse: periodically sends out a signal of 1." +
" Sawtooth: sends out a periodic wave that increases linearly from 0 to 1." +
" Sine: sends out a sine wave oscillating between -1 and 1." +
" Square: sends out a signal that alternates between 0 and 1.", alwaysUseInstanceValues: true)]
" Square: sends out a signal that alternates between 0 and 1." +
" Triangle: sends out a wave that alternates between increasing linearly from -1 to 1 and decreasing from 1 to -1.",
alwaysUseInstanceValues: true)]
public WaveType OutputType
{
get;
@@ -63,6 +68,10 @@ namespace Barotrauma.Items.Components
phase -= pulseInterval;
}
break;
case WaveType.Sawtooth:
phase = (phase + deltaTime * frequency) % 1.0f;
item.SendSignal(phase.ToString(CultureInfo.InvariantCulture), "signal_out");
break;
case WaveType.Square:
phase = (phase + deltaTime * frequency) % 1.0f;
item.SendSignal(phase < 0.5f ? "0" : "1", "signal_out");
@@ -71,6 +80,11 @@ namespace Barotrauma.Items.Components
phase = (phase + deltaTime * frequency) % 1.0f;
item.SendSignal(Math.Sin(phase * MathHelper.TwoPi).ToString(CultureInfo.InvariantCulture), "signal_out");
break;
case WaveType.Triangle:
phase = (phase + deltaTime * frequency) % 1.0f;
float output = 4.0f * MathF.Abs(MathUtils.PositiveModulo(phase - 0.25f, 1.0f) - 0.5f) - 1.0f;
item.SendSignal(output.ToString(CultureInfo.InvariantCulture), "signal_out");
break;
}
}
@@ -85,14 +85,15 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
if (string.IsNullOrWhiteSpace(expression) || regex == null) return;
if (string.IsNullOrWhiteSpace(expression) || regex == null) { return; }
if (!ContinuousOutput && nonContinuousOutputSent) { return; }
if (receivedSignal != previousReceivedSignal && receivedSignal != null)
{
try
{
Match match = regex.Match(receivedSignal);
previousResult = match.Success;
previousResult = match.Success;
previousGroups = UseCaptureGroup && previousResult ? match.Groups : null;
previousReceivedSignal = receivedSignal;
@@ -133,7 +134,7 @@ namespace Barotrauma.Items.Components
{
if (!string.IsNullOrEmpty(signalOut)) { item.SendSignal(signalOut, "signal_out"); }
}
else if (!nonContinuousOutputSent)
else
{
if (!string.IsNullOrEmpty(signalOut)) { item.SendSignal(signalOut, "signal_out"); }
nonContinuousOutputSent = true;
@@ -45,6 +45,9 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize(false, true, description: "The terminal will use a monospace font if this box is ticked.", alwaysUseInstanceValues: true)]
public bool UseMonospaceFont { get; set; }
private string OutputValue { get; set; }
public Terminal(Item item, XElement element)
@@ -100,9 +100,11 @@ namespace Barotrauma.Items.Components
if (item.CurrentHull != null)
{
int waterPercentage = MathHelper.Clamp((int)Math.Round(item.CurrentHull.WaterPercentage), 0, 100);
int waterPercentage = MathHelper.Clamp((int)Math.Ceiling(item.CurrentHull.WaterPercentage), 0, 100);
item.SendSignal(waterPercentage.ToString(), "water_%");
}
string highPressureOut = (item.CurrentHull == null || item.CurrentHull.LethalPressure > 5.0f) ? "1" : "0";
item.SendSignal(highPressureOut, "high_pressure");
}
}
}