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 FovUpdate v0.4.1
plugins/com.github.darmuh.FovUpdate.dll
Decompiled 2 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("darmuh")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.1")] [assembly: AssemblyInformationalVersion("0.4.1+33af1114ccd372a195eabd84a7a15255b371a2fc")] [assembly: AssemblyProduct("com.github.darmuh.FovUpdate")] [assembly: AssemblyTitle("FovUpdate")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace FovUpdate { public static class FovConfig { public enum AdjustUI { EnableAllFixes, MinimalFixes, NoFixes } internal static ConfigEntry<bool> DeveloperLogging; internal static ConfigEntry<float> UserDefinedFov; internal static ConfigEntry<float> UserCrouchFov; internal static ConfigEntry<float> UserSprintFov; internal static ConfigEntry<float> MapFov; internal static ConfigEntry<float> MaximumPossibleFov; public static ConfigEntry<bool> EffectsFix; public static ConfigEntry<bool> OnScreenFix; public static ConfigEntry<bool> AspectRatioFix; public static ConfigEntry<AdjustUI> UI_Adjustments; internal static bool ChangingSprintFov; internal static float UpdateSprintConfigItem() { if (UserSprintFov.Value + UserDefinedFov.Value > MaximumPossibleFov.Value) { ChangingSprintFov = true; Plugin.Log.LogMessage((object)$"Sprint FOV + desired FOV exceeds maximum of {MaximumPossibleFov.Value}. Lowering Sprint FOV to maximum acceptable value"); UserSprintFov.Value = Mathf.Clamp(MaximumPossibleFov.Value - UserDefinedFov.Value, 0f, 100f); } ChangingSprintFov = false; return UserSprintFov.Value; } internal static void Init() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown DeveloperLogging = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Debug", "Developer Logging", false, new ConfigDescription("Enable this to see developer logging output", (AcceptableValueBase)null, Array.Empty<object>())); UserDefinedFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "Fov", 70f, new ConfigDescription("Set this to desired Fov value (standard gameplay)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(45f, 140f), Array.Empty<object>())); UserCrouchFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "CrouchFov", 55f, new ConfigDescription("Set this to desired Fov value for when the player is crouched (tumble mode)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(45f, 140f), Array.Empty<object>())); UserSprintFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "SprintFov", 20f, new ConfigDescription("Set this to the desired base modifier for your fov when sprinting.\r\nThis number will be added on to your regular fov when you start sprinting.\r\nDefault in vanilla is 20.\r\nNOTE: If Maximum FOV fix is enabled, this value will be capped based on your base Fov setting to ensure the fov can never exceed the number set via Maximum Possible Fov", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); MapFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "MapFov", 50f, new ConfigDescription("Set this to desired Fov value for when pulling out your map.\nLeave at default value of 50 to let the Effects fix automatically adjust this value based on your base fov", (AcceptableValueBase)(object)new AcceptableValueRange<float>(35f, 140f), Array.Empty<object>())); AspectRatioFix = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Settings", "Aspect-ratio fix on/off", false, "Set this to true to enable compatibility with your monitor's resolution (Ultrawide/Ultralong)"); UI_Adjustments = ((BaseUnityPlugin)Plugin.instance).Config.Bind<AdjustUI>("Settings", "UI Adjustments", AdjustUI.EnableAllFixes, "Allows you to determine how much this mod will touch the UI.\r\nThis setting requires a game restart to be used effectively.\r\nVALUES:\r\nEnableAllFixes - Allow mod full control to adjust UI.\r\nMinimalFixes - This only enables minimal fixes to the UI so that it fills the screen, as done in previous versions of this mod.\r\nNoFixes - No UI fixes will be enabled and the UI will be left untouched completely."); OnScreenFix = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Settings", "OnScreen fix on/off", true, "This setting updates the OnScreen method calculation to account for your prefered FOV when enabled\r\nShould fix some of the more exagerated examples of being able to stare at enemies like the \"Shadow Child\" in the corner of your screen without triggering the looked at effect by using a high fov"); EffectsFix = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Settings", "Effects fix on/off", true, "This setting adjusts the strength of fov effects based on your base fov.\r\nSo if you have a higher fov than standard, the amount you zoom in from enemies or items will be lessened to match a similar zoom distance as with the original default fov"); MaximumPossibleFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "Maximum Possible Fov", 170f, new ConfigDescription("Requires Maximum FOV fix to be enabled\nClamps the fov to never be higher than this number", (AcceptableValueBase)(object)new AcceptableValueRange<float>(150f, 200f), Array.Empty<object>())); } internal static bool FullUIFixesEnabled() { return UI_Adjustments.Value == AdjustUI.EnableAllFixes; } internal static bool MinimalUIFixesEnabled() { return UI_Adjustments.Value != AdjustUI.NoFixes; } } [HarmonyPatch(typeof(CameraZoom), "Awake")] public class CameraPatchThings { public static void Prefix(CameraZoom __instance) { if (!Plugin.AreWeInGame() || (Object)(object)__instance.PlayerController == (Object)null) { return; } Plugin.playerCams.RemoveAll((Camera c) => (Object)(object)c == (Object)null); CollectionExtensions.Do<Camera>((IEnumerable<Camera>)__instance.cams, (Action<Camera>)delegate(Camera x) { Plugin.playerCams.Add(x); Plugin.Spam($"Original Fov of {((Object)x).name} is {x.fieldOfView}"); x.fieldOfView = FovConfig.UserDefinedFov.Value; Plugin.Spam($"Field of view for {((Object)x).name} set to {FovConfig.UserDefinedFov.Value}"); if (FovConfig.AspectRatioFix.Value) { UltraWideSupport.StretchFix(x); } }); __instance.MaximumZoom = FovConfig.MaximumPossibleFov.Value; __instance.zoomPrev = FovConfig.UserDefinedFov.Value; __instance.zoomNew = FovConfig.UserDefinedFov.Value; __instance.zoomCurrent = FovConfig.UserDefinedFov.Value; __instance.playerZoomDefault = FovConfig.UserDefinedFov.Value; __instance.SprintZoom = FovConfig.UpdateSprintConfigItem(); } } [HarmonyPatch(typeof(StatsUI), "Update")] public class HideUpgradeTextFix { public static void Postfix(StatsUI __instance) { if (FovConfig.AspectRatioFix.Value && FovConfig.FullUIFixesEnabled()) { if (((SemiUI)__instance).isHidden && ((Behaviour)__instance.Text).enabled) { ((Behaviour)__instance.Text).enabled = false; } else if (!((SemiUI)__instance).isHidden && !((Behaviour)__instance.Text).enabled) { ((Behaviour)__instance.Text).enabled = true; } } } } [HarmonyPatch(typeof(HealthUI), "Start")] public class GameHUDFix { public static void Prefix(HealthUI __instance) { if (!FovConfig.AspectRatioFix.Value || !FovConfig.FullUIFixesEnabled() || !Plugin.AreWeInGame()) { return; } float ratioModifier = Plugin.GetRatioModifier(); if (ratioModifier != 1f) { Transform parent = ((Component)__instance).transform.parent; RectTransform transform = default(RectTransform); if (((Component)parent).TryGetComponent<RectTransform>(ref transform)) { Plugin.AdjustToDifference(transform, ratioModifier < 1f); } } } } [HarmonyPatch(typeof(SemiUI), "Start")] public class SemiUIPositionFixes { private static TaskCompletionSource<float> ItemHintYTask = new TaskCompletionSource<float>(); public static void Postfix(SemiUI __instance) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) if (!FovConfig.AspectRatioFix.Value || !FovConfig.FullUIFixesEnabled() || !Plugin.AreWeInGame()) { return; } float ratioModifier = Plugin.GetRatioModifier(); if (ratioModifier == 1f) { return; } if (ratioModifier < 1f) { __instance.hidePosition = new Vector2(__instance.hidePosition.x * ratioModifier, __instance.hidePosition.y); __instance.showPosition = new Vector2(__instance.showPosition.x * ratioModifier, __instance.showPosition.y); } if (!(ratioModifier > 1f)) { return; } bool flag = ((Object)((Component)__instance).transform.parent).name == "Shop"; bool flag2 = (Object)(object)((Component)__instance).GetComponent<ItemInfoUI>() != (Object)null; if ((Object)(object)((Component)__instance).GetComponent<ItemInfoExtraUI>() != (Object)null) { GetItemHintY(__instance, ratioModifier); return; } if (flag) { __instance.hidePosition = new Vector2(__instance.hidePosition.x, __instance.hidePosition.y * ratioModifier); __instance.showPosition = new Vector2(__instance.showPosition.x, __instance.showPosition.y / ratioModifier); if (!SemiFunc.IsLevelShop(RunManager.instance.levelCurrent)) { __instance.AllChildrenSetActive(false); } } else { __instance.hidePosition = new Vector2(__instance.hidePosition.x, __instance.hidePosition.y * ratioModifier); __instance.showPosition = new Vector2(__instance.showPosition.x, __instance.showPosition.y * ratioModifier); } if (flag2) { Plugin.Spam($"Setting result for ItemHintYTask to {__instance.showPosition.y}"); ItemHintYTask.TrySetResult(__instance.showPosition.y); } } private static async Task GetItemHintY(SemiUI __instance, float ratio) { if (!ItemHintYTask.Task.IsCompleted) { await ItemHintYTask.Task; } Plugin.Spam("Setting " + ((Object)__instance).name + " new positions!"); __instance.hidePosition = new Vector2(__instance.hidePosition.x, __instance.hidePosition.y * ratio); __instance.showPosition = new Vector2(__instance.showPosition.x, ItemHintYTask.Task.Result + 36f); Plugin.Spam($"Show {__instance.showPosition}, Hide {__instance.hidePosition}"); ItemHintYTask = new TaskCompletionSource<float>(); } } [HarmonyPatch(typeof(VideoOverlay), "Awake")] public class VideoFix { public static void Prefix(VideoOverlay __instance) { if (FovConfig.AspectRatioFix.Value && FovConfig.FullUIFixesEnabled()) { float ratioModifier = Plugin.GetRatioModifier(); RectTransform transform = default(RectTransform); if (ratioModifier != 1f && ((Component)__instance).TryGetComponent<RectTransform>(ref transform)) { Plugin.AdjustToDifference(transform, ratioModifier < 1f); } } } } [HarmonyPatch(typeof(PlayerAvatarMenuHover), "Awake")] public class UnStretchMenuAvatar { public static void Prefix(PlayerAvatarMenuHover __instance) { if (FovConfig.AspectRatioFix.Value) { Transform parent = ((Component)__instance).transform.parent; object obj; if (parent == null) { obj = null; } else { Transform parent2 = parent.parent; obj = ((parent2 != null) ? ((Component)parent2).GetComponent<MenuPageEsc>() : null); } bool updatePos = (Object)obj == (Object)null; RectTransform transform = default(RectTransform); if (((Component)__instance).TryGetComponent<RectTransform>(ref transform)) { Plugin.AdjustToDifference(transform, updatePos); } } } } [HarmonyPatch(typeof(MenuCursor), "Start")] public class MenuCursorSizeFix { public static void Prefix(MenuCursor __instance) { if (FovConfig.AspectRatioFix.Value && FovConfig.FullUIFixesEnabled() && Plugin.GetRatioModifier() != 1f) { Transform child = ((Component)__instance).transform.GetChild(0); RectTransform transform = default(RectTransform); if ((Object)(object)child != (Object)null && ((Component)child).TryGetComponent<RectTransform>(ref transform)) { Plugin.AdjustToDifference(transform, updatePos: false); } } } } [HarmonyPatch(typeof(MenuSelectionBox), "MenuSelectionBoxSetTarget")] public class MenuSelectionFix { public static void Prefix(ref Vector3 scale, ref Vector2 customScale) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (FovConfig.AspectRatioFix.Value && FovConfig.FullUIFixesEnabled()) { float ratioModifier = Plugin.GetRatioModifier(); if (ratioModifier < 1f) { scale = new Vector3(scale.x * ratioModifier, scale.y, scale.z); customScale = new Vector2(customScale.x * ratioModifier, customScale.y); } if (ratioModifier > 1f) { scale = new Vector3(scale.x, scale.y / ratioModifier, scale.z); customScale = new Vector2(customScale.x, customScale.y / ratioModifier); } } } } [HarmonyPatch(typeof(MenuPageCosmetics), "Start")] public class CosmeticsPageFixes { public static void Postfix(MenuPageCosmetics __instance) { if (FovConfig.AspectRatioFix.Value && FovConfig.FullUIFixesEnabled()) { float ratioModifier = Plugin.GetRatioModifier(); if (ratioModifier != 1f) { AdjustCosmeticCategoryButtons(__instance.categoriesTransform.parent, __instance.categoriesHolder, ratioModifier); AdjustCosmeticCategoryButtons(__instance.subCategoriesTransform.parent, __instance.subCategoriesHolder, ratioModifier); } } } private static void AdjustCosmeticCategoryButtons(Transform maskTransform, MenuElementCosmeticCategoryScroll holder, float ratioMod) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) RectMask2D val = default(RectMask2D); if (!((Component)maskTransform).TryGetComponent<RectMask2D>(ref val)) { return; } val.padding = new Vector4(-10f, val.padding.y, val.padding.z, val.padding.w); Plugin.Spam("Attempting to fix customize menu category arrow buttons"); Plugin.Spam("Get World Corners:"); Vector3[] array = (Vector3[])(object)new Vector3[4]; val.rectTransform.GetWorldCorners(array); for (int i = 0; i < array.Length; i++) { Plugin.Spam($"{array[i]}"); } RectTransform val2 = default(RectTransform); if (holder.buttonLeft.TryGetComponent<RectTransform>(ref val2)) { float x = array[0].x; float y = ((Transform)val2).position.y; if (ratioMod < 1f) { x -= val2.sizeDelta.x * ratioMod + 5f; } else { x -= val2.sizeDelta.x - 20f; y = array[0].y; } Plugin.Spam($"Left Corner Position of mask with resolution offset for button - {x}, {y}"); ((Transform)val2).position = new Vector3(x, y, ((Transform)val2).position.z); } RectTransform val3 = default(RectTransform); if (holder.buttonRight.TryGetComponent<RectTransform>(ref val3)) { float x2 = array[3].x; float y2 = ((Transform)val3).position.y; if (ratioMod > 1f) { y2 = array[3].y; } Plugin.Spam($"Right button placed at right corner of mask {x2}, {y2}"); ((Transform)val3).position = new Vector3(x2, y2, ((Transform)val3).position.z); } if (ratioMod > 1f) { holder.menuPageCosmetics.topDividerRestingPositionStart = new Vector2(holder.menuPageCosmetics.topDividerRestingPositionStart.x, holder.menuPageCosmetics.topDividerRestingPositionStart.y / ratioMod); holder.menuPageCosmetics.topDividerRestingPositionCurrent = new Vector2(holder.menuPageCosmetics.topDividerRestingPositionCurrent.x, holder.menuPageCosmetics.topDividerRestingPositionCurrent.y / ratioMod); holder.menuPageCosmetics.topDividerRestingPositionEnd = new Vector2(holder.menuPageCosmetics.topDividerRestingPositionEnd.x, holder.menuPageCosmetics.topDividerRestingPositionEnd.y / ratioMod); holder.menuPageCosmetics.topDividerRestingPositionEndNew = new Vector2(holder.menuPageCosmetics.topDividerRestingPositionEndNew.x, holder.menuPageCosmetics.topDividerRestingPositionEndNew.y / ratioMod); } } } [HarmonyPatch(typeof(MenuPageCosmetics), "RefreshScrollContent")] public class CustomizePageTallFix { public static void Postfix(MenuPageCosmetics __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (FovConfig.AspectRatioFix.Value && FovConfig.FullUIFixesEnabled()) { float ratioModifier = Plugin.GetRatioModifier(); if (!(ratioModifier <= 1f)) { __instance.topDividerRestingPositionEndNew = new Vector2(__instance.topDividerRestingPositionEnd.x, __instance.topDividerRestingPositionEndNew.y / ratioModifier); } } } } [HarmonyPatch(typeof(MenuPage), "Start")] public class MenuPagesFix { private static readonly List<string> DontTouch = new List<string>(4) { "Background", "Panel Back", "Panel", "Bool Setting - " }; public static void Prefix(MenuPage __instance) { if (!FovConfig.AspectRatioFix.Value || !FovConfig.FullUIFixesEnabled()) { return; } float ratioModifier = Plugin.GetRatioModifier(); if (ratioModifier == 1f || (Object)(object)((Component)__instance).gameObject.GetComponent<MenuPagePassword>() != (Object)null) { return; } bool flag = (Object)(object)((Component)__instance).gameObject.GetComponent<MenuPageEsc>() != (Object)null; bool flag2 = (Object)(object)((Component)__instance).gameObject.GetComponent<MenuPageLobby>() != (Object)null; Plugin.Spam($"escMenu - {flag}, lobbyMenu - {flag2}"); RectTransform transform = default(RectTransform); for (int i = 0; i < ((Component)__instance).transform.childCount; i++) { bool updatePos = ratioModifier != 1f; Transform child = ((Component)__instance).transform.GetChild(i); if (((Component)child).TryGetComponent<RectTransform>(ref transform) && !DontTouch.Contains(((Object)child).name)) { if (flag) { updatePos = false; } if (flag2) { updatePos = ((Object)child).name == "Gradient"; } Plugin.AdjustToDifference(transform, updatePos); } } } } [HarmonyPatch(typeof(RenderTextureMain), "Start")] public class RenderTextureMainOverrides { public static void Postfix(RenderTextureMain __instance) { if (FovConfig.AspectRatioFix.Value) { __instance.textureWidthLarge = (float)Screen.width * 0.78f; __instance.textureWidthMedium = (float)Screen.width * 0.58f; __instance.textureWidthSmall = (float)Screen.width * 0.39f; __instance.textureHeightLarge = (float)Screen.height * 0.77f; __instance.textureHeightMedium = (float)Screen.height * 0.58f; __instance.textureHeightSmall = (float)Screen.height * 0.38f; GraphicsManager.instance.UpdateRenderSize(); } } } [HarmonyPatch(typeof(GraphicsManager), "UpdateRenderSize")] public class CatchNoPixelationSetting { public static bool Prefix() { int num = DataDirector.instance.SettingValueFetch((Setting)25); if (num != 99) { Plugin.Spam($"Non-controlled pixelation setting set! ({num})"); return true; } Plugin.Spam($"Controlled pixelation setting being set! ({num})"); UseNonePixelation(); return false; } internal static void UseNonePixelation() { Plugin.Spam("Setting pixelation to None!"); RenderTextureMain.instance.textureWidthOriginal = Screen.width; RenderTextureMain.instance.textureHeightOriginal = Screen.height; RenderTextureMain.instance.ResetResolution(); } } [HarmonyPatch(typeof(MenuSlider), "Awake")] public class InsertPixelationSetting { [CompilerGenerated] private static class <>O { public static UnityAction <0>__SetNone; } private static readonly UnityEvent Nopixel = new UnityEvent(); private static MenuSlider? PixelSlider { get; set; } = null; private static CustomOption? NoneOption { get; set; } = null; public static void Prefix(MenuSlider __instance) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown if (__instance.elementName != "Pixelation") { return; } PixelSlider = __instance; PixelSlider.wrapAround = true; if (NoneOption == null) { NoneOption = new CustomOption { customOptionText = "None", localizedCustomOptionText = null, onOption = Nopixel }; } NoneOption.customValueInt = 99; if (!PixelSlider.customOptions.Contains(NoneOption)) { ((UnityEventBase)Nopixel).RemoveAllListeners(); PixelSlider.customOptions.Add(NoneOption); PixelSlider.settingSegments = Mathf.Max(PixelSlider.customOptions.Count - 1, 1); PixelSlider.startValue = 0; PixelSlider.endValue = PixelSlider.customOptions.Count - 1; UnityEvent nopixel = Nopixel; object obj = <>O.<0>__SetNone; if (obj == null) { UnityAction val = SetNone; <>O.<0>__SetNone = val; obj = (object)val; } nopixel.AddListener((UnityAction)obj); PixelSlider.SetBar((float)PixelSlider.GetIndexFromCustomValue(DataDirector.instance.SettingValueFetch((Setting)25) / PixelSlider.endValue)); Plugin.Spam("Inserted 'none' Pixelation setting!"); } } private static void SetNone() { Plugin.Log.LogMessage((object)"Pixelation set to [NONE] by FovUpdate"); GraphicsManager.instance.UpdateRenderSize(); } } [HarmonyPatch(typeof(GraphicsManager), "Update")] public class UltraWideSupport { public enum ScreenStatus { Default, Wide, Tall } internal static ScreenStatus ScreenIs = ScreenStatus.Default; internal static float previousAspectRatio; internal static float currentAspectRatio; public static readonly float defaultAspectRatio = 1.7777778f; internal static List<RectTransform> Rects = new List<RectTransform>(); public static void Postfix(GraphicsManager __instance) { if (!FovConfig.AspectRatioFix.Value || __instance.fullscreenCheckTimer > 0f) { return; } Rects.RemoveAll((RectTransform r) => (Object)(object)r == (Object)null); bool flag = false; if (Rects.Count == 0) { if (!FovConfig.MinimalUIFixesEnabled()) { Rects = new List<RectTransform>(1) { ((Component)RenderTextureMain.instance).gameObject.GetComponent<RectTransform>() }; } else { Rects = ((Component)RenderTextureMain.instance).gameObject.GetComponentsInChildren<RectTransform>().ToList(); } flag = true; } currentAspectRatio = (float)Screen.width / (float)Screen.height; if (previousAspectRatio == currentAspectRatio && !flag) { return; } if (currentAspectRatio > defaultAspectRatio) { CollectionExtensions.Do<RectTransform>((IEnumerable<RectTransform>)Rects, (Action<RectTransform>)delegate(RectTransform r) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) r.sizeDelta = new Vector2(428f * currentAspectRatio, 428f); }); ScreenIs = ScreenStatus.Wide; Plugin.Spam("Updating Aspect Ratio for ultrawide support!"); } else if (currentAspectRatio == defaultAspectRatio) { CollectionExtensions.Do<RectTransform>((IEnumerable<RectTransform>)Rects, (Action<RectTransform>)delegate(RectTransform r) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) r.sizeDelta = new Vector2(750f, 750f / currentAspectRatio); }); ScreenIs = ScreenStatus.Default; Plugin.Spam("Updating Aspect Ratio to default!"); } else { CollectionExtensions.Do<RectTransform>((IEnumerable<RectTransform>)Rects, (Action<RectTransform>)delegate(RectTransform r) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) r.sizeDelta = new Vector2(750f, 750f / currentAspectRatio); }); ScreenIs = ScreenStatus.Tall; Plugin.Spam("Updating Aspect Ratio for ultratall support!"); } Plugin.UpdateCams(); CollectionExtensions.Do<Camera>((IEnumerable<Camera>)Plugin.playerCams, (Action<Camera>)delegate(Camera c) { StretchFix(c); }); previousAspectRatio = currentAspectRatio; } public static void StretchFix(Camera cam) { if (FovConfig.AspectRatioFix.Value && !((Object)(object)cam == (Object)null)) { currentAspectRatio = (float)Screen.width / (float)Screen.height; cam.aspect = currentAspectRatio; Plugin.Spam($"{((Object)cam).name} aspect ratio set to {cam.aspect}"); } } } [HarmonyPatch(typeof(PlayerAvatar), "SpawnRPC")] public class SpawnPlayerStuff { public static void Postfix(PlayerAvatar __instance) { if (!Plugin.AreWeInGame() || !__instance.photonView.IsMine) { return; } if (Camera.main.fieldOfView == FovConfig.UserDefinedFov.Value) { Plugin.Log.LogMessage((object)"@SpawnPatch: Fov already set to correct value"); return; } ((MonoBehaviour)PlayerAvatar.instance).StartCoroutine(ChatCommandHandler.ForceFovZoomCurve(FovConfig.UserDefinedFov.Value, ((Component)PlayerAvatar.instance).gameObject)); Plugin.Log.LogMessage((object)$"@SpawnPatch: Fov set to number [ {FovConfig.UserDefinedFov.Value} ]"); if (!((Object)(object)CameraZoom.Instance == (Object)null)) { CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem(); Plugin.Log.LogMessage((object)$"@SpawnPatch: SprintFov set to number [ {CameraZoom.Instance.SprintZoom} ]"); } } } [HarmonyPatch(typeof(SemiFunc), "OnSceneSwitch")] public class LeaveToMainReset { public static void Postfix() { if (UltraWideSupport.ScreenIs != UltraWideSupport.ScreenStatus.Default) { Plugin.UpdateCams(); CollectionExtensions.Do<Camera>((IEnumerable<Camera>)Plugin.playerCams, (Action<Camera>)delegate(Camera x) { UltraWideSupport.StretchFix(x); }); } } } [HarmonyPatch(typeof(CameraZoom), "OverrideZoomSet")] public class EffectsFix { public static void Prefix(ref float zoom) { bool cont = true; if (!ChatCommandHandler.changingFov && !MapAndConfigCheck(ref zoom, ref cont) && !TumbleCheck()) { if (cont) { float num = 70f / FovConfig.UserDefinedFov.Value; zoom /= num; } Plugin.Spam($"zoom set to {zoom}\n Adjusted: {cont}"); } } private static bool MapAndConfigCheck(ref float value, ref bool cont) { if ((Object)(object)Map.Instance != (Object)null && FovConfig.MapFov.Value != 50f && Map.Instance.Active) { Plugin.Spam("Adjusting mapfov!"); value = FovConfig.MapFov.Value; cont = false; return false; } return !FovConfig.EffectsFix.Value; } private static bool TumbleCheck() { if ((Object)(object)PlayerAvatar.instance == (Object)null || (Object)(object)PlayerController.instance == (Object)null) { return false; } if ((Object)(object)PlayerAvatar.instance.tumble == (Object)null) { return false; } if (PlayerAvatar.instance.tumble.isTumbling) { return PlayerController.instance.InputDisableTimer <= 0f; } return false; } } [HarmonyPatch(typeof(SemiFunc), "OnScreen")] public class AdjustOnScreenBool { public static void Prefix(ref float paddWidth, ref float paddHeight) { if (Plugin.AreWeInGame() && FovConfig.OnScreenFix.Value) { float num = FovConfig.UserDefinedFov.Value / 70f; paddHeight /= num; paddWidth /= num; } } } [HarmonyPatch(typeof(PlayerTumble), "Update")] [HarmonyPriority(0)] public class TumbleAdjustment { private static int replacements; [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TumbleAdjustment_Transpiler(IEnumerable<CodeInstruction> instructions) { Plugin.Log.LogMessage((object)"TumbleAdjustment Transpiler Initialized"); replacements = 0; return Transpilers.Manipulator(instructions, (Func<CodeInstruction, bool>)((CodeInstruction x) => ChangeThisFloat(x, 55f)), (Action<CodeInstruction>)NewInstruction); } internal static void NewInstruction(CodeInstruction instruction) { CodeInstruction val = Transpilers.EmitDelegate<Func<float>>((Func<float>)OverrideZoomSpecial); instruction.opcode = val.opcode; instruction.operand = val.operand; replacements++; Plugin.Log.LogMessage((object)$"TumbleAdjustment patched crouchfov config!\n[ {replacements} ] lines changed"); } internal static bool ChangeThisFloat(CodeInstruction instruction, float expectedValue) { if (instruction.opcode != OpCodes.Ldc_R4) { return false; } if (!float.TryParse(instruction.operand.ToString(), out var result)) { return false; } if (result != expectedValue) { return false; } return true; } internal static float OverrideZoomSpecial() { return FovConfig.UserCrouchFov.Value; } } [HarmonyPatch(typeof(ChatManager), "MessageSend")] public class ChatCommandHandler { private static string lastMsg = ":o"; internal static bool changingFov = false; public static bool Prefix(ChatManager __instance) { if (__instance.chatMessage == lastMsg) { return true; } Plugin.Spam("Reading chat message - " + __instance.chatMessage); lastMsg = __instance.chatMessage; if (__instance.chatMessage.StartsWith("/fov")) { __instance.AddLetterToChat(" " + HandleFovChange(__instance.chatMessage)); } else if (__instance.chatMessage.StartsWith("/cfov")) { __instance.AddLetterToChat(" " + HandleCrouchFovChange(__instance.chatMessage)); } else if (__instance.chatMessage.StartsWith("/sfov")) { __instance.AddLetterToChat(" " + HandleSprintFovChange(__instance.chatMessage)); } return true; } internal static string HandleSprintFovChange(string message) { string[] array = message.Split(' '); if (array.Length == 1) { Plugin.Log.LogMessage((object)("Invalid sprint fov message format given - [ " + message + " ]")); return "No number specified for /sfov!"; } string text = array[1]; if (float.TryParse(text, out var result)) { if (result < 0f || result > 100f) { return $"Unable to set sprint fov to {result} (out of range)"; } FovConfig.UserSprintFov.Value = result; CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem(); Plugin.Log.LogMessage((object)$"SprintFov set to number [ {CameraZoom.Instance.SprintZoom} ]"); return "Sprint fov updated"; } Plugin.Log.LogMessage((object)("Unable to parse value from " + text + "!")); return "Unable to parse value from " + text + "!"; } internal static string HandleCrouchFovChange(string message) { if (CameraZoom.Instance.OverrideActive && !PlayerAvatar.instance.tumble.isTumbling) { Plugin.Log.LogMessage((object)"Unable to update crouch fov, camera OverrideActive is true! (not tumbling)"); lastMsg = ""; return "Unable to change crouch fov, overriden by outside entity!"; } string[] array = message.Split(' '); if (array.Length == 1) { Plugin.Log.LogMessage((object)("Invalid crouch fov message format given - [ " + message + " ]")); return "No number specified for /cfov!"; } string text = array[1]; if (float.TryParse(text, out var result)) { if (result < 45f || result > 140f) { return $"Unable to set crouch fov to {result} (out of range)"; } if (PlayerAvatar.instance.isTumbling) { ((MonoBehaviour)ChatManager.instance).StartCoroutine(ForceFovZoomCurve(result, ((Component)PlayerAvatar.instance.tumble).gameObject, updateDef: false)); } FovConfig.UserCrouchFov.Value = result; Plugin.Log.LogMessage((object)$"CrouchFov set to number [ {result} ]"); return $"crouch fov set to {result}"; } Plugin.Log.LogMessage((object)("Unable to parse value from " + text + "!")); return "Unable to parse value from " + text + "!"; } internal static string HandleFovChange(string message) { if (CameraZoom.Instance.OverrideActive && !PlayerAvatar.instance.isTumbling) { Plugin.Log.LogMessage((object)"Unable to update fov, camera OverrideActive is true!"); lastMsg = ""; return "Unable to change fov, camera is overriden!"; } string[] array = message.Split(' '); if (array.Length == 1) { Plugin.Log.LogMessage((object)("Invalid fov message format given - [ " + message + " ]")); return "No number specified for /fov!"; } string text = array[1]; if (float.TryParse(text, out var result)) { if (result < 45f || result > 140f) { return $"Unable to set fov to {result} (out of range)"; } if (PlayerAvatar.instance.isTumbling) { CameraZoom.Instance.playerZoomDefault = result; FovConfig.UserDefinedFov.Value = result; CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem(); return $"fov will be {result} when you get up"; } ((MonoBehaviour)ChatManager.instance).StartCoroutine(ForceFovZoomCurve(result, ((Component)PlayerAvatar.instance).gameObject)); FovConfig.UserDefinedFov.Value = result; Plugin.Log.LogMessage((object)$"Fov set to number [ {result} ]"); CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem(); return $"fov set to {result}"; } Plugin.Log.LogMessage((object)("Unable to parse value from " + text + "!")); return "Unable to parse value from " + text + "!"; } internal static IEnumerator ForceFovZoomCurve(float newFov, GameObject obj = null, bool updateDef = true) { if (!((Object)(object)PlayerAvatar.instance == (Object)null) && !changingFov) { GameObject overrideObj = (GameObject)((!((Object)(object)obj == (Object)null)) ? ((object)obj) : ((object)PlayerController.instance.playerAvatar.gameObject)); changingFov = true; CameraZoom.Instance.zoomPrev = CameraZoom.Instance.zoomCurrent; CameraZoom.Instance.OverrideZoomSet(newFov, 2f, 1f, 1f, obj, 150); while ((double)Mathf.Abs(CameraZoom.Instance.zoomCurrent - newFov) > 0.25 && (Object)(object)CameraZoom.Instance.OverrideZoomObject == (Object)(object)overrideObj) { yield return null; } if (updateDef) { CameraZoom.Instance.playerZoomDefault = newFov; } changingFov = false; if (!((Object)(object)CameraZoom.Instance.OverrideZoomObject != (Object)(object)obj)) { CameraZoom.Instance.OverrideActive = false; CameraZoom.Instance.OverrideZoomObject = null; CameraZoom.Instance.OverrideZoomPriority = 999; CameraZoom.Instance.OverrideZoomSpeedIn = 1f; CameraZoom.Instance.OverrideZoomSpeedOut = 1f; } } } } [BepInPlugin("com.github.darmuh.FovUpdate", "FovUpdate", "0.4.1")] public class Plugin : BaseUnityPlugin { internal static Plugin instance = null; internal static ManualLogSource Log = null; internal static List<Camera> playerCams = new List<Camera>(); public const string Id = "com.github.darmuh.FovUpdate"; public static string Name => "FovUpdate"; public static string Version => "0.4.1"; private void Awake() { instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)(Name + " is loading with version " + Version + "!")); FovConfig.Init(); ((BaseUnityPlugin)instance).Config.SettingChanged += OnSettingChanged; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); Log.LogInfo((object)(Name + " load complete!")); Log.LogInfo((object)"This version of the mod has been compiled for REPO version 0.4.4.3 (Cosmetic Update & More)\nEnjoy! :3"); } private void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg) { Spam("CONFIG SETTING CHANGE EVENT"); if (settingChangedArg.ChangedSetting == null || (Object)(object)CameraZoom.Instance == (Object)null) { return; } if ((object)settingChangedArg.ChangedSetting == FovConfig.DeveloperLogging || (object)settingChangedArg.ChangedSetting == FovConfig.AspectRatioFix) { Log.LogDebug((object)$"{settingChangedArg.ChangedSetting.Definition.Key} is enabled [ {(bool)settingChangedArg.ChangedSetting.BoxedValue} ]"); } if ((object)settingChangedArg.ChangedSetting == FovConfig.UserSprintFov && !FovConfig.ChangingSprintFov) { CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem(); Spam($"SprintFov updated to {CameraZoom.Instance.SprintZoom}"); } if ((object)settingChangedArg.ChangedSetting == FovConfig.UserDefinedFov) { if (!CameraZoom.Instance.OverrideActive && (Object)(object)CameraNoPlayerTarget.instance == (Object)null) { ((MonoBehaviour)PlayerAvatar.instance).StartCoroutine(ChatCommandHandler.ForceFovZoomCurve((float)settingChangedArg.ChangedSetting.BoxedValue, ((Component)PlayerAvatar.instance).gameObject)); } else { CameraZoom.Instance.playerZoomDefault = FovConfig.UserDefinedFov.Value; } CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem(); Spam($"Fov updated to {(float)settingChangedArg.ChangedSetting.BoxedValue}"); } if ((object)settingChangedArg.ChangedSetting == FovConfig.UserCrouchFov) { if ((Object)(object)PlayerAvatar.instance == (Object)null || (Object)(object)PlayerAvatar.instance.tumble == (Object)null) { return; } if (CameraZoom.Instance.OverrideActive && PlayerAvatar.instance.tumble.isTumbling) { ((MonoBehaviour)PlayerAvatar.instance).StartCoroutine(ChatCommandHandler.ForceFovZoomCurve((float)settingChangedArg.ChangedSetting.BoxedValue, ((Component)PlayerAvatar.instance.tumble).gameObject, updateDef: false)); } Spam($"CrouchFov updated to {(float)settingChangedArg.ChangedSetting.BoxedValue}"); } if ((object)settingChangedArg.ChangedSetting == FovConfig.UI_Adjustments) { UltraWideSupport.Rects = new List<RectTransform>(); } } internal static void UpdateCams() { if (!((Object)(object)CameraZoom.Instance == (Object)null)) { playerCams.RemoveAll((Camera c) => (Object)(object)c == (Object)null); CollectionExtensions.DoIf<Camera>((IEnumerable<Camera>)CameraZoom.Instance.cams, (Func<Camera, bool>)((Camera c) => !playerCams.Contains(c)), (Action<Camera>)delegate(Camera c) { playerCams.Add(c); }); } } private static void TestUltraWide() { SetWindowRes(1720, 720); } private static void Test1610() { SetWindowRes(1280, 800); } private static void TestMobileRes() { SetWindowRes(720, 1280); } private static void ReloadScene() { RunManager.instance.RestartScene(); } internal static void SetWindowRes(int width, int height) { Screen.SetResolution(width, height, false); } internal static float GetRatioModifier() { return UltraWideSupport.defaultAspectRatio / UltraWideSupport.currentAspectRatio; } internal static void AdjustToDifference(RectTransform transform, bool updatePos = true) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Spam($"AdjustToDifference {((Object)transform).name}, updatePos = {updatePos}"); float x = ((Transform)transform).localScale.x; float y = ((Transform)transform).localScale.y; float z = ((Transform)transform).localScale.z; float ratioModifier = GetRatioModifier(); if (ratioModifier < 1f) { if (x <= 0f) { return; } ((Transform)transform).localScale = new Vector3(x * ratioModifier, y, z); if (updatePos) { transform.anchoredPosition = new Vector2(transform.anchoredPosition.x * ratioModifier, transform.anchoredPosition.y); } } if (ratioModifier > 1f && !(y <= 0f)) { ((Transform)transform).localScale = new Vector3(x, y / ratioModifier, z); if (updatePos) { transform.anchoredPosition = new Vector2(transform.anchoredPosition.x, transform.anchoredPosition.y / ratioModifier); } Spam($"Position: {transform.anchoredPosition}"); } } internal static bool AreWeInGame() { return !SemiFunc.MenuLevel(); } internal static void Spam(string message) { if (FovConfig.DeveloperLogging.Value) { Log.LogDebug((object)message); } } internal static void ERROR(string message) { Log.LogError((object)message); } internal static void WARNING(string message) { Log.LogWarning((object)message); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }