Decompiled source of EclipseRevamped v1.0.1

EclipseRevamped.dll

Decompiled a day ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HG.Reflection;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("EclipseRevamped")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EclipseRevamped")]
[assembly: AssemblyTitle("EclipseRevamped")]
[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;
		}
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class IsExternalInit
	{
	}
}
namespace EclipseRevamped
{
	[BepInPlugin("com.Nuxlar.EclipseRevamped", "EclipseRevamped", "1.0.1")]
	public class EclipseRevamped : BaseUnityPlugin
	{
		private GameObject vagrantMaster = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Vagrant/VagrantMaster.prefab").WaitForCompletion();

		private GameObject awuMaster = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/RoboBallBoss/SuperRoboBallBossMaster.prefab").WaitForCompletion();

		private GameObject grandparentMaster = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Grandparent/GrandparentMaster.prefab").WaitForCompletion();

		private static ConfigEntry<bool> enableE1Changes;

		private static ConfigEntry<bool> enableE2Changes;

		private static ConfigEntry<bool> enableE3Changes;

		private static ConfigEntry<bool> enableE5Changes;

		private static ConfigEntry<bool> enableE6Changes;

		private static ConfigFile ERConfig { get; set; }

		public void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			ERConfig = new ConfigFile(Paths.ConfigPath + "\\com.Nuxlar.EclipseRevamped.cfg", true);
			enableE1Changes = ERConfig.Bind<bool>("General", "Enable E1 Changes", true, "Replaces E1 with a new modifier.");
			enableE2Changes = ERConfig.Bind<bool>("General", "Enable E2 Changes", true, "Replaces E2 with a new modifier.");
			enableE3Changes = ERConfig.Bind<bool>("General", "Enable E3 Changes", true, "Replaces E3 with a new modifier.");
			enableE5Changes = ERConfig.Bind<bool>("General", "Enable E5 Tweak", true, "Reduces healing reduction to 25% instead of 50%.");
			enableE6Changes = ERConfig.Bind<bool>("General", "Enable E6 Changes", true, "Replaces E6 with a new modifier.");
			(from x in vagrantMaster.GetComponents<AISkillDriver>()
				where x.customName == "FireNova"
				select x).First().noRepeat = true;
			(from x in awuMaster.GetComponents<AISkillDriver>()
				where x.customName == "EnableEyebeam"
				select x).First().noRepeat = true;
			(from x in grandparentMaster.GetComponents<AISkillDriver>()
				where x.customName == "ChannelSun"
				select x).First().noRepeat = true;
			ChangeDescriptions();
			if (enableE1Changes.Value)
			{
				CharacterMaster.OnBodyStart += new Manipulator(RemoveVanillaE1);
				Run.RecalculateDifficultyCoefficentInternal += new hook_RecalculateDifficultyCoefficentInternal(AddNewE1);
			}
			if (enableE2Changes.Value)
			{
				HoldoutZoneController.FixedUpdate += new Manipulator(RemoveVanillaE2);
			}
			CombatDirector.Awake += new hook_Awake(AddNewE2E6);
			if (enableE3Changes.Value)
			{
				GlobalEventManager.OnCharacterHitGroundServer += new Manipulator(RemoveVanillaE3);
				RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(AddNewE3);
			}
			if (enableE5Changes.Value)
			{
				HealthComponent.Heal += new Manipulator(TweakVanillaE5);
			}
			if (enableE6Changes.Value)
			{
				DeathRewards.OnKilledServer += new Manipulator(RemoveVanillaE6);
			}
		}

