using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CustomFOV")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomFOV")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("64bccb02-5a59-4063-94f4-6b4e4e068bac")]
[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("CustomFOVMod_J0804", "CustomFOV", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public class FOVSaveData
{
public string customFOVval;
public float customFOV;
public string menubind = "F2";
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class GlobalFOVPatch
{
private static bool Prefix(ref float value)
{
value = customFOV;
return true;
}
}
[HarmonyPatch(typeof(PlayerMovement), "StartGame")]
public static class HUDFOVPATCH
{
private static float baseFOV = 60f;
private static Dictionary<string, Vector3> originalScales = new Dictionary<string, Vector3>();
private static void Postfix()
{
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
float customFOV = Plugin.customFOV;
float num = customFOV / baseFOV;
float num2 = ((customFOV == 90f) ? 1.35f : ((customFOV == 100f) ? 1.4f : ((customFOV != 120f) ? 1f : 1.58f)));
float num3 = Mathf.Pow(num, num2);
string[] array = new string[1] { "uibox" };
string[] array2 = array;
foreach (string text in array2)
{
GameObject val = GameObject.FindGameObjectWithTag(text);
if ((Object)(object)val != (Object)null)
{
if (!originalScales.ContainsKey(text))
{
originalScales[text] = val.transform.localScale;
}
Vector3 val2 = originalScales[text];
val.transform.localScale = new Vector3(val2.x * num3, val2.y * num3, val2.z);
}
}
}
}
private const string modGUID = "CustomFOVMod_J0804";
private const string modName = "CustomFOV";
private const string modVersion = "1.0.1";
private readonly Harmony harmony = new Harmony("CustomFOVMod_J0804");
internal ManualLogSource mls;
private static Plugin Instance;
private Rect guiRect;
private string saveFilePath;
private bool showGUI2 = false;
private static float customFOV = 60f;
private static string customFOVval = "";
private KeyCode menubindkc = (KeyCode)283;
private string[] fovOptions = new string[4] { "60", "90", "100", "120" };
private int selectedFovIndex = 0;
private bool showDropdown = false;
private void OnGUI()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
if (showGUI2)
{
float num = 300f;
float num2 = 150f;
guiRect = new Rect((float)Screen.width - num - 10f, 10f, num, num2);
GUI.color = Color.white;
GUI.backgroundColor = new Color(0.15f, 0.15f, 0.15f);
guiRect = GUI.Window(0, guiRect, new WindowFunction(DrawGuiWindow), "FOV Changer");
}
}
private void DrawGuiWindow(int windowID)
{
//IL_001b: 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_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
Event current = Event.current;
GUI.Label(new Rect(20f, 30f, 80f, 20f), "FOV:");
Rect val = default(Rect);
((Rect)(ref val))..ctor(100f, 30f, 100f, 20f);
if (GUI.Button(val, fovOptions[selectedFovIndex]))
{
showDropdown = !showDropdown;
}
float num = 0f;
if (showDropdown)
{
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y + ((Rect)(ref val)).height, 100f, (float)(20 * fovOptions.Length));
for (int i = 0; i < fovOptions.Length; i++)
{
if (GUI.Button(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y + (float)(20 * i), ((Rect)(ref val2)).width, 20f), fovOptions[i]))
{
selectedFovIndex = i;
showDropdown = false;
}
}
num = ((Rect)(ref val2)).height;
if ((int)current.type == 0 && !((Rect)(ref val2)).Contains(current.mousePosition) && !((Rect)(ref val)).Contains(current.mousePosition))
{
showDropdown = false;
}
}
float num2 = ((Rect)(ref val)).y + ((Rect)(ref val)).height + num + 10f;
if (GUI.Button(new Rect(100f, num2, 100f, 25f), "Apply"))
{
if (float.TryParse(fovOptions[selectedFovIndex], out var result))
{
customFOV = result;
SaveData();
Debug.Log((object)$"New FOV set: {customFOV}");
}
else
{
Debug.LogWarning((object)"Invalid FOV value selected.");
}
}
if (GUI.Button(new Rect(100f, num2 + 35f, 100f, 25f), "Close"))
{
showGUI2 = false;
}
GUI.DragWindow();
}
private void OldDrawGuiWindow(int windowID)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
GUI.Label(new Rect(20f, 30f, 80f, 20f), "FOV:");
customFOVval = GUI.TextField(new Rect(100f, 30f, 100f, 20f), customFOVval);
if (GUI.Button(new Rect(100f, 60f, 100f, 25f), "Apply"))
{
if (float.TryParse(customFOVval, out var result))
{
customFOV = result;
SaveData();
Debug.Log((object)$"New FOV set: {customFOV}");
}
else
{
Debug.LogWarning((object)"Invalid FOV value entered.");
}
}
if (GUI.Button(new Rect(100f, 95f, 100f, 25f), "Close"))
{
showGUI2 = false;
}
}
private void Update()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(menubindkc))
{
showGUI2 = !showGUI2;
}
}
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("CustomFOVMod_J0804");
mls.LogInfo((object)"CustomFOV Loaded");
saveFilePath = Path.Combine(Paths.ConfigPath, "custom_fov.txt");
LoadData();
harmony.PatchAll();
}
private void SaveData()
{
FOVSaveData fOVSaveData = new FOVSaveData
{
customFOVval = customFOVval,
customFOV = customFOV,
menubind = ((object)(KeyCode)(ref menubindkc)).ToString()
};
string contents = JsonUtility.ToJson((object)fOVSaveData, true);
File.WriteAllText(saveFilePath, contents);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Saved FOV.");
}
private void LoadData()
{
//IL_0102: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
if (!File.Exists(saveFilePath))
{
menubindkc = (KeyCode)283;
SaveData();
return;
}
try
{
string text = File.ReadAllText(saveFilePath);
FOVSaveData fOVSaveData = JsonUtility.FromJson<FOVSaveData>(text);
customFOVval = fOVSaveData.customFOVval;
customFOV = fOVSaveData.customFOV;
if (string.IsNullOrEmpty(fOVSaveData.menubind) || !Enum.TryParse<KeyCode>(fOVSaveData.menubind.Trim(), ignoreCase: true, out KeyCode result) || (int)result == 0)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Menubind missing or invalid in config, using default F2");
menubindkc = (KeyCode)283;
}
else
{
menubindkc = result;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)$"loaded from save {customFOVval}, {customFOV}, {menubindkc}");
}
catch (Exception)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load config, regenerating default");
SaveData();
menubindkc = (KeyCode)283;
}
}
}
}
namespace CustomFOV.Other
{
internal class Unused
{
private float lastFOV = -1f;
private const float minFOV = 60f;
private const float midFOV = 90f;
private const float maxFOV = 120f;
private const float scaleAtMin = 1f;
private const float scaleAtMid = 1.35f;
private const float scaleAtMax = 1.58f;
private readonly Vector3 baseHUDScale = new Vector3(1f, 1f, 1f);
private void LateUpdate()
{
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
return;
}
float num = 90f;
if (Mathf.Approximately(num, lastFOV))
{
return;
}
lastFOV = num;
float num2 = Mathf.Clamp(num, 60f, 120f);
float num4;
if (num2 <= 90f)
{
float num3 = (num2 - 60f) / 30f;
num4 = Mathf.Lerp(1f, 1.35f, num3);
}
else
{
float num5 = (num2 - 90f) / 30f;
num4 = Mathf.Lerp(1.35f, 1.58f, num5);
}
string[] array = new string[3] { "uibox", "stamcover", "hpcover" };
string[] array2 = array;
foreach (string text in array2)
{
GameObject val = GameObject.FindGameObjectWithTag(text);
if ((Object)(object)val != (Object)null)
{
val.transform.localScale = new Vector3(baseHUDScale.x * num4, baseHUDScale.y * num4, baseHUDScale.z);
}
}
}
}
}