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
@@ -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;
}
}