diff --git a/README.md b/README.md index 3b07858..ab392b9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,24 @@ # FOV -Increased FOV \ No newline at end of file +Increased FOV + +## Overview + +Increases the range of FOV selection in the settings menu, combining my previous HUD "FOV" mod which allows you to move the FP camera relative to your body + +You can change some settings like minimum and maximum value in ConfigurationManager, to open it, press F12 on your keyboard in the game and expand SamSWAT.FOV section. If you launched eft with this mod at least once, you can find `com.samswat.fov.cfg` file in the `BepInEx/config/` and change settings here too. + +## How to install + +1. Download the latest release here: [link](https://dev.sp-tarkov.com/SamSWAT/FOV/releases) -OR- build from source (instructions below) +2. Extract the zip file `SamSWAT.FOV` somewhere. +3. Copy `SamSWAT.FOV.dll` into `BepInEx/plugins` folder. + +## How to build from source + +1. Download/clone this repository +2. VS2019 > File > Open solution > `SamSWAT.FOV.sln` +3. VS2019 > Build > Rebuild solution +4. `SamSWAT.FOV.dll` should appear in `bin\Debug` directory +5. Copy the .dll into the `BepInEx/plugins` folder +6. That's it, you have a working release of this mod. \ No newline at end of file diff --git a/project/SamSWAT.FOV/FovPatch.cs b/project/SamSWAT.FOV/FovPatch.cs new file mode 100644 index 0000000..6f78a22 --- /dev/null +++ b/project/SamSWAT.FOV/FovPatch.cs @@ -0,0 +1,30 @@ +using Aki.Reflection.Patching; +using EFT.UI.Settings; +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; + +namespace SamSWAT.FOV +{ + public class FovPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(GameSettingsTab).GetMethod("Show"); + } + + [PatchPrefix] + private static void PatchPrefix(ref ReadOnlyCollection ___readOnlyCollection_0) + { + if (FovPlugin.MaxFov.Value < FovPlugin.MinFov.Value) + { + FovPlugin.MinFov.Value = 50; + FovPlugin.MaxFov.Value = 75; + } + + int rangeCount = FovPlugin.MaxFov.Value - FovPlugin.MinFov.Value + 1; + ___readOnlyCollection_0 = Array.AsReadOnly(Enumerable.Range(FovPlugin.MinFov.Value, rangeCount).ToArray()); + } + } +} diff --git a/project/SamSWAT.FOV/FovPlugin.cs b/project/SamSWAT.FOV/FovPlugin.cs new file mode 100644 index 0000000..6f2ae6b --- /dev/null +++ b/project/SamSWAT.FOV/FovPlugin.cs @@ -0,0 +1,59 @@ +using BepInEx; +using BepInEx.Configuration; +using Comfort.Common; +using EFT; +using System; +using UnityEngine; + +namespace SamSWAT.FOV +{ + [BepInPlugin("com.samswat.fov", "SamSWAT.FOV", "1.0.0")] + public class FovPlugin : BaseUnityPlugin + { + internal static ConfigEntry MinFov; + internal static ConfigEntry MaxFov; + internal static ConfigEntry HudFov; + + private void Awake() + { + new FovPatch().Enable(); + new PlayerSpringPatch().Enable(); + new SettingsApplierPatch().Enable(); + + MinFov = Config.Bind( + "Main Section", + "Min FOV Value", + 20, + new ConfigDescription("Your desired minimum FOV value. Default is 50", + new AcceptableValueRange(1, 149))); + + MaxFov = Config.Bind( + "Main Section", + "Max FOV Value", + 150, + new ConfigDescription("Your desired maximum FOV value. Default is 75", + new AcceptableValueRange(1, 150))); + + HudFov = Config.Bind( + "Main Section", + "HUD FOV `Value`", + 0.05f, + new ConfigDescription("Pseudo-value for HUD FOV, it will actually change your camera position relative to your body. The lower the value, the further away the camera is, meaning more hands and weapon in your field of view. Default is 0.05", + new AcceptableValueRange(-0.1f, 0.1f))); + + HudFov.SettingChanged += HudFov_SettingChanged; + } + + private void HudFov_SettingChanged(object sender, EventArgs e) + { + var gameWorld = Singleton.Instance; + + if (gameWorld == null || gameWorld.RegisteredPlayers == null) + { + return; + } + + gameWorld.RegisteredPlayers.Find(p => p.IsYourPlayer).ProceduralWeaponAnimation.HandsContainer.CameraOffset = new Vector3(0.04f, 0.04f, HudFov.Value); + } + } +} diff --git a/project/SamSWAT.FOV/PlayerSpringPatch.cs b/project/SamSWAT.FOV/PlayerSpringPatch.cs new file mode 100644 index 0000000..cade71f --- /dev/null +++ b/project/SamSWAT.FOV/PlayerSpringPatch.cs @@ -0,0 +1,21 @@ +using Aki.Reflection.Patching; +using EFT.Animations; +using System.Reflection; +using UnityEngine; + +namespace SamSWAT.FOV +{ + public class PlayerSpringPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(PlayerSpring).GetMethod("Start", BindingFlags.NonPublic | BindingFlags.Instance); + } + + [PatchPostfix] + private static void PatchPostfix(ref Vector3 ___CameraOffset) + { + ___CameraOffset = new Vector3(0.04f, 0.04f, FovPlugin.HudFov.Value); + } + } +} diff --git a/project/SamSWAT.FOV/Properties/AssemblyInfo.cs b/project/SamSWAT.FOV/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2b6c67c --- /dev/null +++ b/project/SamSWAT.FOV/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("SamSWAT.FOV")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SamSWAT.FOV")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("a34f97ad-2fdb-43da-805b-410b1a2ac464")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/project/SamSWAT.FOV/References/Aki.Reflection.dll b/project/SamSWAT.FOV/References/Aki.Reflection.dll new file mode 100644 index 0000000..72b9cbe Binary files /dev/null and b/project/SamSWAT.FOV/References/Aki.Reflection.dll differ diff --git a/project/SamSWAT.FOV/References/Assembly-CSharp.dll b/project/SamSWAT.FOV/References/Assembly-CSharp.dll new file mode 100644 index 0000000..23cbaaa Binary files /dev/null and b/project/SamSWAT.FOV/References/Assembly-CSharp.dll differ diff --git a/project/SamSWAT.FOV/References/BepInEx.dll b/project/SamSWAT.FOV/References/BepInEx.dll new file mode 100644 index 0000000..8aedff0 Binary files /dev/null and b/project/SamSWAT.FOV/References/BepInEx.dll differ diff --git a/project/SamSWAT.FOV/References/Comfort.dll b/project/SamSWAT.FOV/References/Comfort.dll new file mode 100644 index 0000000..96d7476 Binary files /dev/null and b/project/SamSWAT.FOV/References/Comfort.dll differ diff --git a/project/SamSWAT.FOV/References/UnityEngine.CoreModule.dll b/project/SamSWAT.FOV/References/UnityEngine.CoreModule.dll new file mode 100644 index 0000000..7d585db Binary files /dev/null and b/project/SamSWAT.FOV/References/UnityEngine.CoreModule.dll differ diff --git a/project/SamSWAT.FOV/References/UnityEngine.dll b/project/SamSWAT.FOV/References/UnityEngine.dll new file mode 100644 index 0000000..6ff1d0f Binary files /dev/null and b/project/SamSWAT.FOV/References/UnityEngine.dll differ diff --git a/project/SamSWAT.FOV/SamSWAT.FOV.csproj b/project/SamSWAT.FOV/SamSWAT.FOV.csproj new file mode 100644 index 0000000..8597155 --- /dev/null +++ b/project/SamSWAT.FOV/SamSWAT.FOV.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {A34F97AD-2FDB-43DA-805B-410B1A2AC464} + Library + Properties + SamSWAT.FOV + SamSWAT.FOV + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + References\Aki.Reflection.dll + + + References\Assembly-CSharp.dll + + + References\BepInEx.dll + + + References\Comfort.dll + + + + References\UnityEngine.dll + + + References\UnityEngine.CoreModule.dll + + + + + + + + + + + \ No newline at end of file diff --git a/project/SamSWAT.FOV/SamSWAT.FOV.sln b/project/SamSWAT.FOV/SamSWAT.FOV.sln new file mode 100644 index 0000000..a35df54 --- /dev/null +++ b/project/SamSWAT.FOV/SamSWAT.FOV.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamSWAT.FOV", "SamSWAT.FOV.csproj", "{A34F97AD-2FDB-43DA-805B-410B1A2AC464}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A34F97AD-2FDB-43DA-805B-410B1A2AC464}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A34F97AD-2FDB-43DA-805B-410B1A2AC464}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A34F97AD-2FDB-43DA-805B-410B1A2AC464}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A34F97AD-2FDB-43DA-805B-410B1A2AC464}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E5C57CB0-6CAD-4805-99D0-7D5C0CA057D3} + EndGlobalSection +EndGlobal diff --git a/project/SamSWAT.FOV/SettingsApplierPatch.cs b/project/SamSWAT.FOV/SettingsApplierPatch.cs new file mode 100644 index 0000000..8957ab4 --- /dev/null +++ b/project/SamSWAT.FOV/SettingsApplierPatch.cs @@ -0,0 +1,24 @@ +using Aki.Reflection.Patching; +using Aki.Reflection.Utils; +using System; +using System.Linq; +using System.Reflection; +using UnityEngine; + +namespace SamSWAT.FOV +{ + public class SettingsApplierPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + Type gclass911 = PatchConstants.EftTypes.Single(x => x.GetMethod("Clone") != null && x.GetField("NotificationTransportType") != null); + return gclass911.GetNestedTypes(PatchConstants.PrivateFlags)[0].GetMethod("method_0", PatchConstants.PrivateFlags); + } + + [PatchPostfix] + public static void PatchPostfix(int x, ref int __result) + { + __result = Mathf.Clamp(x, FovPlugin.MinFov.Value, FovPlugin.MaxFov.Value); + } + } +}