using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FOVChanger")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adjustable FOV for In Silence")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FOVChanger")]
[assembly: AssemblyTitle("FOVChanger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 FOVChanger
{
[BepInPlugin("com.mrbub.fovchanger", "FOV Changer", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ConfigEntry<float> NormalFOV;
internal static ConfigEntry<float> AimingFOV;
internal static ManualLogSource Log;
private void Awake()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
NormalFOV = ((BaseUnityPlugin)this).Config.Bind<float>("Field of View", "NormalFOV", 90f, new ConfigDescription("Field of view when not aiming. Default: 90", (AcceptableValueBase)(object)new AcceptableValueRange<float>(60f, 120f), Array.Empty<object>()));
AimingFOV = ((BaseUnityPlugin)this).Config.Bind<float>("Field of View", "AimingFOV", 65f, new ConfigDescription("Field of view when aiming down sights. Default: 65", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 90f), Array.Empty<object>()));
((BaseUnityPlugin)this).Logger.LogInfo((object)"FOV Changer v1.0.0 loaded!");
Harmony.CreateAndPatchAll(typeof(WeaponControllerPatch), (string)null);
}
}
[HarmonyPatch(typeof(WeaponController))]
public class WeaponControllerPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void Update_Postfix(WeaponController __instance)
{
FieldInfo field = typeof(WeaponController).GetField("standartFOV", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(WeaponController).GetField("aimFOV", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null && field2 != null)
{
float num = (float)field.GetValue(__instance);
float num2 = (float)field2.GetValue(__instance);
if (Mathf.Abs(num - Plugin.NormalFOV.Value) > 0.1f)
{
field.SetValue(__instance, Plugin.NormalFOV.Value);
}
if (Mathf.Abs(num2 - Plugin.AimingFOV.Value) > 0.1f)
{
field2.SetValue(__instance, Plugin.AimingFOV.Value);
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.mrbub.fovchanger";
public const string PLUGIN_NAME = "FOV Changer";
public const string PLUGIN_VERSION = "1.0.0";
}
}