Decompiled source of Mega Tempest v1.1.4

MegaTempest.dll

Decompiled a month 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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
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("MegaTempest")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MegaTempest")]
[assembly: AssemblyTitle("MegaTempest")]
[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 MegaTempest
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("MegaTempest", "MegaTempest", "1.1.4")]
	internal class DifficultyExample : BaseUnityPlugin
	{
		public static AssetBundle assetBundle;

		private DifficultyIndex myIndex;

		public static ConfigEntry<float> difficultyScaling { get; set; }

		public static ConfigEntry<float> movementSpeedBonus { get; set; }

		public static ConfigEntry<float> attackSpeedBonus { get; set; }

		public static ConfigEntry<float> armorPerLevel { get; set; }

		public static ConfigEntry<bool> decreaseEnemyDamage { get; set; }

		public static ConfigEntry<float> reductionBeginning { get; set; }

		public static ConfigEntry<float> reductionMiddle { get; set; }

		public static ConfigEntry<bool> debug { get; set; }

		private void Awake()
		{
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			Run.onRunSetRuleBookGlobal += removeLevelCap;
			difficultyScaling = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Difficulty Scaling", 8f, "The difficulty scaling. Monsoon is 3, Tempest is 6, default is 8");
			movementSpeedBonus = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Movement Speed", 0.35f, "The movement speed bonus given to monsters. Default is 0.35");
			attackSpeedBonus = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Attack Speed", 0.25f, "The attack speed bonus given to monsters. Default is 0.25");
			armorPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Armor per Level", 1f, "The armor per level given to monsters. Default is 1");
			decreaseEnemyDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Experimental", "Decrease Enemy Damage", false, "Whether the changes to enemy baseDamage should be applied or not.\nThis will recude the amount of baseDamage enemies gain per level, the higher their level gets.");
			reductionBeginning = ((BaseUnityPlugin)this).Config.Bind<float>("Experimental", "Beginn reduction at level", 10f, "DO NOT CHANGE CARELESSLY:\nDefines when the damage drop of for enemies should start.\nRepresents x in the formula:\n(level-x)/(level+y)");
			reductionMiddle = ((BaseUnityPlugin)this).Config.Bind<float>("Experimental", "50% reduction at level", 250f, "DO NOT CHANGE CARELESSLY:\nDetermines at which level reduction is approximately 50%.\nRepresents y in the formula:\n(level-x)/(level+y)");
			debug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Debug", false, "Will print debug messages into the console. (For development purposes)");
			assetBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("MegaTempest.dll", "assets1"));
			DifficultyDef val = new DifficultyDef(difficultyScaling.Value, "MEGA_TEMPEST_NAME", "", "MEGA_TEMPEST_DESC", new Color(0.5f, 0.1f, 0.2f), "nr", true);
			val.foundIconSprite = true;
			val.iconSprite = assetBundle.LoadAsset<Sprite>("assets/importantfolder/icon.png");
			myIndex = DifficultyAPI.AddDifficulty(val);
			LanguageTokens();
			Run.onRunStartGlobal += delegate(Run run)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				if (run.selectedDifficulty != myIndex)
				{
				}
			};
			Run.onRunDestroyGlobal += delegate(Run run)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				if (run.selectedDifficulty != myIndex)
				{
				}
			};
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
			if (debug.Value)
			{
				Console.WriteLine("Mega Tempest awake completed.");
			}
		}

		private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			DifficultyIndex selectedDifficulty = Run.instance.selectedDifficulty;
			if (selectedDifficulty != myIndex || !Object.op_Implicit((Object)(object)sender) || !Object.op_Implicit((Object)(object)sender.teamComponent) || !(((Object)((Component)sender).gameObject).name != "BrotherBody(Clone)") || (int)sender.teamComponent.teamIndex != 2)
			{
				return;
			}
			args.moveSpeedMultAdd += movementSpeedBonus.Value;
			args.attackSpeedMultAdd += attackSpeedBonus.Value;
			args.levelArmorAdd += armorPerLevel.Value;
			if (decreaseEnemyDamage.Value)
			{
				float num = Math.Max(0f, (sender.level - reductionBeginning.Value) / (sender.level + reductionMiddle.Value));
				float damage = sender.damage;
				args.levelDamageAdd -= sender.levelDamage * num;
				if (debug.Value)
				{
					Console.WriteLine(((Object)sender).name + "(" + sender.level + ") " + sender.baseDamage + " + " + sender.levelDamage + " * " + (sender.level - 1f) + "L = " + (sender.baseDamage + sender.levelDamage * (sender.level - 1f)) + " (" + damage + ") -> " + sender.damage + " (" + num + ")");
				}
			}
		}

		private void removeLevelCap(Run run, RuleBook rulebook)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (run.selectedDifficulty == myIndex)
			{
				Run.ambientLevelCap = int.MaxValue;
			}
		}

		private void LanguageTokens()
		{
			LanguageAPI.Add("MEGA_TEMPEST_NAME", "Mega Tempest");
			string text = "Prepare for hell. <style=cStack>\n\n>Difficulty scaling: <style=cIsHealth>+" + (difficultyScaling.Value * 50f - 100f) + "%</style>\n>Enemy Movement speed: <style=cIsHealth>+" + movementSpeedBonus.Value * 100f + "%</style>\n>Enemy Attack speed: <style=cIsHealth>+" + attackSpeedBonus.Value * 100f + "%</style>\n>Enemy Armor per level: <style=cIsHealth>+" + armorPerLevel.Value + "</style>";
			if (decreaseEnemyDamage.Value)
			{
				text += "\n>EXPERIMENTAL: <style=cIsHealing>Enemy Damage is lowered on higher levels</style>";
			}
			LanguageAPI.Add("MEGA_TEMPEST_DESC", text);
		}
	}
}
namespace ExamplePlugin
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}