Release v0.15.12.0

This commit is contained in:
Joonas Rikkonen
2021-10-27 18:50:57 +03:00
parent bf95e82d80
commit 234fb6bc06
450 changed files with 26042 additions and 10457 deletions
@@ -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;
}
}