using 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.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ViewmodelFOV")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ViewmodelFOV")]
[assembly: AssemblyTitle("ViewmodelFOV")]
[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 ViewmodelFOV
{
[BepInPlugin("ViewmodelFOV", "Viewmodel FOV", "1.0.0")]
public class Plugin : BasePlugin
{
[HarmonyPatch(typeof(ItemEquippable))]
private static class Patches
{
[HarmonyPatch("GetItemFovNormal")]
[HarmonyPostfix]
private static void Postfix_Hip(ItemEquippable __instance, ref float __result)
{
if (__instance.ArchetypeData != null && ((Item)__instance).ItemDataBlock != null && ((Item)__instance).ItemDataBlock.publicName.StartsWith("Gear"))
{
float num = HipFovTarget.Value / 55f;
__result *= num;
}
}
}
public static ConfigEntry<float> HipFovTarget;
public static ConfigFile ConfigFile;
private const float DefaultGameFov = 55f;
private FileSystemWatcher configWatcher;
public override void Load()
{
ConfigFile = ((BasePlugin)this).Config;
HipFovTarget = ((BasePlugin)this).Config.Bind<float>("Settings", "Hip FOV", 55f, "Target horizontal FOV for guns at hipfire (default game FOV is 55).");
Harmony.CreateAndPatchAll(typeof(Patches), (string)null);
((BasePlugin)this).Log.LogInfo((object)"Viewmodel FOV Loaded! Zoom is untouched, only hip FOV is modified.");
SetupConfigWatcher();
}
private void SetupConfigWatcher()
{
string directoryName = Path.GetDirectoryName(((BasePlugin)this).Config.ConfigFilePath);
string fileName = Path.GetFileName(((BasePlugin)this).Config.ConfigFilePath);
configWatcher = new FileSystemWatcher(directoryName, fileName);
configWatcher.Changed += OnConfigChanged;
configWatcher.EnableRaisingEvents = true;
((BasePlugin)this).Log.LogInfo((object)"Config file watcher enabled - changes will auto-reload!");
}
private void OnConfigChanged(object sender, FileSystemEventArgs e)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
bool flag = default(bool);
try
{
((BasePlugin)this).Config.Reload();
ManualLogSource log = ((BasePlugin)this).Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Config reloaded! New Hip FOV: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(HipFovTarget.Value);
}
log.LogInfo(val);
}
catch (Exception ex)
{
ManualLogSource log2 = ((BasePlugin)this).Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to reload config: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log2.LogError(val2);
}
}
}
}