Makes the nuke keypad play a nonatonic scale (#9431)
This commit is contained in:
@@ -54,6 +54,11 @@ namespace Content.Server.Nuke
|
|||||||
[DataField("alertLevelOnActivate")] public string AlertLevelOnActivate = default!;
|
[DataField("alertLevelOnActivate")] public string AlertLevelOnActivate = default!;
|
||||||
[DataField("alertLevelOnDeactivate")] public string AlertLevelOnDeactivate = default!;
|
[DataField("alertLevelOnDeactivate")] public string AlertLevelOnDeactivate = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is stored so we can do a funny by making 0 shift the last played note up by 12 semitones (octave)
|
||||||
|
/// </summary>
|
||||||
|
public int LastPlayedKeypadSemitones = 0;
|
||||||
|
|
||||||
[DataField("keypadPressSound")]
|
[DataField("keypadPressSound")]
|
||||||
public SoundSpecifier KeypadPressSound = new SoundPathSpecifier("/Audio/Machines/Nuke/general_beep.ogg");
|
public SoundSpecifier KeypadPressSound = new SoundPathSpecifier("/Audio/Machines/Nuke/general_beep.ogg");
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ namespace Content.Server.Nuke
|
|||||||
|
|
||||||
private void OnKeypadButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadMessage args)
|
private void OnKeypadButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadMessage args)
|
||||||
{
|
{
|
||||||
PlaySound(uid, component.KeypadPressSound, 0.125f, component);
|
PlayNukeKeypadSound(uid, args.Value, component);
|
||||||
|
|
||||||
if (component.Status != NukeStatus.AWAIT_CODE)
|
if (component.Status != NukeStatus.AWAIT_CODE)
|
||||||
return;
|
return;
|
||||||
@@ -358,6 +358,37 @@ namespace Content.Server.Nuke
|
|||||||
ui.SetState(state);
|
ui.SetState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PlayNukeKeypadSound(EntityUid uid, int number, NukeComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref component))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// This is a C mixolydian blues scale.
|
||||||
|
// 1 2 3 C D Eb
|
||||||
|
// 4 5 6 E F F#
|
||||||
|
// 7 8 9 G A Bb
|
||||||
|
var semitoneShift = number switch
|
||||||
|
{
|
||||||
|
1 => 0,
|
||||||
|
2 => 2,
|
||||||
|
3 => 3,
|
||||||
|
4 => 4,
|
||||||
|
5 => 5,
|
||||||
|
6 => 6,
|
||||||
|
7 => 7,
|
||||||
|
8 => 9,
|
||||||
|
9 => 10,
|
||||||
|
0 => component.LastPlayedKeypadSemitones + 12,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
|
||||||
|
// Don't double-dip on the octave shifting
|
||||||
|
component.LastPlayedKeypadSemitones = number == 0 ? component.LastPlayedKeypadSemitones : semitoneShift;
|
||||||
|
|
||||||
|
SoundSystem.Play(component.KeypadPressSound.GetSound(), Filter.Pvs(uid),
|
||||||
|
AudioHelpers.ShiftSemitone(semitoneShift).WithVolume(-5f));
|
||||||
|
}
|
||||||
|
|
||||||
private void PlaySound(EntityUid uid, SoundSpecifier sound, float varyPitch = 0f,
|
private void PlaySound(EntityUid uid, SoundSpecifier sound, float varyPitch = 0f,
|
||||||
NukeComponent? component = null)
|
NukeComponent? component = null)
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user