Decompiled source of UltraFeedbacker v1.0.1

doomahreal.ultrakill.ultrafeedbacker/UltraFeedbacker.dll

Decompiled 2 months ago
using System;
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 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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("UltraFeedbacker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UltraFeedbacker")]
[assembly: AssemblyTitle("UltraFeedbacker")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UltraFeedbacker
{
	[BepInPlugin("doomahreal.ultrakill.ultrafeedbacker", "UltraFeedbacker", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Debug.Log((object)"UltraFeedbacker is loaded!");
			_harmony = new Harmony("doomahreal.ultrakill.ultrafeedbacker");
			_harmony.PatchAll();
		}
	}
	[HarmonyPatch(typeof(ProjectileParryZone))]
	[HarmonyPatch("OnTriggerEnter")]
	public class ProjectileParryZone_OnTriggerEnter_Patch
	{
		private static void Postfix(Collider other, ProjectileParryZone __instance)
		{
			List<GameObject> list = (List<GameObject>)typeof(ProjectileParryZone).GetField("projs", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
			list.Add(((Component)other).gameObject);
			EnemyIdentifier component = ((Component)other).gameObject.GetComponent<EnemyIdentifier>();
			if ((Object)(object)component != (Object)null)
			{
				AddProjectileToChildrenRecursively(((Component)component).transform);
			}
			else
			{
				MeshRenderer component2 = ((Component)other).GetComponent<MeshRenderer>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)((Component)other).gameObject.GetComponent<Projectile>() == (Object)null)
				{
					((Component)other).gameObject.AddComponent<Projectile>();
				}
			}
			MeshRenderer component3 = ((Component)other).GetComponent<MeshRenderer>();
			if ((Object)(object)component3 != (Object)null && (Object)(object)((Renderer)component3).sharedMaterial == (Object)(object)__instance.origMat)
			{
				((Renderer)component3).material = __instance.newMat;
			}
		}

		private static void AddProjectileToChildrenRecursively(Transform parent)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				((Component)val).gameObject.AddComponent<Projectile>();
				AddProjectileToChildrenRecursively(val);
			}
		}
	}
	[HarmonyPatch(typeof(ProjectileParryZone))]
	[HarmonyPatch("OnTriggerExit")]
	public class ProjectileParryZone_OnTriggerExit_Patch
	{
		private static void Postfix(Collider other, ProjectileParryZone __instance)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			List<GameObject> list = (List<GameObject>)typeof(ProjectileParryZone).GetField("projs", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
			if (list.Contains(((Component)other).gameObject))
			{
				list.Remove(((Component)other).gameObject);
				MeshRenderer component = ((Component)other).GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).sharedMaterial == (Object)(object)__instance.origMat)
				{
					((Renderer)component).material = __instance.origMat;
				}
			}
			if ((Object)(object)((Component)other).gameObject.GetComponent<EnemyIdentifier>() == (Object)null)
			{
				Projectile component2 = ((Component)other).gameObject.GetComponent<Projectile>();
				if ((Object)(object)component2 != (Object)null)
				{
					Object.Destroy((Object)(object)component2);
				}
			}
			if (!((Object)(object)((Component)other).gameObject.GetComponent<EnemyIdentifier>() != (Object)null))
			{
				return;
			}
			foreach (Transform item in ((Component)other).transform)
			{
				Transform val = item;
				Projectile component3 = ((Component)val).gameObject.GetComponent<Projectile>();
				if ((Object)(object)component3 != (Object)null)
				{
					Object.Destroy((Object)(object)component3);
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "UltraFeedbacker";

		public const string PLUGIN_NAME = "UltraFeedbacker";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}