HideDress/SkinHide/Patches/PlayerPatch.cs

51 lines
1.2 KiB
C#
Raw Normal View History

2022-08-17 10:03:42 +08:00
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using System.Reflection;
using System.Threading.Tasks;
2022-09-11 19:51:27 +08:00
using Comfort.Common;
2022-08-17 10:03:42 +08:00
using EFT;
namespace SkinHide.Patches
{
public class PlayerPatch : ModulePatch
{
2022-09-11 19:51:27 +08:00
private static bool? Is231Up;
2022-08-17 10:03:42 +08:00
protected override MethodBase GetTargetMethod()
{
return typeof(Player).GetMethod("Init", PatchConstants.PrivateFlags);
}
[PatchPostfix]
private async static void PatchPostfix(Task __result, Player __instance)
{
await __result;
2022-09-11 19:51:27 +08:00
if (!Is231Up.HasValue)
{
Is231Up = typeof(Player).GetProperty("IsYourPlayer").GetSetMethod() == null;
}
bool isyouplayer;
if ((bool)Is231Up)
{
isyouplayer = __instance.IsYourPlayer;
}
else
{
2022-10-07 02:07:05 +08:00
isyouplayer = __instance == Singleton<GameWorld>.Instance.AllPlayers[0];
2022-09-11 19:51:27 +08:00
}
if (isyouplayer)
2022-08-17 10:03:42 +08:00
{
2022-08-31 23:12:17 +08:00
SkinHidePlugin.Player = __instance.PlayerBody;
2022-08-17 10:03:42 +08:00
}
2022-08-17 10:11:39 +08:00
else
{
2022-08-31 23:12:17 +08:00
SkinHidePlugin.Bot.Add(__instance.PlayerBody);
2022-08-17 10:11:39 +08:00
}
2022-08-17 10:03:42 +08:00
}
}
}