CustomCharacteristicsPatch.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using HarmonyLib;
  2. using System.Linq;
  3. using UnityEngine;
  4. namespace SongCore.HarmonyPatches
  5. {
  6. [HarmonyPatch(typeof(BeatmapCharacteristicCollectionSO))]
  7. [HarmonyPatch("GetBeatmapCharacteristicBySerializedName", MethodType.Normal)]
  8. class CustomCharacteristicsPatch
  9. {
  10. // public static OverrideClasses.CustomLevel previouslySelectedSong = null;
  11. static void Postfix(string serializedName, ref BeatmapCharacteristicSO __result)
  12. {
  13. if (__result == null)
  14. {
  15. if (Collections.customCharacteristics.Any(x => x.serializedName == serializedName))
  16. __result = Collections.customCharacteristics.FirstOrDefault(x => x.serializedName == serializedName);
  17. else
  18. __result = Collections.customCharacteristics.FirstOrDefault(x => x.serializedName == "MissingCharacteristic");
  19. }
  20. }
  21. }
  22. /*
  23. [HarmonyPatch(typeof(BeatmapCharacteristicSO))]
  24. [HarmonyPatch("descriptionLocalizationKey", MethodType.Getter)]
  25. class CustomCharacteristicsPatch2
  26. {
  27. // public static OverrideClasses.CustomLevel previouslySelectedSong = null;
  28. static void Postfix(BeatmapCharacteristicSO __instance, ref string __result)
  29. {
  30. if (__result == null)
  31. {
  32. __result = __instance.descriptionLocalizationKey;
  33. }
  34. }
  35. }
  36. [HarmonyPatch(typeof(BeatmapCharacteristicSO))]
  37. [HarmonyPatch("characteristicNameLocalizationKey", MethodType.Getter)]
  38. class CustomCharacteristicsPatch3
  39. {
  40. // public static OverrideClasses.CustomLevel previouslySelectedSong = null;
  41. static void Postfix(BeatmapCharacteristicSO __instance, ref string __result)
  42. {
  43. if (__result == null)
  44. {
  45. __result = __instance.characteristicNameLocalizationKey;
  46. }
  47. }
  48. }
  49. */
  50. }