HideDress/SkinHide/Patches/PlayerPatch.cs

47 lines
1.1 KiB
C#
Raw Normal View History

2022-08-17 10:03:42 +08:00
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
2023-01-05 08:49:34 +08:00
using System;
2022-08-17 10:03:42 +08:00
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
{
2023-01-05 08:49:34 +08:00
private static readonly bool Is231Up = SkinHidePlugin.GameVersion > new Version("0.12.12.17349");
2022-11-07 10:17:07 +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
2023-01-05 08:49:45 +08:00
if (Is231Up)
2022-09-11 19:51:27 +08:00
{
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
}
}
}