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 AddFoVSettings v2.0.0
AddFoVSettings.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HG; using HarmonyLib; using Microsoft.CodeAnalysis; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.CameraModes; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AddFoVSettings")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AddFoVSettings")] [assembly: AssemblyTitle("AddFoVSettings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 AddFoVSettings { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Quizzik.AddFoVSettings", "AddFoVSettings", "2.0.0")] public class AddFoVSettingsMain : BaseUnityPlugin { public const string PluginGUID = "Quizzik.AddFoVSettings"; public const string PluginAuthor = "Quizzik"; public const string PluginName = "AddFoVSettings"; public const string PluginVersion = "2.0.0"; private const string RiskOfOptionsGuid = "com.rune580.riskofoptions"; private Harmony _harmony; internal static ConfigEntry<float> BaseFoV { get; private set; } internal static ConfigEntry<bool> SprintingIncreasesFoV { get; private set; } public void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); BaseFoV = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "BaseCameraFoV", 60f, new ConfigDescription("The base camera field of view (vanilla default is 60).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 120f), Array.Empty<object>())); SprintingIncreasesFoV = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "SprintingIncreasesFoV", false, "Enables the vanilla FoV increase while sprinting. Keep disabled to prevent sprint FoV zoom."); BaseFoV.SettingChanged += delegate { CameraFoVPatches.ApplyBaseFoVImmediate(); }; _harmony = Harmony.CreateAndPatchAll(typeof(CameraFoVPatches), "Quizzik.AddFoVSettings"); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { RegisterRiskOfOptions(); } Log.LogInfo(string.Format("{0} {1} initialized (BaseCameraFoV={2}, SprintingIncreasesFoV={3}).", "AddFoVSettings", "2.0.0", BaseFoV.Value, SprintingIncreasesFoV.Value)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void RegisterRiskOfOptions() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown ModSettingsManager.SetModDescription("Adjust base camera field of view and toggle sprint FoV scaling."); TryLoadModIcon(); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(BaseFoV, new StepSliderConfig { name = "Base Camera FoV", min = 50f, max = 120f, increment = 1f, FormatString = "{0:0}" })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(SprintingIncreasesFoV, new CheckBoxConfig { name = "Sprinting Increases FoV" })); Log.LogInfo("Registered settings with Risk Of Options."); } private void TryLoadModIcon() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0068: 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) string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); if (string.IsNullOrEmpty(directoryName)) { return; } string path = Path.Combine(directoryName, "icon.png"); if (File.Exists(path)) { byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, array)) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f))); } } } } [HarmonyPatch] internal static class CameraFoVPatches { private const float VanillaDefaultFoV = 60f; internal static void ApplyBaseFoVImmediate() { float value = AddFoVSettingsMain.BaseFoV.Value; foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList) { if (Object.op_Implicit((Object)(object)readOnlyInstances)) { readOnlyInstances.baseFov = value; } } } [HarmonyPostfix] [HarmonyPatch(typeof(CameraRigController), "OnEnable")] private static void CameraRigController_OnEnable_Postfix(CameraRigController __instance) { __instance.baseFov = AddFoVSettingsMain.BaseFoV.Value; } [HarmonyPostfix] [HarmonyPatch(typeof(CameraTargetParams), "CalcParams")] private static void CameraTargetParams_CalcParams_Postfix(ref CharacterCameraParamsData dest) { float num = AddFoVSettingsMain.BaseFoV.Value / 60f; dest.fov.value *= num; } [HarmonyPrefix] [HarmonyPatch(typeof(CameraModeBase), "Update")] private static void CameraModeBase_Update_Prefix(CameraModeBase __instance, ref CameraModeContext context, out bool __state) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) context.cameraInfo.baseFov = AddFoVSettingsMain.BaseFoV.Value; __state = context.targetInfo.isSprinting; if (AddFoVSettingsMain.SprintingIncreasesFoV.Value || !(__instance is CameraModePlayerBasic)) { return; } context.targetInfo.isSprinting = false; if ((Object)(object)context.cameraInfo.cameraRigController != (Object)null && __instance.camToRawInstanceData != null && __instance.camToRawInstanceData.TryGetValue(UnityObjectWrapperKey<CameraRigController>.op_Implicit(context.cameraInfo.cameraRigController), out var value)) { InstanceData val = (InstanceData)((value is InstanceData) ? value : null); if (val != null) { val.sprintFovMultiplier = 1f; val.sprintFovDampVelocity = 0f; } } } [HarmonyPostfix] [HarmonyPatch(typeof(CameraModeBase), "Update")] private static void CameraModeBase_Update_Postfix(CameraModeBase __instance, ref CameraModeContext context, ref UpdateResult result, bool __state) { context.targetInfo.isSprinting = __state; if (!AddFoVSettingsMain.SprintingIncreasesFoV.Value && __state && __instance is CameraModePlayerBasic) { result.showSprintParticles = true; } } } internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void LogDebug(object data) { _logSource.LogDebug(data); } internal static void LogError(object data) { _logSource.LogError(data); } internal static void LogFatal(object data) { _logSource.LogFatal(data); } internal static void LogInfo(object data) { _logSource.LogInfo(data); } internal static void LogMessage(object data) { _logSource.LogMessage(data); } internal static void LogWarning(object data) { _logSource.LogWarning(data); } } }