		private void ChangeDescriptions()
		{
			string text = "Starts at baseline Monsoon difficulty.\n";
			string text2 = "\n<mspace=0.5em>(1)</mspace> Difficulty Scaling: <style=cIsHealth>+25%</style></style>";
			string text3 = "\n<mspace=0.5em>(2)</mspace> Director Credits: <style=cIsHealth>+20%</style></style>";
			string text4 = "\n<mspace=0.5em>(3)</mspace> Enemy Attack Speed: <style=cIsHealth>+25%</style></style>";
			string text5 = "\n<mspace=0.5em>(4)</mspace> Enemies: <style=cIsHealth>+40% Faster</style></style>";
			string text6 = "\n<mspace=0.5em>(5)</mspace> Ally Healing: <style=cIsHealth>-25%</style></style>";
			string text7 = "\n<mspace=0.5em>(6)</mspace> Director Credit Generation: <style=cIsHealth>+15% Faster</style></style>";
			string text8 = "\n<mspace=0.5em>(7)</mspace> Enemy Cooldowns: <style=cIsHealth>-50%</style></style>";
			string text9 = "\n<mspace=0.5em>(8)</mspace> Allies recieve <style=cIsHealth>permanent damage</style></style>";
			string text10 = "\"You only celebrate in the light... because I allow it.\" \n\n";
			LanguageAPI.Add("ECLIPSE_1_DESCRIPTION", text + text2);
			LanguageAPI.Add("ECLIPSE_2_DESCRIPTION", text + text2 + text3);
			LanguageAPI.Add("ECLIPSE_3_DESCRIPTION", text + text2 + text3 + text4);
			LanguageAPI.Add("ECLIPSE_4_DESCRIPTION", text + text2 + text3 + text4 + text5);
			LanguageAPI.Add("ECLIPSE_5_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6);
			LanguageAPI.Add("ECLIPSE_6_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6 + text7);
			LanguageAPI.Add("ECLIPSE_7_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6 + text7 + text8);
			LanguageAPI.Add("ECLIPSE_8_DESCRIPTION", text10 + text + text2 + text3 + text4 + text5 + text6 + text7 + text8 + text9);
		}

		private void AddNewE1(orig_RecalculateDifficultyCoefficentInternal orig, Run self)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			float runStopwatch = self.GetRunStopwatch();
			DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(self.selectedDifficulty);
			float num = difficultyDef.scalingValue;
			if (difficultyDef.nameToken.Contains("ECLIPSE"))
			{
				num *= 1.25f;
			}
			float num2 = Mathf.Floor(runStopwatch * (1f / 60f));
			float num3 = (float)self.participatingPlayerCount * 0.3f;
			float num4 = 0.7f + num3;
			float num5 = 0.7f + num3;
			float num6 = Mathf.Pow((float)self.participatingPlayerCount, 0.2f);
			float num7 = 0.0506f * num * num6;
			float num8 = 0.0506f * num * num6;
			float num9 = Mathf.Pow(1.15f, (float)self.stageClearCount);
			self.compensatedDifficultyCoefficient = (num5 + num8 * num2) * num9;
			self.difficultyCoefficient = (num4 + num7 * num2) * num9;
			self.ambientLevel = Mathf.Min((float)(((double)((num4 + num7 * (runStopwatch * (1f / 60f))) * Mathf.Pow(1.15f, (float)self.stageClearCount)) - (double)num4) / 0.33000001311302185 + 1.0), (float)Run.ambientLevelCap);
			int ambientLevelFloor = self.ambientLevelFloor;
			self.ambientLevelFloor = Mathf.FloorToInt(self.ambientLevel);
			if (ambientLevelFloor != self.ambientLevelFloor && ambientLevelFloor != 0 && self.ambientLevelFloor > ambientLevelFloor)
			{
				self.OnAmbientLevelUp();
			}
		}

		private void RemoveVanillaE1(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f)
			}))
			{
				val.Next.Operand = 1f;
			}
			else
			{
				Debug.LogError((object)"EclipseRevamped: Failed to remove vanilla E1");
			}
		}

		private void AddNewE2E6(orig_Awake orig, CombatDirector self)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				if (enableE2Changes.Value && (int)Run.instance.selectedDifficulty >= 4)
				{
					self.creditMultiplier += 0.2f;
				}
				if (enableE6Changes.Value && (int)Run.instance.selectedDifficulty >= 8)
				{
					for (int i = 0; i < self.moneyWaveIntervals.Length; i++)
					{
						self.moneyWaveIntervals[i].min *= 0.85f;
						self.moneyWaveIntervals[i].max *= 0.85f;
					}
				}
			}
			orig.Invoke(self);
		}

		private void RemoveVanillaE2(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f)
			}))
			{
				val.Next.Operand = 1f;
			}
			else
			{
				Debug.LogError((object)"EclipseRevamped: Failed to remove vanilla E2");
			}
		}

		private void RemoveVanillaE3(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 5)
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int useless) => int.MaxValue));
			}
			else
			{
				Debug.LogError((object)"EclipseRevamped: Failed to remove vanilla E3");
			}
		}

		private void AddNewE3(CharacterBody sender, StatHookEventArgs args)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)Run.instance) && (int)Run.instance.selectedDifficulty >= 5 && Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.teamComponent) && (int)sender.teamComponent.teamIndex != 1)
			{
				args.attackSpeedMultAdd += 0.25f;
			}
		}

		private void TweakVanillaE5(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 2f),
				(Instruction x) => ILPatternMatchingExt.MatchDiv(x)
			}))
			{
				val.Next.Operand = 1.33f;
			}
			else
			{
				Debug.LogError((object)"EclipseRevamped: Failed to tweak vanilla E5");
			}
		}

		private void RemoveVanillaE6(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.8f)
			}))
			{
				val.Next.Operand = 1f;
			}
			else
			{
				Debug.LogError((object)"EclipseRevamped: Failed to remove vanilla E6");
			}
		}
	}
}