using System;
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 BepInEx;
using DarkMachine.UI;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MoreFOV")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+c2c5105120b738e8748bb058c893c2987511c3d6")]
[assembly: AssemblyProduct("MoreFOV")]
[assembly: AssemblyTitle("MoreFOV")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MoreFOV
{
[BepInPlugin("Bryan_-000-.MoreFOV", "MoreFOV", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string GUID = "Bryan_-000-.MoreFOV";
public const string Name = "MoreFOV";
public const string Version = "1.0.1";
public static Harmony Harm { get; internal set; }
}
public void Awake()
{
PluginInfo.Harm = Harmony.CreateAndPatchAll(((object)this).GetType(), "Bryan_-000-.MoreFOV");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UI_SettingsMenu), "Start")]
public static void EditFOV(UI_SettingsMenu __instance)
{
Transform transform = ((Component)__instance).transform;
Transform val = transform.Find("SettingsParent/Settings Pane/Video Settings/Main Panel/Tab - Video/Column - Video/SliderAsset - FOV/Slider");
if (!Object.op_Implicit((Object)(object)val))
{
val = ((IEnumerable<Transform>)((Component)transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform child) => ((Object)child).name.Contains("Slider") && ((Object)child.parent).name.Contains("FOV") && (Object)(object)((Component)child).GetComponent<SubmitSlider>() != (Object)null));
}
SubmitSlider component = ((Component)val).GetComponent<SubmitSlider>();
component.maxValue = 180f;
component.minValue = 0f;
component.value = SettingsManager.settings.playerFOV;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(ENT_Player), "FixedUpdate")]
public static IEnumerable<CodeInstruction> DontClampFOV(IEnumerable<CodeInstruction> instructions)
{
MethodInfo Mathf_Clamp = AccessTools.Method(typeof(Mathf), "Clamp", new Type[3]
{
typeof(float),
typeof(float),
typeof(float)
}, (Type[])null);
FieldInfo Player_curFOV = AccessTools.Field(typeof(ENT_Player), "curFOV");
CodeInstruction[] instructionsArr = instructions.ToArray();
for (int i = 0; i < instructionsArr.Length; i++)
{
CodeInstruction instruction = instructionsArr[i];
if (CodeInstructionExtensions.Calls(instruction, Mathf_Clamp) && CodeInstructionExtensions.Is(instructionsArr[i + 1], OpCodes.Stfld, (MemberInfo)Player_curFOV))
{
yield return new CodeInstruction(OpCodes.Pop, (object)null);
yield return new CodeInstruction(OpCodes.Pop, (object)null);
yield return new CodeInstruction(OpCodes.Ldc_R4, (object)0f);
yield return new CodeInstruction(OpCodes.Ldc_R4, (object)180f);
}
yield return instruction;
}
}
}
}