using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FullBodyMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FullBodyMod")]
[assembly: AssemblyTitle("FullBodyMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FullBodyMod;
[BepInPlugin("yourname.fullbodyvisible", "Full Body Visible", "1.0.0")]
public class FullBodyPlugin : BaseUnityPlugin
{
public const string PluginGuid = "yourname.fullbodyvisible";
public const string PluginName = "Full Body Visible";
public const string PluginVersion = "1.0.0";
internal const float CAMERA_FORWARD_OFFSET = 0.8f;
internal static ManualLogSource Log;
internal static ConfigEntry<bool> ModEnabled;
private void Awake()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "true = мод работает (тело видно вне регдолла, смещённая камера). false = полностью ванильное поведение.");
new Harmony("yourname.fullbodyvisible").PatchAll();
Log.LogInfo((object)string.Format("{0} v{1} загружен. ModEnabled={2}", "Full Body Visible", "1.0.0", ModEnabled.Value));
}
}
[HarmonyPatch(typeof(MainCameraMovement), "GetHeadOffset")]
internal static class MainCameraMovement_GetHeadOffset_Patch
{
[HarmonyPostfix]
private static void Postfix(ref float __result)
{
if (FullBodyPlugin.ModEnabled.Value)
{
bool flag = (Object)(object)Character.localCharacter != (Object)null && Character.localCharacter.data.isClimbing;
__result = (flag ? 0f : 0.8f);
}
}
}
[HarmonyPatch(typeof(MainCameraMovement), "CharacterCam")]
internal static class MainCameraMovement_CharacterCam_Patch
{
private static readonly FieldInfo RagdollCamField = AccessTools.Field(typeof(MainCameraMovement), "ragdollCam");
private static readonly FieldInfo TargetPovField = AccessTools.Field(typeof(MainCameraMovement), "targetPlayerPovPosition");
private static readonly MethodInfo GetHeadOffsetMethod = AccessTools.Method(typeof(MainCameraMovement), "GetHeadOffset", (Type[])null, (Type[])null);
private static readonly MethodInfo GetCameraPosMethod = AccessTools.Method(typeof(Character), "GetCameraPos", new Type[1] { typeof(float) }, (Type[])null);
private static readonly MethodInfo GetBodypartMethod = AccessTools.Method(typeof(Character), "GetBodypart", new Type[1] { typeof(BodypartType) }, (Type[])null);
[HarmonyPostfix]
private static void Postfix(MainCameraMovement __instance)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
if (!FullBodyPlugin.ModEnabled.Value)
{
return;
}
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter == (Object)null)
{
return;
}
float num = (float)RagdollCamField.GetValue(__instance);
if (!(num <= 0f))
{
float num2 = (float)GetHeadOffsetMethod.Invoke(__instance, null);
Vector3 val = (Vector3)GetCameraPosMethod.Invoke(localCharacter, new object[1] { num2 });
object? obj = GetBodypartMethod.Invoke(localCharacter, new object[1] { (object)(BodypartType)4 });
Bodypart val2 = (Bodypart)((obj is Bodypart) ? obj : null);
if (!((Object)(object)val2 == (Object)null))
{
Vector3 position = val2.transform.position;
Vector3 val3 = Vector3.Lerp(val, position, num);
TargetPovField.SetValue(__instance, val3);
}
}
}
}
[HarmonyPatch(typeof(HideTheBody), "Update")]
internal static class HideTheBody_Update_Patch
{
private static readonly FieldInfo CharacterField = AccessTools.Field(typeof(HideTheBody), "character");
private const float RAGDOLL_CONTROL_THRESHOLD = 0.99f;
private const float SHOW_DELAY_AFTER_RAGDOLL = 3f;
private static bool s_wasInRagdoll = false;
private static float s_ragdollExitTime = -1f;
[HarmonyPostfix]
private static void Postfix(HideTheBody __instance)
{
object? value = CharacterField.GetValue(__instance);
Character val = (Character)((value is Character) ? value : null);
if ((Object)(object)val == (Object)null || !val.IsLocal)
{
return;
}
float num;
if (!FullBodyPlugin.ModEnabled.Value)
{
s_wasInRagdoll = false;
s_ragdollExitTime = -1f;
num = 1f;
}
else
{
bool num2 = val.data.currentRagdollControll < 0.99f;
if (num2)
{
s_wasInRagdoll = true;
s_ragdollExitTime = -1f;
}
else if (s_wasInRagdoll)
{
s_wasInRagdoll = false;
s_ragdollExitTime = Time.time;
}
bool flag = !num2 && (s_ragdollExitTime < 0f || Time.time - s_ragdollExitTime >= 3f);
num = (flag ? 0f : 1f);
}
__instance.SetShowing((Renderer)(object)__instance.body, num);
if ((Object)(object)__instance.sash != (Object)null)
{
__instance.SetShowing((Renderer)(object)__instance.sash, num);
}
if ((Object)(object)__instance.medal != (Object)null)
{
__instance.SetShowing(__instance.medal, num);
}
if (__instance.costumes == null)
{
return;
}
SkinnedMeshRenderer[] costumes = __instance.costumes;
foreach (SkinnedMeshRenderer val2 in costumes)
{
if ((Object)(object)val2 != (Object)null)
{
__instance.SetShowing((Renderer)(object)val2, num);
}
}
}
}