diff --git a/SkinHide/Patches/BotOwnerPatch.cs b/SkinHide/Patches/BotOwnerPatch.cs index 3540ff5..7eb3e4e 100644 --- a/SkinHide/Patches/BotOwnerPatch.cs +++ b/SkinHide/Patches/BotOwnerPatch.cs @@ -7,7 +7,6 @@ namespace SkinHide.Patches { public class BotOwnerPatch : ModulePatch { - protected override MethodBase GetTargetMethod() { return typeof(BotOwner).GetMethod("method_4", PatchConstants.PrivateFlags); diff --git a/SkinHide/Properties/AssemblyInfo.cs b/SkinHide/Properties/AssemblyInfo.cs index e08b758..cc171ca 100644 --- a/SkinHide/Properties/AssemblyInfo.cs +++ b/SkinHide/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/SkinHide/SkinHide.csproj b/SkinHide/SkinHide.csproj index 1d7dfe7..c0ff4dc 100644 --- a/SkinHide/SkinHide.csproj +++ b/SkinHide/SkinHide.csproj @@ -37,6 +37,10 @@ kmyuhkyuk.pfx + + False + R:\Battlestate Games\Client.0.12.12.15.17349\BepInEx\core\0Harmony.dll + R:\Battlestate Games\Client.0.12.12.15.17349\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll diff --git a/SkinHide/SkinHidePlugin.cs b/SkinHide/SkinHidePlugin.cs index 16f7fa5..f6efee4 100644 --- a/SkinHide/SkinHidePlugin.cs +++ b/SkinHide/SkinHidePlugin.cs @@ -2,12 +2,13 @@ using BepInEx.Configuration; using UnityEngine; using SkinHide.Patches; +using EFT; using EFT.Visual; using System.Collections.Generic; namespace SkinHide { - [BepInPlugin("com.kmyuhkyuk.SkinHide", "kmyuhkyuk-SkinHide", "1.0.0")] + [BepInPlugin("com.kmyuhkyuk.SkinHide", "kmyuhkyuk-SkinHide", "1.1.0")] public class SkinHidePlugin : BaseUnityPlugin { public static GameObject Player; @@ -24,22 +25,27 @@ namespace SkinHide public HashSet PlayerSkinGameObject = new HashSet(); + public HashSet PlayerDressGameObject = new HashSet(); + public static List Bot = new List(); - public SkinDress[] BotSkinDress; - - public Dress[] BotDress; - public HashSet BotSkinGameObject = new HashSet(); + public HashSet BotDressGameObject = new HashSet(); + public static ConfigEntry KeyPlayerSkinHide { get; set; } public static ConfigEntry KeyBotSkinHide { get; set; } + public static ConfigEntry KeyBotSkinHideShutDown { 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); + + string SkinHide = "Skin Hide"; + KeyPlayerSkinHide = Config.Bind(SkinHide, "玩家服装隐藏 Player Skin Hide", false); + KeyBotSkinHide = Config.Bind(SkinHide, "Bot服装隐藏 Bot Skin Hide", false); + KeyBotSkinHideShutDown = Config.Bind(SkinHide, "Bot服装隐藏功能关闭 Bot Skin Hide Function Shut Down", false, "Many Bot corpse will cause lag, turn the switch off Bot Skin Scan."); new PlayerModelViewPatch().Enable(); new GamePlayerOwnerPatch().Enable(); @@ -74,10 +80,10 @@ namespace SkinHide if (Player != null) { //Get Player all SkinDress and Dress - PlayerSkinDress = Player.GetComponentsInChildren(); - PlayerDress = Player.GetComponentsInChildren(); + PlayerSkinDress = Player.transform.Find("Player/Mesh").gameObject.GetComponentsInChildren(); + PlayerDress = Player.transform.Find("Player/Root_Joint").gameObject.GetComponentsInChildren(); - //False SkinDress and Dress GameObject + //False SkinDress GameObject if (PlayerSkinDress != null) { foreach (SkinDress skindress in PlayerSkinDress) @@ -89,16 +95,65 @@ namespace SkinHide { foreach (Dress dress in PlayerDress) { - PlayerSkinGameObject.Add(dress.gameObject); + PlayerDressGameObject.Add(dress.gameObject); } } - //false or true SkinDress and Dress GameObject + //Hide Dress GameObject + if (PlayerDressGameObject != null) + { + List Loot = new List(); + + foreach (GameObject dress in PlayerDressGameObject) + { + MeshRenderer[] MeshRenderer = dress.GetComponentsInChildren(); + + //Loot False Hide + if (dress != null && dress.GetComponentInParent() != null) + { + foreach (MeshRenderer mesh in MeshRenderer) + { + mesh.enabled = !KeyPlayerSkinHide.Value; + } + } + else + { + foreach (MeshRenderer mesh in MeshRenderer) + { + mesh.enabled = true; + } + Loot.Add(dress); + } + } + + if (Loot != null) + { + PlayerDressGameObject.ExceptWith(Loot); + } + } + + //False or true SkinDress and Dress GameObject if (PlayerSkinGameObject != null) { + List Loot = new List(); + foreach (GameObject skin in PlayerSkinGameObject) { - skin.SetActive(!KeyPlayerSkinHide.Value); + if (skin != null && skin.GetComponentInParent() != null) + { + skin.SetActive(!KeyPlayerSkinHide.Value); + } + else + { + skin.SetActive(true); + + Loot.Add(skin); + } + } + + if (Loot != null) + { + PlayerSkinGameObject.ExceptWith(Loot); } } } @@ -106,41 +161,87 @@ namespace SkinHide { //Quit Raid Clear GameObject List PlayerSkinGameObject.Clear(); + PlayerDressGameObject.Clear(); } //Clear List null Bot Bot.RemoveAll(x => x == null); //Bot Skin Hide - if (Bot.Count > 0) + if (Bot != null && !KeyBotSkinHideShutDown.Value) { //Get Bot all SkinDress and Dress foreach (GameObject bot in Bot) { - BotSkinDress = bot.GetComponentsInChildren(); - BotDress = bot.GetComponentsInChildren(); - } + SkinDress[] botskindress = bot.transform.Find("Player/Mesh").gameObject.GetComponentsInChildren(); - if (BotSkinDress != null) - { - foreach (SkinDress botskindess in BotSkinDress) + foreach (SkinDress skinDress in botskindress) { - BotSkinGameObject.Add(botskindess.gameObject); + BotSkinGameObject.Add(skinDress.gameObject); } - } - if (BotDress != null) - { - foreach (Dress botdess in BotDress) + + Dress[] botDress = bot.transform.Find("Player/Root_Joint").gameObject.GetComponentsInChildren(); + + foreach (Dress Dress in botDress) { - BotSkinGameObject.Add(botdess.gameObject); + BotDressGameObject.Add(Dress.gameObject); } } - //False or true SkinDress and Dress GameObject + //Hide Dress GameObject + if (BotDressGameObject != null) + { + List Loot = new List(); + + foreach (GameObject botdress in BotDressGameObject) + { + MeshRenderer[] MeshRenderer = botdress.GetComponentsInChildren(); + + //Loot False Hide + if (botdress.GetComponentInParent() != null) + { + foreach (MeshRenderer botmesh in MeshRenderer) + { + botmesh.enabled = !KeyBotSkinHide.Value; + } + } + else + { + foreach (MeshRenderer botmesh in MeshRenderer) + { + botmesh.enabled = true; + } + Loot.Add(botdress); + } + } + + if (Loot != null) + { + BotDressGameObject.ExceptWith(Loot); + } + } + + //False or true SkinDress GameObject if (BotSkinGameObject != null) { + List Loot = new List(); + foreach (GameObject botskin in BotSkinGameObject) { - botskin.SetActive(!KeyBotSkinHide.Value); + if (botskin.GetComponentInParent() != null) + { + botskin.SetActive(!KeyBotSkinHide.Value); + } + else + { + botskin.SetActive(true); + + Loot.Add(botskin); + } + } + + if (Loot != null) + { + BotSkinGameObject.ExceptWith(Loot); } } } @@ -148,6 +249,7 @@ namespace SkinHide { //Quit Raid Clear GameObject List BotSkinGameObject.Clear(); + BotDressGameObject.Clear(); } }