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-11-07 10:17:07 +08:00
|
|
|
|
private static bool Is231Up;
|
|
|
|
|
|
|
|
|
|
static PlayerPatch()
|
|
|
|
|
{
|
|
|
|
|
Is231Up = typeof(Player).GetProperty("IsYourPlayer").GetSetMethod() == null;
|
|
|
|
|
}
|
2022-09-11 19:51:27 +08:00
|
|
|
|
|
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-10-17 22:34:46 +08:00
|
|
|
|
bool isYouPlayer;
|
2022-09-11 19:51:27 +08:00
|
|
|
|
|
|
|
|
|
if ((bool)Is231Up)
|
|
|
|
|
{
|
2022-10-17 22:34:46 +08:00
|
|
|
|
isYouPlayer = __instance.IsYourPlayer;
|
2022-09-11 19:51:27 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-10-17 22:34:46 +08:00
|
|
|
|
isYouPlayer = __instance == Singleton<GameWorld>.Instance.AllPlayers[0];
|
2022-09-11 19:51:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-17 22:34:46 +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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|