Decompiled source of Extreme ragdoll v1.0.0

plugins/Extreme Ragdoll.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using SideLoader;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Conjuration Extended")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Conjuration Extended")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ff65a53d-0b52-41b0-8c46-6a77becc659c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Extreme_Ragdoll;

public static class ConfigElements
{
	public static ConfigEntry<float> ragdollScale;

	public static void Init(ConfigFile config)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		ragdollScale = config.Bind<float>("Ragdoll", "Multiplier", 1f, new ConfigDescription("How much stronger than vanilla will the ragdoll be. A value below 6 is recommended. (Vanilla = 1)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), new object[0]));
	}
}
[BepInPlugin("johbenji.extremeragdoll", "Extreme Ragdoll", "1.0.0")]
public class ExtremeRagdollPlugin : BaseUnityPlugin
{
	public const string GUID = "johbenji.extremeragdoll";

	public const string NAME = "Extreme Ragdoll";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	internal void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		((BaseUnityPlugin)this).Logger.Log((LogLevel)8, (object)"Loading config");
		ConfigElements.Init(((BaseUnityPlugin)this).Config);
		new Harmony("johbenji.extremeragdoll").PatchAll();
		SL.OnPacksLoaded += SL_OnPacksLoaded;
	}

	public void SL_OnPacksLoaded()
	{
	}
}
[HarmonyPatch(typeof(Character), "OnReceiveHit")]
public class OnReceiveHitModifier
{
	[HarmonyPrefix]
	public static bool Prefix(Weapon _weapon, float _damage, DamageList _damageList, Vector3 _hitDir, Vector3 _hitPoint, float _angle, float _angleDir, Character _dealerChar, float _knockBack, Character __instance, CharacterSoundManager ___m_characterSoundManager, OnHitEvent ___m_onHitPosResistance, StatusEffectManager ___m_statusEffectManager, ParticleSystem ___m_hurtFX, ParticleSystem[] ___m_elementalFX, HurtType ___m_hurtType)
	{
		//IL_007d: 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_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Invalid comparison between Unknown and I4
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Expected I4, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		__instance.m_lastHurtTime = Time.time;
		float num = (Object.op_Implicit((Object)(object)__instance.Stats) ? __instance.Stats.GetMitigatedImpact((Tag[])null, _knockBack, false) : _knockBack);
		if (_knockBack > 0f && num == 0f)
		{
			num = 0.001f;
		}
		if ((Object)(object)___m_characterSoundManager != (Object)null && ((Object)(object)_weapon != (Object)null || _damage > 9f))
		{
			Global.AudioManager.PlaySoundAtPosition(___m_characterSoundManager.GetHurtSound(), ((Component)__instance).transform, 0f, 1f, 1f, 1f, 1f);
		}
		((UnityEvent<Weapon, float>)(object)___m_onHitPosResistance)?.Invoke(_weapon, _damage);
		if (Object.op_Implicit((Object)(object)___m_statusEffectManager) && _knockBack >= 10f)
		{
			___m_statusEffectManager.OnReceivedHit();
		}
		if (Object.op_Implicit((Object)(object)_dealerChar))
		{
			__instance.AddLastDealer(_dealerChar.UID);
			((Component)__instance).SendMessage("CharHurt", (object)_dealerChar, (SendMessageOptions)1);
			__instance.OnReceiveHitCombatEngaged(_dealerChar);
		}
		if ((Object)(object)_weapon != (Object)null)
		{
			float num2 = Mathf.Lerp(0.7f, 1f, UnityEngineExtensions.GetLerpValue(Mathf.Clamp(_damage, 10f, 40f), 10f, 40f));
			float num3 = Mathf.Lerp(0f, 0.3f, UnityEngineExtensions.GetLerpValue(Mathf.Clamp(__instance.CharacterController.radius, 0.4f, 0.8f), 0.4f, 0.8f));
			Vector3 position = _hitPoint + (_weapon.WeaponCenter - _hitPoint) * 0.1f;
			Vector3 localScale = Vector3.one * (num2 + num3);
			((Component)___m_hurtFX).transform.position = position;
			((Component)___m_hurtFX).transform.forward = _hitDir;
			((Component)___m_hurtFX).transform.localScale = localScale;
			___m_hurtFX.Play();
			if (_damageList != null)
			{
				for (int i = 0; i < _damageList.Count; i++)
				{
					if (_damageList[i].Damage > 0f)
					{
						int num4 = _damageList[i].Type - 1;
						if (num4 >= 0 && num4 < ___m_elementalFX.Length && (Object)(object)___m_elementalFX[num4] != (Object)null)
						{
							((Component)___m_elementalFX[num4]).transform.position = position;
							((Component)___m_elementalFX[num4]).transform.forward = _hitDir;
							((Component)___m_elementalFX[num4]).transform.localScale = localScale;
							___m_elementalFX[num4].Play();
						}
					}
				}
			}
			if (!(_weapon is ProjectileWeapon))
			{
				if (!Object.op_Implicit((Object)(object)_weapon.ImpactSoundOverride))
				{
					if ((Object)(object)_weapon.ImpactSoundPlayer == (Object)null)
					{
						Debug.LogError((object)$"Null ImpactSoundPlayer! {_weapon}");
					}
					else
					{
						_weapon.ImpactSoundPlayer.Play(__instance.HitSoundMaterial, false);
					}
				}
				else
				{
					_weapon.ImpactSoundOverride.Play(false);
				}
			}
		}
		Vector3 val = _hitDir * ConfigElements.ragdollScale.Value * Mathf.Clamp(CharacterManager.Instance.DeathImpulseCurve.Evaluate(Mathf.Clamp(_damage, 0f, 60f)) + CharacterManager.Instance.DeathImpulseCurve.Evaluate(Mathf.Clamp(num, 0f, 60f)), 0f, 60f);
		__instance.VitalityHit(_dealerChar, _damage, val);
		if ((int)___m_hurtType != 2)
		{
			__instance.StabilityHit(num, Vector3.Angle(((Component)__instance).transform.forward, -_hitDir) * _angleDir, false, _dealerChar);
		}
		return false;
	}
}