Patch_GameScript_Update.cs 976 B

123456789101112131415161718192021222324252627282930313233343536
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. using UnityEngine;
  4. namespace ScreenshotMode.Patches
  5. {
  6. [HarmonyPatch(typeof(GameScript))]
  7. [HarmonyPatch("Update")]
  8. [HarmonyGadget("ScreenshotMode")]
  9. public static class Patch_GameScript_Update
  10. {
  11. [HarmonyPostfix]
  12. public static void Postfix(GameScript __instance)
  13. {
  14. if (MenuScript.player && GameScript.pausing && Input.GetMouseButtonDown(0))
  15. {
  16. RaycastHit hit;
  17. var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  18. if (Physics.Raycast(ray, out hit, 5f))
  19. {
  20. string name = hit.transform.gameObject.name;
  21. switch (name)
  22. {
  23. case "bScreenshotMode":
  24. __instance.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/bHit"), Menuu.soundLevel / 10f);
  25. Core.state = (Core.state + 1) % 3;
  26. ScreenshotMode.Update();
  27. break;
  28. }
  29. }
  30. }
  31. }
  32. }
  33. }