Patcher.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections.Generic;
  2. using System.Reflection;
  3. using MaidStatus;
  4. using Mono.Cecil;
  5. using NeighPatcher;
  6. using PrivateMaidMode;
  7. namespace AllMaidsInPrivateMode.Patcher
  8. {
  9. public static class Patcher
  10. {
  11. public static readonly string[] TargetAssemblyNames = { "Assembly-CSharp.dll" };
  12. public static void Patch(AssemblyDefinition ad)
  13. {
  14. NeighPatcher.NeighPatcher.PatchAll(ad, "AllMaidsInPrivateMode.Patcher.Hooks");
  15. }
  16. }
  17. public static class Hooks
  18. {
  19. [NeighPatch("Assembly-CSharp", "PrivateMaidMode.PrivateCharaSelectMain", "OnCall")]
  20. public static void OnCreate()
  21. {
  22. var field = typeof(PrivateCharaSelectMain).GetField("<>f__mg$cache0",
  23. BindingFlags.Static | BindingFlags.NonPublic);
  24. field.SetValue(
  25. null, new uGUICharacterSelectManager.CallBackMaidList(uGUICharacterSelectManager.DefaultMaidList));
  26. }
  27. [NeighPatch("Assembly-CSharp", "PrivateMaidMode.PrivateModeMgr", "CreateListData")]
  28. public static void OnCreateListData(ref List<Maid> ___maidList)
  29. {
  30. var characterMgr = GameMain.Instance.CharacterMgr;
  31. for (var i = 0; i < characterMgr.GetStockMaidCount(); i++)
  32. {
  33. var stockMaid = characterMgr.GetStockMaid(i);
  34. var status = stockMaid.status;
  35. if (status.specialRelation != SpecialRelation.Married)
  36. ___maidList.Add(stockMaid);
  37. }
  38. }
  39. }
  40. }