initial commit

This commit is contained in:
SamSWAT 2022-07-29 17:28:54 +03:00
parent dd34d952a1
commit d6cffa6573
14 changed files with 279 additions and 1 deletions

View File

@ -1,3 +1,24 @@
# FOV
Increased FOV
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.

View File

@ -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<int> ___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());
}
}
}

View File

@ -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<int> MinFov;
internal static ConfigEntry<int> MaxFov;
internal static ConfigEntry<float> 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<int>(1, 149)));
MaxFov = Config.Bind(
"Main Section",
"Max FOV Value",
150,
new ConfigDescription("Your desired maximum FOV value. Default is 75",
new AcceptableValueRange<int>(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<float>(-0.1f, 0.1f)));
HudFov.SettingChanged += HudFov_SettingChanged;
}
private void HudFov_SettingChanged(object sender, EventArgs e)
{
var gameWorld = Singleton<GameWorld>.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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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")]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A34F97AD-2FDB-43DA-805B-410B1A2AC464}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SamSWAT.FOV</RootNamespace>
<AssemblyName>SamSWAT.FOV</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Aki.Reflection">
<HintPath>References\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>References\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Comfort">
<HintPath>References\Comfort.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine">
<HintPath>References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="FovPatch.cs" />
<Compile Include="FovPlugin.cs" />
<Compile Include="PlayerSpringPatch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsApplierPatch.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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

View File

@ -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);
}
}
}