Decompiled source of Enemy Dismemberment v1.0.0

EmpressBodyParts.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c574138cfea486cfa7104eae1a6f135c166daf8b")]
[assembly: AssemblyProduct("EmpressBodyParts")]
[assembly: AssemblyTitle("EmpressBodyParts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 EnemyDismemberment
{
	[BepInPlugin("com.Empress.EnemyDismemberment", "Enemy Dismemberment", "6.6.9")]
	public class EnemyDismembermentPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.Empress.EnemyDismemberment").PatchAll();
		}
	}
	[HarmonyPatch(typeof(EnemyHealth))]
	public static class EnemyHealthPatch
	{
		[HarmonyPatch("DeathImpulseRPC")]
		[HarmonyPostfix]
		public static void Postfix(EnemyHealth __instance)
		{
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || __instance.renderers == null || __instance.renderers.Count == 0)
			{
				return;
			}
			Vector3 position = ((Component)__instance).transform.position;
			if ((Object)(object)((Component)__instance).GetComponent<Enemy>()?.CenterTransform != (Object)null)
			{
				position = ((Component)__instance).GetComponent<Enemy>().CenterTransform.position;
			}
			List<Renderer> list = new List<Renderer>((IEnumerable<Renderer>)__instance.renderers);
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "empress");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Material val2 = val.LoadAsset<Material>("EmpressBlood");
			val.Unload(false);
			foreach (Renderer item in list)
			{
				if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).gameObject == (Object)null)
				{
					continue;
				}
				GameObject gameObject = ((Component)item).gameObject;
				gameObject.transform.SetParent((Transform)null);
				Rigidbody val3 = gameObject.GetComponent<Rigidbody>();
				if ((Object)(object)val3 == (Object)null)
				{
					val3 = gameObject.AddComponent<Rigidbody>();
					val3.mass = 2f;
					val3.collisionDetectionMode = (CollisionDetectionMode)1;
				}
				Collider component = gameObject.GetComponent<Collider>();
				if ((Object)(object)component == (Object)null)
				{
					BoxCollider val4 = gameObject.AddComponent<BoxCollider>();
					try
					{
						Quaternion rotation = gameObject.transform.rotation;
						gameObject.transform.rotation = Quaternion.identity;
						val4.center = Vector3.zero;
						Bounds bounds = item.bounds;
						val4.size = ((Bounds)(ref bounds)).size;
						gameObject.transform.rotation = rotation;
					}
					catch
					{
						val4.size = Vector3.one * 0.5f;
					}
				}
				Material[] array = (Material[])(object)new Material[item.materials.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = val2;
				}
				item.materials = array;
				float num = 800f;
				float num2 = 4f;
				val3.AddExplosionForce(num, position, num2, 1f, (ForceMode)1);
				val3.AddTorque(Random.insideUnitSphere * 500f);
			}
		}
	}
}