diff --git a/SkinHide.cs b/SkinHide.cs new file mode 100644 index 0000000..40f5272 --- /dev/null +++ b/SkinHide.cs @@ -0,0 +1,54 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using EFT.Visual; +using EFT.Interactive; + +namespace SkinHide +{ + public class SkinHide : MonoBehaviour + { + public SkinDress[] skindress; + public Dress[] dress; + public bool skinhide = true; + public GameObject Player; + + void Update() + { + //Destroy LootItem + if (GetComponent() == null) + { + Debug.LogError("not find ObservedLootItem"); + } + else if (GetComponent().enabled == true) + { + Destroy(gameObject); + } + + if (transform.GetComponentInParent() == null) + { + Debug.LogError("not find Animator"); + } + else if (skinhide) + { + //Get Player GameObject + Player = transform.GetComponentInParent().gameObject; + + //Find Skin + skindress = Player.GetComponentsInChildren(); + dress = Player.GetComponentsInChildren(); + + //False Skin GameObject + foreach (SkinDress skindress in skindress) + { + skindress.gameObject.SetActive(false); + } + foreach (Dress dress in dress) + { + dress.gameObject.SetActive(false); + } + } + } + } +} + diff --git a/SkinHide.sln b/SkinHide.sln new file mode 100644 index 0000000..af85be7 --- /dev/null +++ b/SkinHide.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32407.343 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkinHide", "SkinHide\SkinHide.csproj", "{E5DD6484-115E-4104-AADF-E5610EE4F397}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E5DD6484-115E-4104-AADF-E5610EE4F397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5DD6484-115E-4104-AADF-E5610EE4F397}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5DD6484-115E-4104-AADF-E5610EE4F397}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5DD6484-115E-4104-AADF-E5610EE4F397}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DEF8B0A7-400E-448C-8C06-2ACDC08A868C} + EndGlobalSection +EndGlobal diff --git a/SkinHide/Patches/BotOwnerPatch.cs b/SkinHide/Patches/BotOwnerPatch.cs new file mode 100644 index 0000000..3540ff5 --- /dev/null +++ b/SkinHide/Patches/BotOwnerPatch.cs @@ -0,0 +1,22 @@ +using Aki.Reflection.Patching; +using Aki.Reflection.Utils; +using System.Reflection; +using EFT; + +namespace SkinHide.Patches +{ + public class BotOwnerPatch : ModulePatch + { + + protected override MethodBase GetTargetMethod() + { + return typeof(BotOwner).GetMethod("method_4", PatchConstants.PrivateFlags); + } + + [PatchPostfix] + private static void PatchPostfix(BotOwner __instance) + { + SkinHidePlugin.Bot.Add(__instance.gameObject); + } + } +} diff --git a/SkinHide/Patches/GamePlayerOwnerPatch.cs b/SkinHide/Patches/GamePlayerOwnerPatch.cs new file mode 100644 index 0000000..043ca38 --- /dev/null +++ b/SkinHide/Patches/GamePlayerOwnerPatch.cs @@ -0,0 +1,22 @@ +using Aki.Reflection.Patching; +using Aki.Reflection.Utils; +using System.Reflection; +using EFT; + +namespace SkinHide.Patches +{ + public class GamePlayerOwnerPatch : ModulePatch + { + + protected override MethodBase GetTargetMethod() + { + return typeof(GamePlayerOwner).GetMethod("method_6", PatchConstants.PrivateFlags); + } + + [PatchPostfix] + private static void PatchPostfix(GamePlayerOwner __instance) + { + SkinHidePlugin.Player = __instance.gameObject; + } + } +} diff --git a/SkinHide/Patches/PlayerModelViewPatch.cs b/SkinHide/Patches/PlayerModelViewPatch.cs new file mode 100644 index 0000000..05fb2ec --- /dev/null +++ b/SkinHide/Patches/PlayerModelViewPatch.cs @@ -0,0 +1,25 @@ +using Aki.Reflection.Patching; +using Aki.Reflection.Utils; +using System.Reflection; +using EFT.UI; +using System.Threading.Tasks; + +namespace SkinHide.Patches +{ + public class PlayerModelViewPatch : ModulePatch + { + + protected override MethodBase GetTargetMethod() + { + return typeof(PlayerModelView).GetMethod("method_0", PatchConstants.PrivateFlags); + } + + [PatchPostfix] + private static async void PatchPostfix(Task __result, PlayerModelView __instance) + { + await __result; + + SkinHidePlugin.PlayerModelView = __instance.gameObject; + } + } +} diff --git a/SkinHide/Properties/AssemblyInfo.cs b/SkinHide/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e08b758 --- /dev/null +++ b/SkinHide/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("kmyuhkyuk-SkinHide")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SkinHide")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("e5dd6484-115e-4104-aadf-e5610ee4f397")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SkinHide/SkinHide.csproj b/SkinHide/SkinHide.csproj new file mode 100644 index 0000000..1d7dfe7 --- /dev/null +++ b/SkinHide/SkinHide.csproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + {E5DD6484-115E-4104-AADF-E5610EE4F397} + Library + Properties + SkinHide + SkinHide + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + kmyuhkyuk.pfx + + + + R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll + + + False + R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll + + + R:\Battlestate Games\Client.0.12.12.15.17349\BepInEx\core\BepInEx.dll + + + + + + + + + + + + False + R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\UnityEngine.dll + + + False + R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\UnityEngine.AnimationModule.dll + + + False + R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SkinHide/SkinHidePlugin.cs b/SkinHide/SkinHidePlugin.cs new file mode 100644 index 0000000..bfb0ccd --- /dev/null +++ b/SkinHide/SkinHidePlugin.cs @@ -0,0 +1,142 @@ +using BepInEx; +using BepInEx.Configuration; +using UnityEngine; +using SkinHide.Patches; +using EFT.Visual; +using System.Collections.Generic; + +namespace SkinHide +{ + [BepInPlugin("com.kmyuhkyuk.SkinHide", "kmyuhkyuk-SkinHide", "1.0.0")] + public class SkinHidePlugin : BaseUnityPlugin + { + public static GameObject Player; + + public static GameObject PlayerModelView; + + public SkinDress[] PlayerMVSkinDress; + + public Dress[] PlayerMVDress; + + public SkinDress[] PlayerSkinDress; + + public Dress[] PlayerDress; + + public HashSet PlayerSkinGameObject = new HashSet(); + + public static List Bot = new List(); + + public HashSet BotSkinGameObject = new HashSet(); + + public SkinDress[] BotSkinDress; + + public Dress[] BotDress; + + public static ConfigEntry KeyPlayerSkinHide { get; set; } + public static ConfigEntry KeyBotSkinHide { get; set; } + + private void Start() + { + Logger.LogInfo("Loaded: kmyuhkyuk-SkinHide"); + KeyPlayerSkinHide = Config.Bind("玩家服装隐藏 Player Skin Hide", "开关 Swithc", false); + KeyBotSkinHide = Config.Bind("Bot服装隐藏 Bot Skin Hide", "开关 Swithc", false); + + new PlayerModelViewPatch().Enable(); + new GamePlayerOwnerPatch().Enable(); + new BotOwnerPatch().Enable(); + } + void Update() + { + if (PlayerModelView != null && KeyPlayerSkinHide.Value) + { + PlayerMVSkinDress = PlayerModelView.GetComponentsInChildren(); + PlayerMVDress = PlayerModelView.GetComponentsInChildren(); + + if (PlayerMVSkinDress != null) + { + foreach (SkinDress skindress in PlayerMVSkinDress) + { + skindress.gameObject.SetActive(false); + } + } + if (PlayerMVDress != null) + { + foreach (Dress dress in PlayerMVDress) + { + dress.gameObject.SetActive(false); + } + } + } + if (Player != null) + { + PlayerSkinDress = Player.GetComponentsInChildren(); + PlayerDress = Player.GetComponentsInChildren(); + + if (PlayerSkinDress != null) + { + foreach (SkinDress skindress in PlayerSkinDress) + { + PlayerSkinGameObject.Add(skindress.gameObject); + } + } + if (PlayerDress != null) + { + foreach (Dress dress in PlayerDress) + { + PlayerSkinGameObject.Add(dress.gameObject); + } + } + + if (PlayerSkinGameObject != null) + { + foreach (GameObject skin in PlayerSkinGameObject) + { + skin.SetActive(!KeyPlayerSkinHide.Value); + } + } + } + else + { + PlayerSkinGameObject.Clear(); + } + + Bot.RemoveAll(x => x == null); + if (Bot.Count > 0) + { + foreach (GameObject bot in Bot) + { + BotSkinDress = bot.GetComponentsInChildren(); + BotDress = bot.GetComponentsInChildren(); + } + + if (BotSkinDress != null) + { + foreach (SkinDress botskindess in BotSkinDress) + { + BotSkinGameObject.Add(botskindess.gameObject); + } + } + if (BotDress != null) + { + foreach (Dress botdess in BotDress) + { + BotSkinGameObject.Add(botdess.gameObject); + } + } + + if (BotSkinGameObject != null) + { + foreach (GameObject botskin in BotSkinGameObject) + { + botskin.SetActive(!KeyBotSkinHide.Value); + } + } + } + else + { + BotSkinGameObject.Clear(); + } + } + + } +} \ No newline at end of file