Decompiled source of ItWasYourFault v1.0.1

BepInEx/plugin/RagdollFix.dll

Decompiled 11 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Template description")]
[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 RagdollFix
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "RagdollFix";

		public const string PLUGIN_NAME = "Template description";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ModNamespace
{
	internal class Patches
	{
		[HarmonyPatch(typeof(JumpPadScript), "OnCollisionEnter2D")]
		[HarmonyPrefix]
		private static bool JumpPadCollide(JumpPadScript __instance, Collision2D collision)
		{
			//IL_0045: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.disabled || !(__instance.cooldown <= 0f) || !Object.op_Implicit((Object)(object)collision.rigidbody) || collision.rigidbody.isKinematic)
			{
				return false;
			}
			GameObject gameObject = collision.gameObject;
			ContactPoint2D contact = collision.GetContact(0);
			Limb val = Body.LimbFromObject(gameObject, ((ContactPoint2D)(ref contact)).point);
			if (Object.op_Implicit((Object)(object)val) && __instance.cooldown <= 0f)
			{
				val.body.Ragdoll();
				__instance.light.intensity = 1f;
				Limb[] limbs = val.body.limbs;
				Limb[] array = limbs;
				foreach (Limb val2 in array)
				{
					val2.rb.velocity = new Vector2(val2.rb.velocity.x, 65f);
				}
				val.body.Scream();
				Sound.Play("jumppad", Vector2.op_Implicit(((Component)__instance).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
				__instance.cooldown = 15f;
				PlayerCamera.main.shaker.Shake(70f);
			}
			else
			{
				__instance.light.intensity = 1f;
				collision.rigidbody.AddForce(Vector2.up * 350f, (ForceMode2D)1);
				Sound.Play("jumppad", Vector2.op_Implicit(((Component)__instance).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
				__instance.cooldown = 15f;
			}
			return false;
		}

		[HarmonyPatch(typeof(BarbedFence), "OnTriggerEnter2D")]
		[HarmonyPrefix]
		private static bool BarbedFenceCollide(BarbedFence __instance, Collider2D collision)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Body val = default(Body);
			if (((Component)collision).TryGetComponent<Body>(ref val) && __instance.soundPlayCooldown <= 0f)
			{
				val.Ragdoll();
				BarbedFenceCut(__instance, Body.LimbFromObject(((Component)val).gameObject, Vector2.op_Implicit(((Component)__instance).transform.position)));
			}
			Limb limb = default(Limb);
			if (((Component)collision).TryGetComponent<Limb>(ref limb))
			{
				BarbedFenceCut(__instance, limb);
			}
			return false;
		}

		private static void BarbedFenceCut(BarbedFence __instance, Limb limb)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.soundPlayCooldown <= 0f)
			{
				__instance.soundPlayCooldown = 10f;
				Sound.Play("fence", Vector2.op_Implicit(((Component)__instance).transform.position), false, true, (Transform)null, 1f, 1f, false, false);
			}
			limb.skinHealth -= Random.Range(10f, 25f) / limb.GetArmorReduction();
			limb.bleedAmount += Random.Range(1f, 3f) / limb.GetArmorReduction();
			limb.pain += Random.Range(20f, 60f) / limb.GetArmorReduction();
			limb.DamageWearables(0.2f);
			limb.body.Scream();
			((Component)__instance).GetComponent<SpriteRenderer>().sprite = __instance.hitSprite;
		}

		[HarmonyPatch(typeof(CoilScript), "OnCollisionEnter2D")]
		[HarmonyPrefix]
		private static bool CoilScriptCollide(CoilScript __instance, Collision2D collision)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.cooldown <= 0f)
			{
				GameObject gameObject = collision.gameObject;
				ContactPoint2D contact = collision.GetContact(0);
				Limb val = Body.LimbFromObject(gameObject, ((ContactPoint2D)(ref contact)).point);
				if (Object.op_Implicit((Object)(object)val))
				{
					__instance.Shock(val);
				}
			}
			return false;
		}
	}
	[BepInPlugin("com.mayzmae.ragdollfix", "Ragdoll Fix", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.mayzmae.ragdollfix";

		public const string ModName = "Ragdoll Fix";

		public const string ModVersion = "1.0.0";

		internal static ManualLogSource Logger;

		private readonly Harmony _harmony = new Harmony("com.mayzmae.ragdollfix");

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			_harmony.PatchAll(typeof(Patches));
			Logger.LogInfo((object)"Plugin Ragdoll Fix is loaded!");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Instance = null;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}