Skip to content

Commit

Permalink
Add HasValidInstrument property to YargProfile (YARC-Official#209)
Browse files Browse the repository at this point in the history
* Add HasValidInstrument property to YargProfile

* Applied PR review changes
Introduced EnsureValidInstrument() to YARG.Core
Applied style change to several one-liner if statements
  • Loading branch information
thomeval authored Sep 14, 2024
1 parent 0e94db8 commit 28f7a93
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions YARG.Core/Game/YargProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using YARG.Core.Chart;
using YARG.Core.Utility;
using YARG.Core.Extensions;
using System.Linq;

namespace YARG.Core.Game
{
Expand Down Expand Up @@ -32,6 +33,8 @@ public double InputCalibrationSeconds
set => InputCalibrationMilliseconds = (long) (value * 1000);
}

public bool HasValidInstrument => GameMode.PossibleInstruments().Contains(CurrentInstrument);

public Guid EnginePreset;

public Guid ThemePreset;
Expand Down Expand Up @@ -175,6 +178,15 @@ public void ApplyVocalModifiers(VocalsPart vocalsPart)
}
}

public void EnsureValidInstrument()
{

if (!HasValidInstrument)
{
CurrentInstrument = GameMode.PossibleInstruments()[0];
}
}

// For replay serialization
public void Serialize(BinaryWriter writer)
{
Expand Down

0 comments on commit 28f7a93

Please sign in to comment.