From acac743403b3aff2be25a87a94fbe6243b6b72cd Mon Sep 17 00:00:00 2001 From: CWX Date: Wed, 18 Oct 2023 13:04:15 +0100 Subject: [PATCH] bump --- .gitignore | 1 + Live/CWX_Mods.sln | 6 ++++ Live/Chocster-mod/Chocster-mod.csproj | 35 ++++++++++++++++++++ Live/Chocster-mod/patch.cs | 47 +++++++++++++++++++++++++++ Live/Chocster-mod/plugin.cs | 18 ++++++++++ Live/test-layout/patch.cs | 28 +++++++++++++++- 6 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 Live/Chocster-mod/Chocster-mod.csproj create mode 100644 Live/Chocster-mod/patch.cs create mode 100644 Live/Chocster-mod/plugin.cs diff --git a/.gitignore b/.gitignore index aa94aee..1a5272f 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ WIP/CWX-BackpackReload/CWX-BackpackReload/obj WIP/CWX-BUNDLEMAKER/BUNDLEMAKER/bin WIP/CWX-BUNDLEMAKER/BUNDLEMAKER/obj +Live/CWX_Mods.sln.DotSettings.user diff --git a/Live/CWX_Mods.sln b/Live/CWX_Mods.sln index 2450720..3578c48 100644 --- a/Live/CWX_Mods.sln +++ b/Live/CWX_Mods.sln @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CWX_LockPicking", "CWX_Lock EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kaeno-TraderScrolling", "Kaeno-TraderScrolling\Kaeno-TraderScrolling.csproj", "{01BF7708-EC1F-4E2A-A788-084AE1C9E467}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chocster-mod", "Chocster-mod\Chocster-mod.csproj", "{1EE1391B-8D03-43C1-BB65-8B631122D54C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -63,6 +65,10 @@ Global {01BF7708-EC1F-4E2A-A788-084AE1C9E467}.Debug|Any CPU.Build.0 = Debug|Any CPU {01BF7708-EC1F-4E2A-A788-084AE1C9E467}.Release|Any CPU.ActiveCfg = Release|Any CPU {01BF7708-EC1F-4E2A-A788-084AE1C9E467}.Release|Any CPU.Build.0 = Release|Any CPU + {1EE1391B-8D03-43C1-BB65-8B631122D54C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1EE1391B-8D03-43C1-BB65-8B631122D54C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EE1391B-8D03-43C1-BB65-8B631122D54C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1EE1391B-8D03-43C1-BB65-8B631122D54C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Live/Chocster-mod/Chocster-mod.csproj b/Live/Chocster-mod/Chocster-mod.csproj new file mode 100644 index 0000000..56e0982 --- /dev/null +++ b/Live/Chocster-mod/Chocster-mod.csproj @@ -0,0 +1,35 @@ + + + + net472 + Chocster_mod + + + + + ..\..\..\Shared\0Harmony.dll + + + ..\..\..\Shared\Aki.Common.dll + + + ..\..\..\Shared\Aki.Reflection.dll + + + ..\..\..\Shared\Assembly-CSharp.dll + + + ..\..\..\Shared\BepInEx.dll + + + ..\..\..\Shared\Comfort.dll + + + ..\..\..\Shared\UnityEngine.dll + + + ..\..\..\Shared\UnityEngine.CoreModule.dll + + + + diff --git a/Live/Chocster-mod/patch.cs b/Live/Chocster-mod/patch.cs new file mode 100644 index 0000000..6673d0f --- /dev/null +++ b/Live/Chocster-mod/patch.cs @@ -0,0 +1,47 @@ +using System; +using System.Linq; +using Aki.Reflection.Patching; +using System.Reflection; +using Aki.Reflection.Utils; +using EFT; +using HarmonyLib; + +namespace Chocster_mod +{ + public class ChocPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return PatchConstants.EftTypes.First(IsTargetType).GetMethod("OnModChanged", PatchConstants.PublicFlags); + } + + private bool IsTargetType(Type type) + { + if (type.Name == "Class943") + { + return true; + } + + return false; + } + + [PatchPrefix] + private static void PatchPrefix(ref object __instance) + { + Logger.LogError($"Get weaponPrefab"); + var testTraverse = (Player.FirearmController) Traverse.Create(__instance).Field("firearmController_0").GetValue(); + var testtest = (WeaponPrefab)Traverse.Create(testTraverse).Field("weaponPrefab_0").GetValue(); + Logger.LogError($"Got weaponPrefab"); + Logger.LogError($"Get weaponPrefab methods"); + var methodsOnType = testtest.GetType().GetMethods().ToList(); + Logger.LogError($"Log weaponPrefab methods"); + foreach (var method in methodsOnType) + { + Logger.LogError(method.Name); + } + Logger.LogError($"End"); + testtest.ResetStatesToDefault(); + } + } +} + diff --git a/Live/Chocster-mod/plugin.cs b/Live/Chocster-mod/plugin.cs new file mode 100644 index 0000000..6bf9bcd --- /dev/null +++ b/Live/Chocster-mod/plugin.cs @@ -0,0 +1,18 @@ +using BepInEx; +using BepInEx.Logging; + +namespace Chocster_mod +{ + [BepInPlugin("com.ChocMod", "ChocMod", "1.0.0")] + public class ChocPlugin : BaseUnityPlugin + { + internal new static ManualLogSource Logger { get; private set; } + private void Awake() + { + Logger = base.Logger; + + new ChocPatch().Enable(); + } + } +} + diff --git a/Live/test-layout/patch.cs b/Live/test-layout/patch.cs index fe21bc7..384b733 100644 --- a/Live/test-layout/patch.cs +++ b/Live/test-layout/patch.cs @@ -1,8 +1,10 @@ using System; +using System.Linq; using Aki.Reflection.Patching; using EFT.InventoryLogic; using EFT.UI.DragAndDrop; using System.Reflection; +using Aki.Reflection.Utils; using EFT.UI; using UnityEngine; using Newtonsoft.Json; @@ -13,7 +15,31 @@ namespace Test_layout { protected override MethodBase GetTargetMethod() { - return typeof(ContainedGridsView).GetMethod("CreateGrids", BindingFlags.Public | BindingFlags.Static); + var typesToCheck = PatchConstants.EftTypes; + var afterChecks = typesToCheck.First(IsTargetType); + + Debug.LogError($"AfterChecks: {afterChecks.Name}"); + + var methodToCheck = afterChecks.GetMethod("OnModChanged", PatchConstants.PublicFlags); + + Debug.LogError($"methodName: {methodToCheck.Name}"); + + return methodToCheck; + } + + private bool IsTargetType(Type type) + { + Debug.LogError($"type name: {type.Name}"); + var fieldsToCheck = type.GetFields(); + + if (fieldsToCheck.Length == 4 && fieldsToCheck.Any(x => x.Name == "item_0") && + fieldsToCheck.Any(x => x.Name == "slot_0") && fieldsToCheck.Any(x => x.Name == "callback_0")) + { + Debug.LogError("type found mother fucker"); + return true; + } + + return false; } [PatchPostfix]