diff --git a/Projects/SamSWAT.OldFreelook/Plugin.cs b/Projects/SamSWAT.OldFreelook/Plugin.cs new file mode 100644 index 0000000..69ea175 --- /dev/null +++ b/Projects/SamSWAT.OldFreelook/Plugin.cs @@ -0,0 +1,55 @@ +using Aki.Reflection.Patching; +using BepInEx; +using EFT; +using HarmonyLib; +using System.Collections.Generic; +using System.Reflection; +using System.Reflection.Emit; + +namespace SamSWAT.OldFreelook +{ + [BepInPlugin("com.samswat.oldfreelook", "SamSWAT.OldFreelook", "1.0.0")] + public class Plugin : BaseUnityPlugin + { + void Awake() + { + new Transpiler().Enable(); + } + } + + public class Transpiler : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(Player).GetMethod("Look", BindingFlags.Instance | BindingFlags.Public); + } + + [PatchTranspiler] + private static IEnumerable PatchTranspile(IEnumerable instructions) + { + var codes = new List(instructions); + var searchCode = new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(EFTHardSettings), "get_Instance")); + + int endIndex = -1; + + for (int i = 0; i < codes.Count; i++) + { + if (codes[i].opcode == searchCode.opcode && codes[i].operand == searchCode.operand) + { + endIndex = i; + break; + } + } + + if (endIndex == -1) + { + Logger.LogError("Old Freelook patch failed: Could not find reference code."); + return instructions; + } + + codes.RemoveRange(0, endIndex); + + return codes; + } + } +} diff --git a/Projects/SamSWAT.OldFreelook/Properties/AssemblyInfo.cs b/Projects/SamSWAT.OldFreelook/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f1e1a51 --- /dev/null +++ b/Projects/SamSWAT.OldFreelook/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("SamSWAT.OldFreelook")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SamSWAT.OldFreelook")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("3e58b01f-a6b6-4b6d-ab33-1b567c5b81ec")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Projects/SamSWAT.OldFreelook/SamSWAT.OldFreelook.csproj b/Projects/SamSWAT.OldFreelook/SamSWAT.OldFreelook.csproj new file mode 100644 index 0000000..2a331e4 --- /dev/null +++ b/Projects/SamSWAT.OldFreelook/SamSWAT.OldFreelook.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {3E58B01F-A6B6-4B6D-AB33-1B567C5B81EC} + Library + Properties + SamSWAT.OldFreelook + SamSWAT.OldFreelook + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\References\0Harmony.dll + + + ..\..\References\Aki.Reflection.dll + + + ..\..\References\Assembly-CSharp.dll + + + ..\..\References\BepInEx.dll + + + + ..\..\References\UnityEngine.dll + + + ..\..\References\UnityEngine.CoreModule.dll + + + + + + + + \ No newline at end of file diff --git a/Projects/SamSWAT.OldFreelook/SamSWAT.OldFreelook.sln b/Projects/SamSWAT.OldFreelook/SamSWAT.OldFreelook.sln new file mode 100644 index 0000000..de982e2 --- /dev/null +++ b/Projects/SamSWAT.OldFreelook/SamSWAT.OldFreelook.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.OldFreelook", "SamSWAT.OldFreelook.csproj", "{3E58B01F-A6B6-4B6D-AB33-1B567C5B81EC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3E58B01F-A6B6-4B6D-AB33-1B567C5B81EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E58B01F-A6B6-4B6D-AB33-1B567C5B81EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E58B01F-A6B6-4B6D-AB33-1B567C5B81EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E58B01F-A6B6-4B6D-AB33-1B567C5B81EC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {15AEFD71-1D38-4868-8F6F-8D3ABB87B7DE} + EndGlobalSection +EndGlobal