This commit is contained in:
kmyuhkyuk 2022-08-17 10:03:42 +08:00
parent 1d30d38ede
commit 4e2ecdb755
4 changed files with 33 additions and 27 deletions

View File

@ -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<PlayerBody>();
}
}
}

View File

@ -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<PlayerBody>();
}
}
}
}

View File

@ -75,7 +75,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Patches\BotOwnerPatch.cs" />
<Compile Include="Patches\GamePlayerOwnerPatch.cs" />
<Compile Include="Patches\PlayerPatch.cs" />
<Compile Include="Patches\PlayerModelViewPatch.cs" />
<Compile Include="SkinHidePlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -53,7 +53,7 @@ namespace SkinHide
KBSBotSkinHide = Config.Bind<KeyboardShortcut>(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<object>();