From 4e2ecdb755ca7b64ced2f0645326e6991fc80a3a Mon Sep 17 00:00:00 2001 From: kmyuhkyuk <2451614940@qq.com> Date: Wed, 17 Aug 2022 10:03:42 +0800 Subject: [PATCH] Update --- SkinHide/Patches/GamePlayerOwnerPatch.cs | 21 ------------------ SkinHide/Patches/PlayerPatch.cs | 27 ++++++++++++++++++++++++ SkinHide/SkinHide.csproj | 2 +- SkinHide/SkinHidePlugin.cs | 10 ++++----- 4 files changed, 33 insertions(+), 27 deletions(-) delete mode 100644 SkinHide/Patches/GamePlayerOwnerPatch.cs create mode 100644 SkinHide/Patches/PlayerPatch.cs diff --git a/SkinHide/Patches/GamePlayerOwnerPatch.cs b/SkinHide/Patches/GamePlayerOwnerPatch.cs deleted file mode 100644 index 448bc3d..0000000 --- a/SkinHide/Patches/GamePlayerOwnerPatch.cs +++ /dev/null @@ -1,21 +0,0 @@ -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.GetComponentInChildren(); - } - } -} diff --git a/SkinHide/Patches/PlayerPatch.cs b/SkinHide/Patches/PlayerPatch.cs new file mode 100644 index 0000000..7a2da40 --- /dev/null +++ b/SkinHide/Patches/PlayerPatch.cs @@ -0,0 +1,27 @@ +using Aki.Reflection.Patching; +using Aki.Reflection.Utils; +using System.Reflection; +using System.Threading.Tasks; +using EFT; + +namespace SkinHide.Patches +{ + public class PlayerPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(Player).GetMethod("Init", PatchConstants.PrivateFlags); + } + + [PatchPostfix] + private async static void PatchPostfix(Task __result, Player __instance) + { + await __result; + + if (__instance.IsYourPlayer) + { + SkinHidePlugin.Player = __instance.gameObject.GetComponentInChildren(); + } + } + } +} diff --git a/SkinHide/SkinHide.csproj b/SkinHide/SkinHide.csproj index c0ff4dc..9a367bf 100644 --- a/SkinHide/SkinHide.csproj +++ b/SkinHide/SkinHide.csproj @@ -75,7 +75,7 @@ - + diff --git a/SkinHide/SkinHidePlugin.cs b/SkinHide/SkinHidePlugin.cs index ea9faf5..9d7e567 100644 --- a/SkinHide/SkinHidePlugin.cs +++ b/SkinHide/SkinHidePlugin.cs @@ -53,7 +53,7 @@ namespace SkinHide KBSBotSkinHide = Config.Bind(KBSSettings, "Bot服装隐藏快捷键 Bot Skin Hide", KeyboardShortcut.Empty); new PlayerModelViewPatch().Enable(); - new GamePlayerOwnerPatch().Enable(); + new PlayerPatch().Enable(); new BotOwnerPatch().Enable(); } @@ -71,13 +71,13 @@ namespace SkinHide //PlayerModelView Skin Hide if (PlayerModelView != null) { - Hide(PlayerModelView, KeyPlayerSkinHide.Value, KeyPlayerSkinHidePart.Value); + Hide(PlayerModelView, KeyPlayerSkinHidePart.Value, KeyPlayerSkinHide.Value); } //Player Skin Hide if (Player != null) { - Hide(Player, KeyPlayerSkinHide.Value, KeyPlayerSkinHidePart.Value); + Hide(Player, KeyPlayerSkinHidePart.Value, KeyPlayerSkinHide.Value); } //Bot Skin Hide @@ -86,12 +86,12 @@ namespace SkinHide { foreach (PlayerBody bot in Bot) { - Hide(bot, KeyBotSkinHide.Value, KeyBotSkinHidePart.Value); + Hide(bot, KeyBotSkinHidePart.Value, KeyBotSkinHide.Value); } } } - void Hide(PlayerBody playerbody, bool hide, Part part) + void Hide(PlayerBody playerbody, Part part, bool hide) { object slotviews = Traverse.Create(playerbody).Field("SlotViews").GetValue();