Patch_CameraScript_Update.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. using UnityEngine;
  4. namespace ShipDecorations.Patches
  5. {
  6. [HarmonyPatch(typeof(CameraScript))]
  7. [HarmonyPatch("Update")]
  8. [HarmonyGadget("ShipDecorations")]
  9. public static class Patch_CameraScript_Update
  10. {
  11. [HarmonyPrefix]
  12. public static bool Prefix(CameraScript __instance, Transform ___t, Transform ___player, bool ___deathCamera, int ___dLimit)
  13. {
  14. var offset = -50f;
  15. var smoothing = 100;
  16. if (!___player)
  17. ___t.rotation = Quaternion.EulerAngles(0, 0, 0);
  18. else
  19. ___t.rotation = Quaternion.EulerAngles(0.2f, 0.2f, 0);
  20. if (!___player)
  21. {
  22. ___t.position = new Vector3(0f, 0f, -8f);
  23. }
  24. else if (___deathCamera)
  25. {
  26. ___t.position = Vector3.Lerp(___t.position, new Vector3(___player.position.x, ___player.position.y + 2f, offset), 5f * Time.smoothDeltaTime * smoothing);
  27. }
  28. else if (GameScript.dead)
  29. {
  30. Vector3 b = new Vector3(___player.position.x, ___player.position.y, offset);
  31. ___dLimit = -24;
  32. ___t.position = Vector3.Lerp(___t.position, b, 5f * Time.smoothDeltaTime * smoothing);
  33. }
  34. else if (!GameScript.inventoryOpen && !GameScript.pausing)
  35. {
  36. if (!GameScript.combatMode)
  37. {
  38. if (GameScript.buildMode)
  39. {
  40. ___dLimit = 20;
  41. }
  42. else
  43. {
  44. ___dLimit = 1;
  45. }
  46. }
  47. else if (GameScript.dead)
  48. {
  49. ___dLimit = 15;
  50. }
  51. else
  52. {
  53. ___dLimit = 7;
  54. }
  55. Vector3 b2 = new Vector3(___player.position.x - 10f, ___player.position.y + 10f, offset);
  56. ___t.position = Vector3.Lerp(___t.position, b2, 5f * Time.smoothDeltaTime * smoothing);
  57. }
  58. else
  59. {
  60. ___t.position = Vector3.Lerp(___t.position, new Vector3(___player.position.x - 10f, ___player.position.y + 10f, offset), 5f * Time.smoothDeltaTime * smoothing);
  61. }
  62. return false;
  63. }
  64. }
  65. }