using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("HitToTPoseMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HitToTPoseMod")]
[assembly: AssemblyTitle("HitToTPoseMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace HitToTPoseMod
{
public enum HitPoseType
{
Stand,
Surrender
}
[BepInPlugin("com.gtfo.hittotpose", "Hit To TPose", "1.3.5")]
public class Plugin : BasePlugin
{
public static ManualLogSource Logger;
public static ConfigEntry<HitPoseType> ConfigPoseType;
public static ConfigEntry<float> ConfigFreezeDuration;
public static ConfigEntry<float> ConfigCooldownDuration;
public static ConfigEntry<float> ConfigPalmTwistAngle;
public static ConfigEntry<bool> ConfigEnableToggleKey;
public static ConfigEntry<bool> ConfigSyncStandToVanillaClients;
public static ConfigEntry<bool> ConfigTriggerTentacle;
public static ConfigEntry<bool> ConfigTriggerShooter;
public static ConfigEntry<bool> ConfigTriggerEnemyMelee;
public static ConfigEntry<bool> ConfigTriggerFriendlyFire;
public static ConfigEntry<bool> ConfigTriggerAllDamage;
public override void Load()
{
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Expected O, but got Unknown
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
ConfigPoseType = ((BasePlugin)this).Config.Bind<HitPoseType>("PoseSettings", "PoseType", HitPoseType.Surrender, "挨打时的姿势选择:\nSurrender = 双手高举投降姿势(默认)\nStand = 立正姿势(A-Pose)");
ConfigFreezeDuration = ((BasePlugin)this).Config.Bind<float>("PoseSettings", "FreezeDuration", 0.5f, "挨打后触发第三人称定身与缴械的持续时间(秒)");
ConfigCooldownDuration = ((BasePlugin)this).Config.Bind<float>("PoseSettings", "CooldownDuration", 5f, "定身结束后的内置冷却免控时间(秒),防止被怪群围殴时无限罚站控到死(设为 0 则无冷却)");
ConfigPalmTwistAngle = ((BasePlugin)this).Config.Bind<float>("PoseSettings", "SurrenderPalmTwistAngle", 90f, "投降姿势下手掌绕手臂轴线的旋转角度(默认 90 度使手心朝正前方)");
ConfigTriggerTentacle = ((BasePlugin)this).Config.Bind<bool>("DamageTriggers", "TriggerOnTentacle", true, "【怪物舌头/触手】被怪物的舌头/触手攻击命中时是否触发(默认开启)");
ConfigTriggerShooter = ((BasePlugin)this).Config.Bind<bool>("DamageTriggers", "TriggerOnShooterProjectile", false, "【远程怪飞弹】被远程怪(Shooter等)发射的飞弹命中时是否触发(默认开启)");
ConfigTriggerEnemyMelee = ((BasePlugin)this).Config.Bind<bool>("DamageTriggers", "TriggerOnEnemyMelee", true, "【敌人近战】被敌人近身抓挠/挥击命中时是否触发(默认开启)");
ConfigTriggerFriendlyFire = ((BasePlugin)this).Config.Bind<bool>("DamageTriggers", "EnableFriendlyFireTrigger", true, "【队友友伤】被队友枪械子弹或哨戒炮误伤时是否触发(默认开启)");
ConfigTriggerAllDamage = ((BasePlugin)this).Config.Bind<bool>("DamageTriggers", "TriggerOnAllDamage", false, "【所有伤害(非默认)】受到任何伤害(包含高处摔落、地雷爆炸、毒气等一切扣血)均触发(默认关闭,开启后将无视上方单项过滤)");
ConfigSyncStandToVanillaClients = ((BasePlugin)this).Config.Bind<bool>("NetworkSync", "SyncStandPoseToVanillaClients", true, "是否通过伪造原版网络状态包(OnTerminal 敲终端直立姿态 + 隐藏手中武器),让未安装本 Mod 的客机也能看到你卸下端枪架势原地立正定身");
ConfigEnableToggleKey = ((BasePlugin)this).Config.Bind<bool>("Hotkeys", "EnableF4TogglePose", true, "是否允许在游戏内按 F4 键快捷切换【投降/立正】姿势");
ClassInjector.RegisterTypeInIl2Cpp<ThirdPersonFreezeController>();
GameObject val = new GameObject("HitToTPoseController");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<ThirdPersonFreezeController>();
new Harmony("com.gtfo.hittotpose").PatchAll();
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(48, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[HitToTPose 1.3.5] 加载成功!当前姿势: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<HitPoseType>(ConfigPoseType.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", 定身时长: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(ConfigFreezeDuration.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("s, 免控冷却: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(ConfigCooldownDuration.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("s");
}
logger.LogInfo(val2);
}
}
public static class PoseHelper
{
public static void ApplyConfiguredPose(GameObject modelRoot, Animator anim = null)
{
if (!((Object)(object)modelRoot == (Object)null) && (Plugin.ConfigPoseType == null || Plugin.ConfigPoseType.Value != HitPoseType.Stand))
{
ApplySurrenderPose(modelRoot, anim);
}
}
public static void ApplySurrenderPose(GameObject modelRoot, Animator anim = null)
{
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
//IL_049d: Unknown result type (might be due to invalid IL or missing references)
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_0514: Unknown result type (might be due to invalid IL or missing references)
//IL_0516: Unknown result type (might be due to invalid IL or missing references)
//IL_051d: Unknown result type (might be due to invalid IL or missing references)
//IL_0522: Unknown result type (might be due to invalid IL or missing references)
//IL_0527: Unknown result type (might be due to invalid IL or missing references)
//IL_052b: Unknown result type (might be due to invalid IL or missing references)
//IL_0530: Unknown result type (might be due to invalid IL or missing references)
//IL_0532: Unknown result type (might be due to invalid IL or missing references)
//IL_0539: Unknown result type (might be due to invalid IL or missing references)
//IL_053e: Unknown result type (might be due to invalid IL or missing references)
//IL_0543: Unknown result type (might be due to invalid IL or missing references)
//IL_0547: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)modelRoot == (Object)null)
{
return;
}
if ((Object)(object)anim == (Object)null)
{
anim = modelRoot.GetComponent<Animator>();
}
Transform val = null;
Transform val2 = null;
Transform val3 = null;
Transform val4 = null;
Transform val5 = null;
Transform val6 = null;
if ((Object)(object)anim != (Object)null && anim.isHuman)
{
try
{
val = anim.GetBoneTransform((HumanBodyBones)13);
val2 = anim.GetBoneTransform((HumanBodyBones)15);
val3 = anim.GetBoneTransform((HumanBodyBones)17);
val4 = anim.GetBoneTransform((HumanBodyBones)14);
val5 = anim.GetBoneTransform((HumanBodyBones)16);
val6 = anim.GetBoneTransform((HumanBodyBones)18);
}
catch
{
}
}
if ((Object)(object)val == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val5 == (Object)null)
{
Il2CppArrayBase<Transform> componentsInChildren = modelRoot.GetComponentsInChildren<Transform>(true);
foreach (Transform item in componentsInChildren)
{
if ((Object)(object)item == (Object)null || string.IsNullOrEmpty(((Object)item).name))
{
continue;
}
string text = ((Object)item).name.ToLowerInvariant();
if (text.Contains("mesh") || text.Contains("vfx") || text.Contains("ik"))
{
continue;
}
bool flag = text.Contains("left") || text.Contains("l_") || text.Contains("_l") || text.Contains(".l");
bool flag2 = text.Contains("right") || text.Contains("r_") || text.Contains("_r") || text.Contains(".r");
if (flag)
{
if ((Object)(object)val == (Object)null && (text.Contains("upperarm") || text.Contains("uparm") || (text.Contains("arm") && !text.Contains("fore") && !text.Contains("low"))))
{
val = item;
}
else if ((Object)(object)val2 == (Object)null && (text.Contains("forearm") || text.Contains("lowerarm") || text.Contains("loarm") || text.Contains("elbow")))
{
val2 = item;
}
else if ((Object)(object)val3 == (Object)null && (text.Contains("hand") || text.Contains("wrist")))
{
val3 = item;
}
}
else if (flag2)
{
if ((Object)(object)val4 == (Object)null && (text.Contains("upperarm") || text.Contains("uparm") || (text.Contains("arm") && !text.Contains("fore") && !text.Contains("low"))))
{
val4 = item;
}
else if ((Object)(object)val5 == (Object)null && (text.Contains("forearm") || text.Contains("lowerarm") || text.Contains("loarm") || text.Contains("elbow")))
{
val5 = item;
}
else if ((Object)(object)val6 == (Object)null && (text.Contains("hand") || text.Contains("wrist")))
{
val6 = item;
}
}
}
}
if ((Object)(object)val != (Object)null && (Object)(object)val2 == (Object)null && val.childCount > 0)
{
val2 = val.GetChild(0);
}
if ((Object)(object)val2 != (Object)null && (Object)(object)val3 == (Object)null && val2.childCount > 0)
{
val3 = val2.GetChild(0);
}
if ((Object)(object)val4 != (Object)null && (Object)(object)val5 == (Object)null && val4.childCount > 0)
{
val5 = val4.GetChild(0);
}
if ((Object)(object)val5 != (Object)null && (Object)(object)val6 == (Object)null && val5.childCount > 0)
{
val6 = val5.GetChild(0);
}
Transform transform = modelRoot.transform;
Vector3 up = transform.up;
Vector3 right = transform.right;
Vector3 forward = transform.forward;
float num = ((Plugin.ConfigPalmTwistAngle != null) ? Plugin.ConfigPalmTwistAngle.Value : 90f);
Transform upperArm = val;
Transform lowerArm = val2;
Transform hand = val3;
Vector3 val7 = -right + up * 0.15f;
Vector3 normalized = ((Vector3)(ref val7)).normalized;
val7 = up + forward * 0.08f;
BendArmToSurrender(upperArm, lowerArm, hand, normalized, ((Vector3)(ref val7)).normalized, num);
Transform upperArm2 = val4;
Transform lowerArm2 = val5;
Transform hand2 = val6;
val7 = right + up * 0.15f;
Vector3 normalized2 = ((Vector3)(ref val7)).normalized;
val7 = up + forward * 0.08f;
BendArmToSurrender(upperArm2, lowerArm2, hand2, normalized2, ((Vector3)(ref val7)).normalized, 0f - num);
}
private static void BendArmToSurrender(Transform upperArm, Transform lowerArm, Transform hand, Vector3 targetUpperDir, Vector3 targetLowerDir, float twistAngle)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: 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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)upperArm == (Object)null || (Object)(object)lowerArm == (Object)null)
{
return;
}
Vector3 val = lowerArm.position - upperArm.position;
if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
{
Quaternion val2 = Quaternion.FromToRotation(((Vector3)(ref val)).normalized, targetUpperDir);
upperArm.rotation = val2 * upperArm.rotation;
}
Vector3 val3 = Vector3.zero;
if ((Object)(object)hand != (Object)null)
{
val3 = hand.position - lowerArm.position;
}
else if (lowerArm.childCount > 0)
{
val3 = lowerArm.GetChild(0).position - lowerArm.position;
}
if (!(((Vector3)(ref val3)).sqrMagnitude > 0.0001f))
{
return;
}
Quaternion val4 = Quaternion.FromToRotation(((Vector3)(ref val3)).normalized, targetLowerDir);
lowerArm.rotation = val4 * lowerArm.rotation;
if (Mathf.Abs(twistAngle) > 0.01f)
{
if ((Object)(object)hand != (Object)null)
{
Quaternion val5 = Quaternion.AngleAxis(twistAngle * 0.5f, targetLowerDir);
lowerArm.rotation = val5 * lowerArm.rotation;
hand.rotation = val5 * hand.rotation;
}
else
{
Quaternion val6 = Quaternion.AngleAxis(twistAngle, targetLowerDir);
lowerArm.rotation = val6 * lowerArm.rotation;
}
}
}
}
public class ThirdPersonFreezeController : MonoBehaviour
{
public static float LocalDisarmTimer = 0f;
public static bool IsInThirdPerson = false;
public static Vector3 LockedPosition = Vector3.zero;
public static Quaternion LockedRotation = Quaternion.identity;
private static Dictionary<Transform, Vector3> _savedFpScales = new Dictionary<Transform, Vector3>();
private static Dictionary<Renderer, bool> _savedAllLocalRenderers = new Dictionary<Renderer, bool>();
private static GameObject _localTPoseDummy = null;
private static InventorySlot _savedWieldedSlot = (InventorySlot)0;
private static bool _hasNetworkPoseOverride = false;
public static bool IsSendingRestoredPacket = false;
public void Update()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
if (Plugin.ConfigEnableToggleKey != null && Plugin.ConfigEnableToggleKey.Value && Input.GetKeyDown((KeyCode)285) && Plugin.ConfigPoseType != null)
{
Plugin.ConfigPoseType.Value = ((Plugin.ConfigPoseType.Value != HitPoseType.Surrender) ? HitPoseType.Surrender : HitPoseType.Stand);
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[HitToTPose] 姿势已切换为: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<HitPoseType>(Plugin.ConfigPoseType.Value);
}
logger.LogInfo(val);
}
if (LocalDisarmTimer > 0f)
{
LocalDisarmTimer -= Time.deltaTime;
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if ((Object)(object)localPlayerAgent != (Object)null && ((Agent)localPlayerAgent).Alive)
{
EnforceDisarmAndFreeze(localPlayerAgent);
}
if (LocalDisarmTimer <= 0f || (Object)(object)localPlayerAgent == (Object)null || !((Agent)localPlayerAgent).Alive)
{
LocalDisarmTimer = 0f;
RestoreFirstPersonAndControl();
}
}
}
public void LateUpdate()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
if (LocalDisarmTimer <= 0f || !IsInThirdPerson)
{
return;
}
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if (!((Object)(object)localPlayerAgent == (Object)null) && ((Agent)localPlayerAgent).Alive)
{
EnforceDisarmAndFreeze(localPlayerAgent);
if ((Object)(object)_localTPoseDummy != (Object)null)
{
_localTPoseDummy.transform.position = LockedPosition;
_localTPoseDummy.transform.rotation = LockedRotation;
}
}
}
public static void ApplyThirdPersonCameraOffset(Camera cam)
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: 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_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
if (!IsInThirdPerson || LocalDisarmTimer <= 0f || (Object)(object)cam == (Object)null)
{
return;
}
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if ((Object)(object)localPlayerAgent == (Object)null || !((Agent)localPlayerAgent).Alive || (Object)(object)localPlayerAgent.FPSCamera == (Object)null || ((Object)(object)((Component)cam).gameObject != (Object)(object)((Component)localPlayerAgent.FPSCamera).gameObject && !((Component)cam).transform.IsChildOf(((Component)localPlayerAgent.FPSCamera).transform) && (Object)(object)cam != (Object)(object)Camera.main))
{
return;
}
foreach (KeyValuePair<Renderer, bool> savedAllLocalRenderer in _savedAllLocalRenderers)
{
if ((Object)(object)savedAllLocalRenderer.Key != (Object)null && savedAllLocalRenderer.Key.enabled)
{
savedAllLocalRenderer.Key.enabled = false;
}
}
Vector3 val = LockedPosition + Vector3.up * 1.35f;
Vector3 val2 = -((Component)cam).transform.forward;
float num = 2.5f;
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(val, val2, ref val3, num, LayerMask.GetMask(new string[2] { "Default", "LevelGeometry" })))
{
num = Mathf.Max(0.4f, ((RaycastHit)(ref val3)).distance - 0.2f);
}
((Component)cam).transform.position = val + val2 * num;
}
public static void StartThirdPersonAndLock(PlayerAgent local)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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_009b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)local == (Object)null)
{
return;
}
if (!IsInThirdPerson)
{
IsInThirdPerson = true;
LockedPosition = ((Component)local).transform.position;
Vector3 forward = ((Component)local).transform.forward;
if ((Object)(object)local.FPSCamera != (Object)null)
{
forward = ((Component)local.FPSCamera).transform.forward;
forward.y = 0f;
}
LockedRotation = ((((Vector3)(ref forward)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(((Vector3)(ref forward)).normalized) : ((Component)local).transform.rotation);
_savedFpScales.Clear();
_savedAllLocalRenderers.Clear();
bool hasDummy = SpawnFullTPoseDummyAtLockedPos(local);
HideAllLocalPlayerModels(local, hasDummy);
BroadcastStandPoseToVanillaClients(local);
Camera.onPreCull += CameraCallback.op_Implicit((Action<Camera>)ApplyThirdPersonCameraOffset);
}
EnforceDisarmAndFreeze(local);
}
private static void BroadcastStandPoseToVanillaClients(PlayerAgent local)
{
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Invalid comparison between Unknown and I4
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.ConfigSyncStandToVanillaClients != null && !Plugin.ConfigSyncStandToVanillaClients.Value)
{
return;
}
try
{
_hasNetworkPoseOverride = true;
if ((Object)(object)local.Inventory != (Object)null && (int)local.Inventory.WieldedSlot > 0)
{
_savedWieldedSlot = local.Inventory.WieldedSlot;
}
if ((Object)(object)local.Sync != (Object)null)
{
local.Sync.WantsToWieldSlot((InventorySlot)0, false);
Vector3 val = LockedRotation * Vector3.forward;
local.Sync.SendLocomotion((PLOC_State)9, LockedPosition, val, 0f, 0f);
}
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[HitToTPose] 广播 OnTerminal 立正状态至客机时发生异常: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val2);
}
}
private static void RestoreNetworkPoseToVanillaClients(PlayerAgent local)
{
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Invalid comparison between Unknown and I4
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Invalid comparison between Unknown and I4
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
if (!_hasNetworkPoseOverride)
{
return;
}
_hasNetworkPoseOverride = false;
if ((Object)(object)local == (Object)null)
{
return;
}
try
{
IsSendingRestoredPacket = true;
if ((Object)(object)local.Sync != (Object)null && (Object)(object)local.Locomotion != (Object)null && ((Agent)local).Alive)
{
PLOC_State val = local.Locomotion.m_currentStateEnum;
if ((int)val == 9)
{
val = (PLOC_State)0;
}
Vector3 val2 = (((Object)(object)local.FPSCamera != (Object)null) ? ((Component)local.FPSCamera).transform.forward : ((Component)local).transform.forward);
local.Sync.SendLocomotion(val, ((Component)local).transform.position, val2, 0f, 0f);
}
if ((int)_savedWieldedSlot <= 0)
{
return;
}
if ((Object)(object)local.Sync != (Object)null)
{
local.Sync.WantsToWieldSlot(_savedWieldedSlot, false);
}
if ((Object)(object)local.Inventory != (Object)null && local.Inventory.WieldedSlot != _savedWieldedSlot && ((Agent)local).Alive)
{
PlayerSync sync = local.Sync;
if (sync != null)
{
sync.WantsToWieldSlot(_savedWieldedSlot, false);
}
}
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[HitToTPose] 恢复客机同步姿势时发生异常: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val3);
}
finally
{
_savedWieldedSlot = (InventorySlot)0;
IsSendingRestoredPacket = false;
}
}
private static bool SpawnFullTPoseDummyAtLockedPos(PlayerAgent local)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_localTPoseDummy != (Object)null)
{
Object.Destroy((Object)(object)_localTPoseDummy);
_localTPoseDummy = null;
}
GameObject val = null;
if ((Object)(object)local.AnimatorBody != (Object)null)
{
val = ((Component)local.AnimatorBody).gameObject;
}
else if ((Object)(object)local.PlayerSyncModel != (Object)null)
{
val = ((Component)local.PlayerSyncModel).gameObject;
}
if ((Object)(object)val == (Object)null)
{
return false;
}
_localTPoseDummy = Object.Instantiate<GameObject>(val, LockedPosition, LockedRotation);
_localTPoseDummy.transform.SetParent((Transform)null);
_localTPoseDummy.transform.position = LockedPosition;
_localTPoseDummy.transform.rotation = LockedRotation;
_localTPoseDummy.transform.localScale = Vector3.one;
Animator component = _localTPoseDummy.GetComponent<Animator>();
if ((Object)(object)component != (Object)null)
{
component.Rebind();
component.Update(0f);
((Behaviour)component).enabled = false;
}
foreach (Transform componentsInChild in _localTPoseDummy.GetComponentsInChildren<Transform>(true))
{
if ((Object)(object)componentsInChild != (Object)null)
{
Vector3 localScale = componentsInChild.localScale;
if (((Vector3)(ref localScale)).sqrMagnitude < 0.01f)
{
componentsInChild.localScale = Vector3.one;
}
}
}
PoseHelper.ApplyConfiguredPose(_localTPoseDummy, component);
foreach (ParticleSystem componentsInChild2 in _localTPoseDummy.GetComponentsInChildren<ParticleSystem>(true))
{
if ((Object)(object)componentsInChild2 != (Object)null)
{
componentsInChild2.Stop(true, (ParticleSystemStopBehavior)0);
}
}
foreach (Renderer componentsInChild3 in _localTPoseDummy.GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild3 == (Object)null)
{
continue;
}
string name = ((MemberInfo)((Object)componentsInChild3).GetIl2CppType()).Name;
if (name.Contains("Particle") || name.Contains("Trail") || name.Contains("Line") || name.Contains("VFX"))
{
componentsInChild3.enabled = false;
continue;
}
SkinnedMeshRenderer val2 = ((Il2CppObjectBase)componentsInChild3).TryCast<SkinnedMeshRenderer>();
if ((Object)(object)val2 != (Object)null)
{
((Component)val2).gameObject.SetActive(true);
((Renderer)val2).enabled = true;
((Renderer)val2).forceRenderingOff = false;
((Renderer)val2).shadowCastingMode = (ShadowCastingMode)1;
val2.updateWhenOffscreen = true;
((Component)val2).gameObject.layer = 0;
}
else
{
componentsInChild3.enabled = false;
}
}
return true;
}
private static void HideAllLocalPlayerModels(PlayerAgent local, bool hasDummy)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
List<Transform> list = new List<Transform>();
if ((Object)(object)local.AnimatorArms != (Object)null)
{
list.Add(((Component)local.AnimatorArms).transform);
}
if ((Object)(object)local.FPItemHolder != (Object)null)
{
list.Add(((Component)local.FPItemHolder).transform);
}
if (hasDummy && (Object)(object)local.AnimatorBody != (Object)null)
{
list.Add(((Component)local.AnimatorBody).transform);
}
foreach (Transform item in list)
{
if (!((Object)(object)item == (Object)null))
{
if (!_savedFpScales.ContainsKey(item))
{
_savedFpScales[item] = item.localScale;
}
item.localScale = Vector3.zero;
}
}
List<GameObject> list2 = new List<GameObject>();
list2.Add(((Component)local).gameObject);
if ((Object)(object)local.FPSCamera != (Object)null)
{
list2.Add(((Component)local.FPSCamera).gameObject);
}
if ((Object)(object)local.PlayerSyncModel != (Object)null)
{
list2.Add(((Component)local.PlayerSyncModel).gameObject);
}
foreach (GameObject item2 in list2)
{
if ((Object)(object)item2 == (Object)null)
{
continue;
}
Il2CppArrayBase<Renderer> componentsInChildren = item2.GetComponentsInChildren<Renderer>(true);
if (componentsInChildren == null)
{
continue;
}
foreach (Renderer item3 in componentsInChildren)
{
if ((Object)(object)item3 == (Object)null)
{
continue;
}
string name = ((MemberInfo)((Object)item3).GetIl2CppType()).Name;
if (name.Contains("Particle") || name.Contains("Trail") || name.Contains("Line"))
{
continue;
}
if (hasDummy)
{
if (!_savedAllLocalRenderers.ContainsKey(item3))
{
_savedAllLocalRenderers[item3] = item3.enabled;
}
item3.enabled = false;
}
else if (((Object)(object)local.AnimatorArms != (Object)null && ((Component)item3).transform.IsChildOf(((Component)local.AnimatorArms).transform)) || ((Object)(object)local.FPItemHolder != (Object)null && ((Component)item3).transform.IsChildOf(((Component)local.FPItemHolder).transform)))
{
if (!_savedAllLocalRenderers.ContainsKey(item3))
{
_savedAllLocalRenderers[item3] = item3.enabled;
}
item3.enabled = false;
}
}
}
}
private static void EnforceDisarmAndFreeze(PlayerAgent local)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (LockedPosition != Vector3.zero)
{
((Component)local).transform.position = LockedPosition;
}
foreach (KeyValuePair<Transform, Vector3> savedFpScale in _savedFpScales)
{
if ((Object)(object)savedFpScale.Key != (Object)null)
{
savedFpScale.Key.localScale = Vector3.zero;
}
}
foreach (KeyValuePair<Renderer, bool> savedAllLocalRenderer in _savedAllLocalRenderers)
{
if ((Object)(object)savedAllLocalRenderer.Key != (Object)null && savedAllLocalRenderer.Key.enabled)
{
savedAllLocalRenderer.Key.enabled = false;
}
}
}
private static void RestoreFirstPersonAndControl()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
RestoreNetworkPoseToVanillaClients(localPlayerAgent);
IsInThirdPerson = false;
LockedPosition = Vector3.zero;
Camera.onPreCull -= CameraCallback.op_Implicit((Action<Camera>)ApplyThirdPersonCameraOffset);
foreach (KeyValuePair<Transform, Vector3> savedFpScale in _savedFpScales)
{
if ((Object)(object)savedFpScale.Key != (Object)null)
{
savedFpScale.Key.localScale = savedFpScale.Value;
}
}
_savedFpScales.Clear();
foreach (KeyValuePair<Renderer, bool> savedAllLocalRenderer in _savedAllLocalRenderers)
{
if ((Object)(object)savedAllLocalRenderer.Key != (Object)null)
{
savedAllLocalRenderer.Key.enabled = savedAllLocalRenderer.Value;
}
}
_savedAllLocalRenderers.Clear();
if ((Object)(object)_localTPoseDummy != (Object)null)
{
Object.Destroy((Object)(object)_localTPoseDummy);
_localTPoseDummy = null;
}
}
}
[HarmonyPatch(typeof(PlayerSync))]
public class VanillaClientSyncPatch
{
[HarmonyPatch("SendLocomotion")]
[HarmonyPrefix]
public static void Prefix_SendLocomotion(PlayerSync __instance, ref PLOC_State state, ref Vector3 pos, ref Vector3 lookDir, ref float velFwd, ref float velRight)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
if (!ThirdPersonFreezeController.IsSendingRestoredPacket && (Plugin.ConfigSyncStandToVanillaClients == null || Plugin.ConfigSyncStandToVanillaClients.Value) && !(ThirdPersonFreezeController.LocalDisarmTimer <= 0f) && ThirdPersonFreezeController.IsInThirdPerson && !((Object)(object)__instance.m_agent == (Object)null) && ((Agent)__instance.m_agent).IsLocallyOwned)
{
state = (PLOC_State)9;
if (ThirdPersonFreezeController.LockedPosition != Vector3.zero)
{
pos = ThirdPersonFreezeController.LockedPosition;
}
velFwd = 0f;
velRight = 0f;
lookDir = ThirdPersonFreezeController.LockedRotation * Vector3.forward;
}
}
}
[HarmonyPatch(typeof(InputMapper))]
public class DisarmAndFreezeInputPatch
{
private static bool ShouldBlockAction(InputAction action)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected I4, but got Unknown
if (ThirdPersonFreezeController.LocalDisarmTimer <= 0f)
{
return false;
}
switch (action - 1)
{
case 0:
case 1:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 22:
case 23:
case 24:
case 25:
case 27:
case 28:
return true;
default:
return false;
}
}
[HarmonyPatch("GetButtonKeyMouseGamepad", new Type[]
{
typeof(InputAction),
typeof(eFocusState)
})]
[HarmonyPrefix]
public static bool Prefix_GetButtonGamepad(InputAction action, ref bool __result)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (ShouldBlockAction(action))
{
__result = false;
return false;
}
return true;
}
[HarmonyPatch("GetButtonDownKeyMouseGamepad", new Type[]
{
typeof(InputAction),
typeof(eFocusState)
})]
[HarmonyPrefix]
public static bool Prefix_GetButtonDownGamepad(InputAction action, ref bool __result)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (ShouldBlockAction(action))
{
__result = false;
return false;
}
return true;
}
[HarmonyPatch("GetButtonKeyMouse", new Type[]
{
typeof(InputAction),
typeof(eFocusState)
})]
[HarmonyPrefix]
public static bool Prefix_GetButtonKeyMouse(InputAction action, ref bool __result)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (ShouldBlockAction(action))
{
__result = false;
return false;
}
return true;
}
[HarmonyPatch("GetButtonDownKeyMouse", new Type[]
{
typeof(InputAction),
typeof(eFocusState)
})]
[HarmonyPrefix]
public static bool Prefix_GetButtonDownKeyMouse(InputAction action, ref bool __result)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (ShouldBlockAction(action))
{
__result = false;
return false;
}
return true;
}
[HarmonyPatch("GetAxisKeyMouseGamepad", new Type[]
{
typeof(InputAction),
typeof(eFocusState)
})]
[HarmonyPrefix]
public static bool Prefix_GetAxisGamepad(InputAction action, ref float __result)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
if (ThirdPersonFreezeController.LocalDisarmTimer > 0f && ((int)action == 1 || (int)action == 2))
{
__result = 0f;
return false;
}
return true;
}
[HarmonyPatch("GetAxisKeyMouse", new Type[]
{
typeof(InputAction),
typeof(eFocusState)
})]
[HarmonyPrefix]
public static bool Prefix_GetAxisKeyMouse(InputAction action, ref float __result)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
if (ThirdPersonFreezeController.LocalDisarmTimer > 0f && ((int)action == 1 || (int)action == 2))
{
__result = 0f;
return false;
}
return true;
}
}
[HarmonyPatch]
public class PlayerDamageTPosePatch
{
private static Dictionary<int, Coroutine> _activeCoroutines = new Dictionary<int, Coroutine>();
private static Dictionary<int, float> _nextAllowedTriggerTime = new Dictionary<int, float>();
private static float GetConfiguredDuration()
{
return (Plugin.ConfigFreezeDuration != null) ? Mathf.Max(0.1f, Plugin.ConfigFreezeDuration.Value) : 1f;
}
private static float GetConfiguredCooldown()
{
return (Plugin.ConfigCooldownDuration != null) ? Mathf.Max(0f, Plugin.ConfigCooldownDuration.Value) : 3f;
}
private static bool IsAllDamageEnabled()
{
return Plugin.ConfigTriggerAllDamage != null && Plugin.ConfigTriggerAllDamage.Value;
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveTentacleAttackDamage")]
[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveTentacleAttackDamage")]
[HarmonyPostfix]
public static void OnTentacleHit(Dam_PlayerDamageBase __instance)
{
if (IsAllDamageEnabled() || (Plugin.ConfigTriggerTentacle != null && Plugin.ConfigTriggerTentacle.Value))
{
TriggerTPose(__instance.Owner, GetConfiguredDuration());
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveShooterProjectileDamage")]
[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveShooterProjectileDamage")]
[HarmonyPostfix]
public static void OnShooterHit(Dam_PlayerDamageBase __instance)
{
if (IsAllDamageEnabled() || (Plugin.ConfigTriggerShooter != null && Plugin.ConfigTriggerShooter.Value))
{
TriggerTPose(__instance.Owner, GetConfiguredDuration());
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveMeleeDamage")]
[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveMeleeDamage")]
[HarmonyPostfix]
public static void OnEnemyMeleeHit(Dam_PlayerDamageBase __instance)
{
if (IsAllDamageEnabled() || (Plugin.ConfigTriggerEnemyMelee != null && Plugin.ConfigTriggerEnemyMelee.Value))
{
TriggerTPose(__instance.Owner, GetConfiguredDuration());
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveBulletDamage")]
[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveBulletDamage")]
[HarmonyPostfix]
public static void OnFriendlyFireBulletHit(Dam_PlayerDamageBase __instance)
{
if (IsAllDamageEnabled() || (Plugin.ConfigTriggerFriendlyFire != null && Plugin.ConfigTriggerFriendlyFire.Value))
{
TriggerTPose(__instance.Owner, GetConfiguredDuration());
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "OnIncomingDamage")]
[HarmonyPostfix]
public static void OnAnyIncomingDamage(Dam_PlayerDamageBase __instance)
{
if (IsAllDamageEnabled())
{
TriggerTPose(__instance.Owner, GetConfiguredDuration());
}
}
public static void TriggerTPose(PlayerAgent player, float duration)
{
if ((Object)(object)player == (Object)null || !((Agent)player).Alive)
{
return;
}
int instanceID = ((Object)player).GetInstanceID();
float time = Time.time;
float configuredCooldown = GetConfiguredCooldown();
if (_nextAllowedTriggerTime.TryGetValue(instanceID, out var value) && time < value && value - time <= duration + configuredCooldown + 1f)
{
return;
}
_nextAllowedTriggerTime[instanceID] = time + duration + Mathf.Max(0.1f, configuredCooldown);
if (((Agent)player).IsLocallyOwned)
{
ThirdPersonFreezeController.LocalDisarmTimer = duration;
ThirdPersonFreezeController.StartThirdPersonAndLock(player);
}
List<Animator> list = new List<Animator>();
Il2CppArrayBase<Animator> componentsInChildren = ((Component)player).GetComponentsInChildren<Animator>(true);
if (componentsInChildren != null)
{
list.AddRange((IEnumerable<Animator>)componentsInChildren);
}
if ((Object)(object)player.PlayerSyncModel != (Object)null)
{
Il2CppArrayBase<Animator> componentsInChildren2 = ((Component)player.PlayerSyncModel).GetComponentsInChildren<Animator>(true);
if (componentsInChildren2 != null)
{
foreach (Animator item in componentsInChildren2)
{
if (!list.Contains(item))
{
list.Add(item);
}
}
}
}
if ((Object)(object)player.AnimatorBody != (Object)null && !list.Contains(player.AnimatorBody))
{
list.Add(player.AnimatorBody);
}
foreach (Animator item2 in list)
{
if (!((Object)(object)item2 == (Object)null) && (!((Agent)player).IsLocallyOwned || !((Object)(object)player.AnimatorArms != (Object)null) || !((Object)(object)item2 == (Object)(object)player.AnimatorArms)))
{
int instanceID2 = ((Object)item2).GetInstanceID();
if (_activeCoroutines.TryGetValue(instanceID2, out var value2) && value2 != null)
{
((MonoBehaviour)player).StopCoroutine(value2);
}
Coroutine value3 = ((MonoBehaviour)player).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(TPoseRoutine(item2, instanceID2, duration)));
_activeCoroutines[instanceID2] = value3;
}
}
}
private static IEnumerator TPoseRoutine(Animator anim, int id, float duration)
{
if ((Object)(object)anim != (Object)null)
{
anim.Rebind();
anim.Update(0f);
((Behaviour)anim).enabled = false;
PoseHelper.ApplyConfiguredPose(((Component)anim).gameObject, anim);
}
yield return (object)new WaitForSeconds(duration);
if ((Object)(object)anim != (Object)null)
{
((Behaviour)anim).enabled = true;
}
_activeCoroutines.Remove(id);
}
}
}