Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FOV Adjust v1.0.0
FovAdjust.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FovAdjust.Patches; using GameNetcodeStuff; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FovAdjust")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FovAdjust")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("dfb6681a-9f25-4737-a7fe-10b3c23f65b3")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FovAdjust { [BepInPlugin("Rozebud.FovAdjust", "FOV Adjust", "1.0.0")] public class RozeModBase : BaseUnityPlugin { private const string modGUID = "Rozebud.FovAdjust"; private const string modName = "FOV Adjust"; private const string modVer = "1.0.0"; private readonly Harmony harmony = new Harmony("Rozebud.FovAdjust"); private static RozeModBase Instance; internal ManualLogSource log; public static ConfigEntry<float> configFov; public static ConfigEntry<bool> configHideVisor; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } log = Logger.CreateLogSource("Rozebud.FovAdjust"); log.LogInfo((object)"Starting."); configFov = ((BaseUnityPlugin)this).Config.Bind<float>("General", "fov", 66f, "Change the field of view of the camera. Clamped from 66 to 130 for my sanity. Also keep in mind that this is vertical FOV."); configHideVisor = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "hideVisor", false, "Changes whether the first person visor is visible."); PlayerControllerBPatches.newTargetFovBase = Mathf.Clamp(configFov.Value, 66f, 130f); PlayerControllerBPatches.hideVisor = configHideVisor.Value; log.LogInfo((object)"Configs DONE!"); harmony.PatchAll(typeof(PlayerControllerBPatches)); log.LogInfo((object)"All FOV Adjust patches have loaded successfully."); } } } namespace FovAdjust.Patches { internal class PlayerControllerBPatches { private static PlayerControllerB playerController; public static float newTargetFovBase = 66f; private static float prefixCamFov = 0f; public static bool hideVisor = false; public static bool jumpStartDelay = false; private static float visorLerpAmount = 0f; private static Vector3 visorScale; [HarmonyPatch(typeof(PlayerControllerB), "Awake")] [HarmonyPostfix] private static void awakePostfix(PlayerControllerB __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) playerController = __instance; if (hideVisor) { __instance.localVisor.localScale = new Vector3(0f, 0f, 0f); } else if (newTargetFovBase > 66f) { visorLerpAmount = (newTargetFovBase - 66f) / 64f; visorLerpAmount = Mathf.Lerp(visorLerpAmount, easeOutSine(visorLerpAmount), 0.7f); visorScale = Vector3.LerpUnclamped(new Vector3(0.66f, 0.82f, 0.95f), new Vector3(0.68f, 0.35f, 0.99f), visorLerpAmount); __instance.localVisor.localScale = visorScale; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void updatePrefix(ref PlayerControllerB __instance) { playerController = __instance; prefixCamFov = playerController.gameplayCamera.fieldOfView; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void updatePostfix() { float num = newTargetFovBase; if (playerController.inTerminalMenu) { num = 60f; } else if (playerController.IsInspectingItem) { num = 46f; } else if (playerController.isSprinting) { num *= 1.03f; } playerController.gameplayCamera.fieldOfView = Mathf.Lerp(prefixCamFov, num, 6f * Time.deltaTime); } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyPostfix] private static void lateUpdatePostfix() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (newTargetFovBase > 66f) { playerController.localVisor.position = playerController.localVisor.position + playerController.localVisor.rotation * new Vector3(0f, 0f, -0.003f); } } private static float easeOutSine(float x) { return Mathf.Sin(x * (float)Math.PI / 2f); } } }