From 18f4b57fb5ee1bc4a1c014ee15bb0462dc65bda3 Mon Sep 17 00:00:00 2001 From: CWX Date: Thu, 3 Aug 2023 10:01:46 +0100 Subject: [PATCH] grasscutter --- Live/CWX_GrassCutter/CWX_GrassCutter.csproj | 32 ++++++++++++++ Live/CWX_GrassCutter/GrassCutter.cs | 13 ++++++ Live/CWX_GrassCutter/GrassCutterPatch.cs | 22 ++++++++++ Live/CWX_GrassCutter/GrassCutterScript.cs | 24 +++++++++++ Live/CWX_Mods.sln | 14 +++++- Live/test-layout/Class1.cs | 13 ++++++ Live/test-layout/patch.cs | 48 +++++++++++++++++++++ Live/test-layout/test-layout.csproj | 29 +++++++++++++ 8 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 Live/CWX_GrassCutter/CWX_GrassCutter.csproj create mode 100644 Live/CWX_GrassCutter/GrassCutter.cs create mode 100644 Live/CWX_GrassCutter/GrassCutterPatch.cs create mode 100644 Live/CWX_GrassCutter/GrassCutterScript.cs create mode 100644 Live/test-layout/Class1.cs create mode 100644 Live/test-layout/patch.cs create mode 100644 Live/test-layout/test-layout.csproj diff --git a/Live/CWX_GrassCutter/CWX_GrassCutter.csproj b/Live/CWX_GrassCutter/CWX_GrassCutter.csproj new file mode 100644 index 0000000..c637908 --- /dev/null +++ b/Live/CWX_GrassCutter/CWX_GrassCutter.csproj @@ -0,0 +1,32 @@ + + + + net472 + CWX-GrassCutter + + + + + ..\..\..\Shared\Aki.Reflection.dll + + + ..\..\..\Shared\Assembly-CSharp.dll + + + ..\..\..\Shared\BepInEx.dll + + + ..\..\..\Shared\Comfort.dll + + + ..\..\..\Shared\Newtonsoft.Json.dll + + + ..\..\..\Shared\UnityEngine.dll + + + ..\..\..\Shared\UnityEngine.CoreModule.dll + + + + diff --git a/Live/CWX_GrassCutter/GrassCutter.cs b/Live/CWX_GrassCutter/GrassCutter.cs new file mode 100644 index 0000000..92f14a9 --- /dev/null +++ b/Live/CWX_GrassCutter/GrassCutter.cs @@ -0,0 +1,13 @@ +using BepInEx; + +namespace CWX_GrassCutter +{ + [BepInPlugin("com.CWX.GrassCutter", "CWX-GrassCutter", "1.0.0")] + public class GrassCutter : BaseUnityPlugin + { + private void Awake() + { + new GrassCutterPatch().Enable(); + } + } +} \ No newline at end of file diff --git a/Live/CWX_GrassCutter/GrassCutterPatch.cs b/Live/CWX_GrassCutter/GrassCutterPatch.cs new file mode 100644 index 0000000..96b7229 --- /dev/null +++ b/Live/CWX_GrassCutter/GrassCutterPatch.cs @@ -0,0 +1,22 @@ +using Aki.Reflection.Patching; +using EFT; +using System.Reflection; + +namespace CWX_GrassCutter +{ + public class GrassCutterPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(GameWorld).GetMethod("OnGameStarted", BindingFlags.Public | BindingFlags.Instance); + } + + [PatchPostfix] + private static void PatchPostFix() + { + GrassCutterScript grassCutter = new GrassCutterScript(); + + grassCutter.Start(); + } + } +} diff --git a/Live/CWX_GrassCutter/GrassCutterScript.cs b/Live/CWX_GrassCutter/GrassCutterScript.cs new file mode 100644 index 0000000..1c7dd59 --- /dev/null +++ b/Live/CWX_GrassCutter/GrassCutterScript.cs @@ -0,0 +1,24 @@ +using GPUInstancer; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + + +namespace CWX_GrassCutter +{ + public class GrassCutterScript + { + public void Start() + { + List allGrass = GameObject.FindObjectsOfType().ToList(); + GameObject streetsGrass = GameObject.Find("GrassPrefabManager"); + + foreach (var grass in allGrass) + { + grass.enabled = false; + } + + streetsGrass?.gameObject.SetActive(false); + } + } +} diff --git a/Live/CWX_Mods.sln b/Live/CWX_Mods.sln index 1c34947..884c826 100644 --- a/Live/CWX_Mods.sln +++ b/Live/CWX_Mods.sln @@ -17,7 +17,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_ColourAdderPrePatch", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_ColourAdderPatcher", "CWX_ColourAdderPatcher\CWX_ColourAdderPatcher.csproj", "{6D696C6A-011B-4D53-8D97-D62105B20E0E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CWX_AlarmChanger", "CWX_AlarmChanger\CWX_AlarmChanger.csproj", "{518D3743-AE98-41CD-8A6A-7B537C3FC293}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CWX_AlarmChanger", "CWX_AlarmChanger\CWX_AlarmChanger.csproj", "{518D3743-AE98-41CD-8A6A-7B537C3FC293}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "test-layout", "test-layout\test-layout.csproj", "{CBDE7880-21AE-45AC-B216-D1061FD6A8A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CWX_GrassCutter", "CWX_GrassCutter\CWX_GrassCutter.csproj", "{CC095831-11F9-4429-9A5C-BF60EF451E96}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -57,6 +61,14 @@ Global {518D3743-AE98-41CD-8A6A-7B537C3FC293}.Debug|Any CPU.Build.0 = Debug|Any CPU {518D3743-AE98-41CD-8A6A-7B537C3FC293}.Release|Any CPU.ActiveCfg = Release|Any CPU {518D3743-AE98-41CD-8A6A-7B537C3FC293}.Release|Any CPU.Build.0 = Release|Any CPU + {CBDE7880-21AE-45AC-B216-D1061FD6A8A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBDE7880-21AE-45AC-B216-D1061FD6A8A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBDE7880-21AE-45AC-B216-D1061FD6A8A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBDE7880-21AE-45AC-B216-D1061FD6A8A0}.Release|Any CPU.Build.0 = Release|Any CPU + {CC095831-11F9-4429-9A5C-BF60EF451E96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC095831-11F9-4429-9A5C-BF60EF451E96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC095831-11F9-4429-9A5C-BF60EF451E96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC095831-11F9-4429-9A5C-BF60EF451E96}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Live/test-layout/Class1.cs b/Live/test-layout/Class1.cs new file mode 100644 index 0000000..5d4e9b2 --- /dev/null +++ b/Live/test-layout/Class1.cs @@ -0,0 +1,13 @@ +using BepInEx; + +namespace test_layout +{ + [BepInPlugin("com.test_layout", "test_layout", "1.0.0")] + public class test_layout : BaseUnityPlugin + { + private void Awake() + { + new test_layoutPatch().Enable(); + } + } +} diff --git a/Live/test-layout/patch.cs b/Live/test-layout/patch.cs new file mode 100644 index 0000000..71bd2f0 --- /dev/null +++ b/Live/test-layout/patch.cs @@ -0,0 +1,48 @@ +using Aki.Reflection.Patching; +using EFT.InventoryLogic; +using EFT.UI.DragAndDrop; +using System.Reflection; +using UnityEngine; + +namespace test_layout +{ + public class test_layoutPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + Debug.LogError("fucker"); + var methods = getMethods(); + + foreach (var method in methods) + { + Debug.LogError(method.Name); + } + + return typeof(ContainedGridsView).GetMethod("CreateGrids", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic); + } + + public MethodInfo[] getMethods() + { + return typeof(ContainedGridsView).GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic); + } + + [PatchPrefix] + private static bool PatchPrefix(ref ContainedGridsView __result, Item item, ContainedGridsView containedGridsTemplate) + { + Debug.LogError(item.TemplateId); + + if (item.TemplateId == "5648a69d4bdc2ded0b8b457b") + { + foreach (var grid in containedGridsTemplate.GridViews) + { + Debug.LogError(grid.transform.ToString()); + } + + __result = Object.Instantiate(containedGridsTemplate); + return false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/Live/test-layout/test-layout.csproj b/Live/test-layout/test-layout.csproj new file mode 100644 index 0000000..4df0237 --- /dev/null +++ b/Live/test-layout/test-layout.csproj @@ -0,0 +1,29 @@ + + + + net472 + test_layout + + + + + ..\..\..\Shared\Aki.Reflection.dll + + + ..\..\..\Shared\Assembly-CSharp.dll + + + ..\..\..\Shared\BepInEx.dll + + + ..\..\..\Shared\Comfort.dll + + + ..\..\..\Shared\UnityEngine.dll + + + ..\..\..\Shared\UnityEngine.CoreModule.dll + + + +