Skip to content

Commit

Permalink
future proofing: generic DLC name matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Aug 25, 2022
1 parent d39393d commit 7c97aa9
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions LoadOrderMod/Patches/ContentManager/IsDLCOwnedPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,32 @@ namespace LoadOrderMod.Patches.ContentManager {
[HarmonyPatch(typeof(SteamHelper), nameof(SteamHelper.IsDLCOwned))]
public static class IsDLCOwnedPatch {
static SteamHelper.DLC[] ExcludedDLCs;

static IEnumerable<SteamHelper.DLC> DLCsStartingWith(string name) {
foreach (SteamHelper.DLC dlc in Enum.GetValues(typeof(SteamHelper.DLC))) {
if (dlc.ToString().StartsWith(name, StringComparison.OrdinalIgnoreCase)) {
yield return dlc;
}
}
}

static void Prepare(MethodBase original) {
Log.Called(original);
if (ExcludedDLCs != null) return;
var dlcs = new List<SteamHelper.DLC>();
foreach(string item in ConfigUtil.Config.ExcludedDLCs) {
if (item == "MusicDLCs") {
dlcs.Add(SteamHelper.DLC.RadioStation1);
dlcs.Add(SteamHelper.DLC.RadioStation2);
dlcs.Add(SteamHelper.DLC.RadioStation3);
dlcs.Add(SteamHelper.DLC.RadioStation4);
dlcs.Add(SteamHelper.DLC.RadioStation5);
dlcs.Add(SteamHelper.DLC.RadioStation6);
dlcs.Add(SteamHelper.DLC.RadioStation7);
dlcs.Add(SteamHelper.DLC.RadioStation9);
dlcs.Add(SteamHelper.DLC.RadioStation10);
dlcs.Add(SteamHelper.DLC.RadioStation11);
var radioDLCs = DLCsStartingWith("RadioStation");
dlcs.AddRange(radioDLCs);
} else if (item == "Football") {
dlcs.Add(SteamHelper.DLC.Football);
dlcs.Add(SteamHelper.DLC.Football2);
dlcs.Add(SteamHelper.DLC.Football3);
dlcs.Add(SteamHelper.DLC.Football4);
dlcs.Add(SteamHelper.DLC.Football5);
dlcs.Add(SteamHelper.DLC.Football2345);
var footballDLCs = DLCsStartingWith("Football");
dlcs.AddRange(footballDLCs);
} else {
dlcs.Add((SteamHelper.DLC)Enum.Parse(typeof(SteamHelper.DLC), item));
}
}
ExcludedDLCs = dlcs.ToArray();
Log.Info($"ExcludedDLCs={ExcludedDLCs.ToSTR()}");
}


Expand Down

0 comments on commit 7c97aa9

Please sign in to comment.