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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GameData;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Player;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("nazelto")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Separate GTFO viewmodel FOV settings for weapons, melee, tools, and carried items.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("AllViewmodelFOV")]
[assembly: AssemblyTitle("AllViewmodelFOV")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 AllViewmodelFOV
{
[BepInPlugin("com.gtfo.allviewmodelfov", "All Viewmodel FOV", "1.1.1")]
[BepInProcess("GTFO.exe")]
public sealed class Plugin : BasePlugin
{
public const string PluginGuid = "com.gtfo.allviewmodelfov";
public const string PluginName = "All Viewmodel FOV";
public const string PluginVersion = "1.1.1";
internal const float DefaultGameViewmodelFov = 55f;
private Harmony? _harmony;
internal static ConfigEntry<bool> Enabled { get; private set; }
internal static ConfigEntry<float> WeaponFov { get; private set; }
internal static ConfigEntry<float> MeleeFov { get; private set; }
internal static ConfigEntry<float> ToolFov { get; private set; }
internal static ConfigEntry<float> ResourceConsumableAndObjectiveFov { get; private set; }
public override void Load()
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable changing the normal (non-zoomed) FOV of every first-person equippable item.");
WeaponFov = BindFov("1. Primary and Special Weapon FOV", "Horizontal viewmodel FOV for primary and special weapons.");
MeleeFov = BindFov("2. Melee Weapon FOV", "Horizontal viewmodel FOV for melee weapons.");
ToolFov = BindFov("3. Tool FOV", "Horizontal viewmodel FOV for class-slot tools and the hacking tool.");
ResourceConsumableAndObjectiveFov = BindFov("4. Resource, Consumable and Objective Item FOV", "Horizontal viewmodel FOV for resource packs, consumables, pocket items, pickups, and objective carry items.");
_harmony = new Harmony("com.gtfo.allviewmodelfov");
_harmony.PatchAll(typeof(ItemFovPatch));
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(69, 6, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("All Viewmodel FOV");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.1");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. ");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Weapon: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(WeaponFov.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Melee: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(MeleeFov.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Tool: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(ToolFov.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Resource/Consumable/Objective: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(ResourceConsumableAndObjectiveFov.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
}
log.LogInfo(val);
}
private ConfigEntry<float> BindFov(string key, string description)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
return ((BasePlugin)this).Config.Bind<float>("FOV", key, 55f, new ConfigDescription($"{description} GTFO's reference value is {55f}. ADS/zoom FOV is not changed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 179f), Array.Empty<object>()));
}
public override bool Unload()
{
Harmony? harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
[HarmonyPatch(typeof(ItemEquippable), "GetItemFovNormal")]
internal static class ItemFovPatch
{
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void SetFov(ItemEquippable __instance, ref float __result)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected I4, but got Unknown
if (!Plugin.Enabled.Value)
{
return;
}
ItemDataBlock itemDataBlock = ((Item)__instance).ItemDataBlock;
if (itemDataBlock != null)
{
InventorySlot inventorySlot = itemDataBlock.inventorySlot;
float? num;
switch (inventorySlot - 1)
{
case 0:
case 1:
num = Plugin.WeaponFov.Value;
break;
case 9:
num = Plugin.MeleeFov.Value;
break;
case 2:
case 10:
num = Plugin.ToolFov.Value;
break;
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
num = Plugin.ResourceConsumableAndObjectiveFov.Value;
break;
default:
num = null;
break;
}
float? num2 = num;
if (num2.HasValue)
{
__result *= num2.Value / 55f;
}
}
}
}
}