Decompiled source of LITERAL HELL v1.0.0

HELL.dll

Decompiled 14 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("RadiantBossesForAll")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RadiantBossesForAll")]
[assembly: AssemblyTitle("RadiantBossesForAll")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 RadiantBossesForAll
{
	[BepInPlugin("user.radiantbossesforall", "Radiant Bosses For All", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGuid = "user.radiantbossesforall";

		public const string ModName = "Radiant Bosses For All";

		public const string ModVersion = "1.0.0";

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_harmony = new Harmony("user.radiantbossesforall");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Radiant Bosses For All loaded.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier), "Start")]
	public static class EnemyIdentifierStartPatch
	{
		private const float HealthMultiplier = 6f;

		private static void Postfix(EnemyIdentifier __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				__instance.DamageBuff();
				__instance.HealthBuff(6f);
				__instance.BossBar(true);
				EnemyPhaseTwoPatch.RegisterEnemy(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier), "Update")]
	public static class EnemyPhaseTwoPatch
	{
		private const float PhaseTwoSpeedMultiplier = 2f;

		private static readonly Dictionary<int, float> MaxHealthById = new Dictionary<int, float>();

		private static readonly HashSet<int> TriggeredById = new HashSet<int>();

		public static void RegisterEnemy(EnemyIdentifier enemy)
		{
			int instanceID = ((Object)enemy).GetInstanceID();
			MaxHealthById[instanceID] = enemy.health;
			TriggeredById.Remove(instanceID);
		}

		private static void Postfix(EnemyIdentifier __instance)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			BossHealthBar component = ((Component)__instance).GetComponent<BossHealthBar>();
			if ((Object)(object)component == (Object)null)
			{
				__instance.BossBar(true);
				component = ((Component)__instance).GetComponent<BossHealthBar>();
			}
			if ((Object)(object)component != (Object)null)
			{
				component.secondaryBar = true;
				component.SetSecondaryBarColor(new Color(1f, 64f / 85f, 0f));
			}
			if (__instance.dead)
			{
				MaxHealthById.Remove(instanceID);
				TriggeredById.Remove(instanceID);
				return;
			}
			if (!MaxHealthById.TryGetValue(instanceID, out var value) || value <= 0f)
			{
				value = __instance.health;
				MaxHealthById[instanceID] = value;
			}
			float num = value * 0.5f;
			if (!TriggeredById.Contains(instanceID))
			{
				float num2 = Mathf.Clamp01((__instance.health - num) / Mathf.Max(num, 0.001f));
				if ((Object)(object)component != (Object)null)
				{
					component.UpdateSecondaryBar(num2);
				}
				if (__instance.health > num)
				{
					return;
				}
				TriggeredById.Add(instanceID);
				__instance.health += num;
				__instance.ForceGetHealth();
				__instance.SpeedBuff(2f);
				__instance.DamageBuff();
				IEnrage[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<IEnrage>(true);
				foreach (IEnrage val in componentsInChildren)
				{
					if (!val.isEnraged)
					{
						val.Enrage();
					}
				}
			}
			if ((Object)(object)component != (Object)null)
			{
				float num3 = Mathf.Clamp01(__instance.health / Mathf.Max(value, 0.001f));
				component.UpdateSecondaryBar(num3);
			}
		}
	}
	[HarmonyPatch(typeof(StyleHUD), "AddPoints")]
	public static class StylePointsPatch
	{
		private const int PointsMultiplier = 5;

		private static void Prefix(ref int points)
		{
			if (points > 0)
			{
				points *= 5;
			}
		}
	}
	[HarmonyPatch(typeof(FinalRank), "AddPoints")]
	public static class FinalRankPointsPatch
	{
		private const int PointsMultiplier = 5;

		private static void Prefix(ref int points)
		{
			if (points > 0)
			{
				points *= 5;
			}
		}
	}
	[HarmonyPatch(typeof(FinalRank), "SetInfo")]
	public static class FinalRankTextPatch
	{
		private const string HellUsedText = "- HELL USED";

		private static void Postfix(FinalRank __instance)
		{
			object value = Traverse.Create((object)__instance).Field("extraInfo").GetValue();
			if (value != null)
			{
				string text = Traverse.Create(value).Property("text", (object[])null).GetValue<string>() ?? string.Empty;
				if (!text.Contains("- HELL USED"))
				{
					string value2 = (string.IsNullOrWhiteSpace(text) ? "- HELL USED" : (text + "\n- HELL USED"));
					Traverse.Create(value).Property("text", (object[])null).SetValue((object)value2);
				}
			}
		}
	}
}