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 static ManualLogSource Log;
internal static ConfigEntry<bool> ModEnabled;
internal static ConfigEntry<float> CameraForwardOffset;
internal static ConfigEntry<float> CameraSideOffset;
internal static ConfigEntry<float> CameraVerticalOffset;
private void Awake()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_00e7: 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 = полностью ванильное поведение.");
CameraForwardOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CameraForwardOffset", 0.8f, new ConfigDescription("Смещение камеры от первого лица вперёд(+)/назад(-). Заменяет штатный GetHeadOffset() игры, когда персонаж не ползёт/не карабкается.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
CameraSideOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CameraSideOffset", 0f, new ConfigDescription("Смещение камеры от первого лица вправо(+)/влево(-) относительно направления взгляда. Применяется поверх CameraForwardOffset, с проверкой на стены.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.1f, 0.1f), Array.Empty<object>()));
CameraVerticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CameraVerticalOffset", 0f, new ConfigDescription("Смещение камеры от первого лица вверх(+)/вниз(-) вдоль мировой вертикали, с проверкой на стены/потолок.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.1f, 0.1f), Array.Empty<object>()));
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 : FullBodyPlugin.CameraForwardOffset.Value);
}
}
}
[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);
}
}
}
}
[HarmonyPatch(typeof(MainCameraMovement), "CharacterCam")]
internal static class MainCameraMovement_CameraCollision_Patch
{
private static readonly MethodInfo GetBodypartMethod = AccessTools.Method(typeof(Character), "GetBodypart", new Type[1] { typeof(BodypartType) }, (Type[])null);
private const float SPHERECAST_RADIUS = 0.1f;
private const float BACKOFF_DISTANCE = 0.05f;
[HarmonyPostfix]
private static void Postfix(MainCameraMovement __instance)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: 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;
}
object? obj = GetBodypartMethod.Invoke(localCharacter, new object[1] { (object)(BodypartType)4 });
Bodypart val = (Bodypart)((obj is Bodypart) ? obj : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Vector3 position = val.transform.position;
float value = FullBodyPlugin.CameraSideOffset.Value;
if (Mathf.Abs(value) > 0.0001f)
{
Transform transform = ((Component)__instance).transform;
transform.position += ((Component)__instance).transform.right * value;
}
float value2 = FullBodyPlugin.CameraVerticalOffset.Value;
if (Mathf.Abs(value2) > 0.0001f)
{
Transform transform2 = ((Component)__instance).transform;
transform2.position += Vector3.up * value2;
}
Vector3 position2 = ((Component)__instance).transform.position;
if (!(Vector3.Distance(position, position2) < 0.001f))
{
RaycastHit val2 = HelperFunctions.LineCheck(position, position2, (LayerType)1, 0.1f, (QueryTriggerInteraction)1);
if ((Object)(object)((RaycastHit)(ref val2)).transform != (Object)null)
{
Vector3 val3 = position2 - position;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Mathf.Max(((RaycastHit)(ref val2)).distance - 0.05f, 0f);
((Component)__instance).transform.position = position + normalized * num;
}
}
}
}