AllProcPropSeqStartPatcher.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Diagnostics.CodeAnalysis;
  3. using HarmonyLib;
  4. namespace MeidoPhotoStudio.Plugin;
  5. public static class AllProcPropSeqStartPatcher
  6. {
  7. public static event EventHandler<ProcStartEventArgs> SequenceStarting;
  8. public static event EventHandler<ProcStartEventArgs> SequenceEnded;
  9. [HarmonyPatch(typeof(Maid), "AllProcPropSeq")]
  10. [HarmonyPrefix]
  11. [SuppressMessage("StyleCop.Analyzers.NamingRules", "SA1313", Justification = "Harmony parameter")]
  12. private static void NotifyAllProcPropStarting(Maid __instance)
  13. {
  14. // TODO: Consider sending a patch to EditBodyLoadFix rather than relying on this brittle hack.
  15. // The check for boModelChg is needed because AllProcProp2Cnt gets reset to 0 before the next phase which causes
  16. // a second false start
  17. if (__instance.AllProcProp2Fase == 0 && __instance.AllProcProp2Cnt == 0 && !__instance.boModelChg)
  18. {
  19. SequenceStarting?.Invoke(null, new(__instance));
  20. if (__instance.GetProp(MPN.head).boDut)
  21. Utility.LogDebug("Face is being initialized");
  22. }
  23. }
  24. [HarmonyPatch(typeof(Maid), "AllProcPropSeq")]
  25. [HarmonyPostfix]
  26. [SuppressMessage("StyleCop.Analyzers.NamingRules", "SA1313", Justification = "Harmony parameter")]
  27. private static void NotifyAllProcPropEnded(Maid __instance)
  28. {
  29. if (__instance.AllProcProp2Fase == 5 && !__instance.IsAllProcPropBusy)
  30. SequenceEnded?.Invoke(null, new(__instance));
  31. }
  32. }