Decompiled source of MithrixTweaks v1.0.4

MithrixMinions.dll

Decompiled 2 weeks 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 BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.BrotherMonster;
using Microsoft.CodeAnalysis;
using On.EntityStates.BrotherMonster;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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("MithrixMinions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5f85a5375d5e68eec2059428903fb9a48c4df019")]
[assembly: AssemblyProduct("MithrixMinions")]
[assembly: AssemblyTitle("MithrixMinions")]
[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 MithrixMinions
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("OakPrime.MithrixTweaks", "MithrixTweaks", "1.0.4")]
	public class MithrixMinions : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action <>9__7_0;

			public static hook_OnEnter <>9__7_1;

			internal void <Awake>b__7_0()
			{
				ExitSkyLeap.waveProjectileDamageCoefficient *= MMConfig.waveDmgMultiplier.Value;
			}

			internal void <Awake>b__7_1(orig_OnEnter orig, HoldSkyLeap self)
			{
				orig.Invoke(self);
				MithrixMinionsBehavior component = ((Component)((EntityState)self).characterBody).GetComponent<MithrixMinionsBehavior>();
				if ((Object)(object)component != (Object)null)
				{
					component.KillMinions();
				}
			}
		}

		public const string PluginGUID = "OakPrime.MithrixTweaks";

		public const string PluginAuthor = "OakPrime";

		public const string PluginName = "MithrixTweaks";

		public const string PluginVersion = "1.0.4";

		private SpawnCard minionSpawnCard = Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/Base/LunarExploder/cscLunarExploder.asset").WaitForCompletion();

		private float timer;

		private const float WAVECOOLDOWN = 1.4f;

		public void Awake()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			try
			{
				MMConfig.InitializeConfig();
				if ((double)MMConfig.waveDmgMultiplier.Value != 1.0)
				{
					RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
					{
						ExitSkyLeap.waveProjectileDamageCoefficient *= MMConfig.waveDmgMultiplier.Value;
					});
				}
				if (MMConfig.waveCount.Value > 1)
				{
					int wavesCompleted = 1;
					ExitSkyLeap.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, ExitSkyLeap self)
					{
						orig.Invoke(self);
						timer = 1.4f;
						wavesCompleted = 1;
					};
					ExitSkyLeap.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, ExitSkyLeap self)
					{
						orig.Invoke(self);
						timer -= Time.fixedDeltaTime;
						if (timer <= 0f && wavesCompleted < MMConfig.waveCount.Value)
						{
							self.FireRingAuthority();
							timer = 1.4f;
							wavesCompleted++;
						}
					};
				}
				if (MMConfig.minionCount.Value <= 0)
				{
					return;
				}
				object obj = <>c.<>9__7_1;
				if (obj == null)
				{
					hook_OnEnter val = delegate(orig_OnEnter orig, HoldSkyLeap self)
					{
						orig.Invoke(self);
						MithrixMinionsBehavior component = ((Component)((EntityState)self).characterBody).GetComponent<MithrixMinionsBehavior>();
						if ((Object)(object)component != (Object)null)
						{
							component.KillMinions();
						}
					};
					<>c.<>9__7_1 = val;
					obj = (object)val;
				}
				HoldSkyLeap.OnEnter += (hook_OnEnter)obj;
				ExitSkyLeap.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, ExitSkyLeap self)
				{
					//IL_004a: Unknown result type (might be due to invalid IL or missing references)
					//IL_004f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0065: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0080: Unknown result type (might be due to invalid IL or missing references)
					//IL_0085: Unknown result type (might be due to invalid IL or missing references)
					//IL_009b: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00da: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
					//IL_0100: Unknown result type (might be due to invalid IL or missing references)
					//IL_0114: Expected O, but got Unknown
					//IL_010f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0114: Unknown result type (might be due to invalid IL or missing references)
					//IL_0125: Expected O, but got Unknown
					//IL_0120: Unknown result type (might be due to invalid IL or missing references)
					//IL_0159: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self);
					MithrixMinionsBehavior mithrixMinionsBehavior = ((Component)((EntityState)self).characterBody).GetComponent<MithrixMinionsBehavior>();
					if ((Object)(object)mithrixMinionsBehavior == (Object)null)
					{
						mithrixMinionsBehavior = ((Component)((EntityState)self).characterBody).gameObject.AddComponent<MithrixMinionsBehavior>();
					}
					Vector3[] array = (Vector3[])(object)new Vector3[4]
					{
						new Vector3(25f, 0f, 25f),
						new Vector3(-25f, 0f, -25f),
						new Vector3(25f, 0f, -25f),
						new Vector3(-25f, 0f, 25f)
					};
					for (int i = 0; i < MMConfig.minionCount.Value; i++)
					{
						GameObject spawnedInstance = minionSpawnCard.DoSpawn(((EntityState)self).characterBody.footPosition + array[i % 4] + array[i % 4] * (float)(i / 4) * 0.5f, Quaternion.identity, new DirectorSpawnRequest(minionSpawnCard, new DirectorPlacementRule
						{
							placementMode = (PlacementMode)0
						}, Run.instance.runRNG)
						{
							teamIndexOverride = (TeamIndex)2
						}).spawnedInstance;
						NetworkServer.Spawn(spawnedInstance);
						CharacterBody body = spawnedInstance.gameObject.GetComponent<CharacterMaster>().GetBody();
						body.teamComponent.teamIndex = ((EntityState)self).characterBody.teamComponent.teamIndex;
						mithrixMinionsBehavior.AddMinion(spawnedInstance.gameObject.GetComponent<CharacterMaster>().GetBody());
					}
				};
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
			}
		}
	}
	internal class MithrixMinionsBehavior : MonoBehaviour
	{
		private List<CharacterBody> minions = new List<CharacterBody>();

		private void OnDisable()
		{
			KillMinions();
		}

		public void AddMinion(CharacterBody minion)
		{
			minions.Add(minion);
		}

		public void KillMinions()
		{
			for (int i = 0; i < minions.Count; i++)
			{
				minions[i].healthComponent.health = 0f;
			}
			minions.Clear();
		}
	}
	internal static class MMConfig
	{
		public static ConfigEntry<int> minionCount;

		public static ConfigEntry<int> waveCount;

		public static ConfigEntry<float> waveDmgMultiplier;

		public static void InitializeConfig()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			ConfigFile val = new ConfigFile(Paths.ConfigPath + "\\OakPrime.MithrixMinions.cfg", true);
			minionCount = val.Bind<int>("Main", "Mithrix Lunar Exploder Count", 4, "Mithrix summons this many Lunar Exploders. Default:4. Vanilla:0. Max:12");
			minionCount.Value = Math.Clamp(minionCount.Value, 0, 12);
			waveCount = val.Bind<int>("Main", "Mithrix Sky Slam Wave Count", 3, "Mithrix sky slam produces this many waves. Default:3. Vanilla:1. Valid Range:1-3.");
			waveCount.Value = Math.Clamp(waveCount.Value, 1, 3);
			waveDmgMultiplier = val.Bind<float>("Main", "Mithrix Sky Slam Wave Damage Multiplier", 0.4f, "Mithrix sky slam damage is multiplied by this number. Default:0.4. Vanilla:1.");
			waveDmgMultiplier.Value = Math.Clamp(waveDmgMultiplier.Value, 0f, 100f);
		}
	}
}