using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CustomFOV")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomFOV")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("37a376b5-b8a6-4d05-a8d0-5b4ce82b6e6a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CustomFOV;
[BepInPlugin("kruumy.CustomFOV", "Custom FOV", "1.0.0")]
public class Main : BaseUnityPlugin
{
public static ConfigEntry<float> FieldOfView;
public static ConfigEntry<float> HelmetZPositionOffset;
private void Awake()
{
FieldOfView = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Field Of View", 90f, (ConfigDescription)null);
HelmetZPositionOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Helmet Z Position Offset", -0.119f, "The amount to move the helmet model on your head. Higher FOVs would look weird without moving the model back a bit.");
Harmony.CreateAndPatchAll(typeof(Main), (string)null);
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
}
private void SceneManager_activeSceneChanged(Scene arg0, Scene arg1)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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)
Object[] array = Object.FindObjectsOfTypeAll(typeof(Camera));
foreach (Object obj in array)
{
Camera val = (Camera)(object)((obj is Camera) ? obj : null);
if (val != null && ((Object)val).name == "MainCamera")
{
Transform child = ((Component)val).gameObject.transform.GetChild(0);
child.localPosition = new Vector3(child.localPosition.x, child.localPosition.y, HelmetZPositionOffset.Value);
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
private static void FOVPrefix(Camera __instance, ref float value)
{
if (((Object)__instance).name == "MainCamera")
{
value = ((FieldOfView == null) ? 90f : FieldOfView.Value);
}
}
}