Decompiled source of MithrixTweaks v1.0.2

MithrixMinions.dll

Decompiled a month 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.Logging;
using EntityStates;
using EntityStates.BrotherMonster;
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 = "")]
[assembly: AssemblyCompany("MithrixMinions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MithrixMinions")]
[assembly: AssemblyTitle("MithrixMinions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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.2")]
public class MithrixMinions : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Action <>9__5_0;

		public static hook_OnEnter <>9__5_2;

		internal void <Awake>b__5_0()
		{
			ExitSkyLeap.waveProjectileDamageCoefficient /= 2.5f;
		}

		internal void <Awake>b__5_2(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.2";

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

	public void Awake()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Expected O, but got Unknown
		Log.Init(((BaseUnityPlugin)this).Logger);
		try
		{
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				ExitSkyLeap.waveProjectileDamageCoefficient /= 2.5f;
			});
			float timer = 1.55f;
			ExitSkyLeap.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, ExitSkyLeap self)
			{
				orig.Invoke(self);
				timer -= Time.fixedDeltaTime;
				if (timer <= 0f)
				{
					Log.LogDebug("Fired wave");
					self.FireRingAuthority();
					timer = 1.4f;
				}
			};
			object obj = <>c.<>9__5_2;
			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__5_2 = val;
				obj = (object)val;
			}
			HoldSkyLeap.OnEnter += (hook_OnEnter)obj;
			ExitSkyLeap.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, ExitSkyLeap self)
			{
				//IL_007b: 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_0096: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Expected O, but got Unknown
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Expected O, but got Unknown
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self);
				timer = 1.55f;
				((BaseUnityPlugin)this).Logger.LogDebug((object)("Duration: " + self.duration));
				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 < 4; i++)
				{
					GameObject spawnedInstance = minionSpawnCard.DoSpawn(((EntityState)self).characterBody.footPosition + array[i], Quaternion.identity, new DirectorSpawnRequest(minionSpawnCard, new DirectorPlacementRule
					{
						placementMode = (PlacementMode)0
					}, Run.instance.runRNG)
					{
						teamIndexOverride = (TeamIndex)2
					}).spawnedInstance;
					NetworkServer.Spawn(spawnedInstance);
					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();
	}
}