Decompiled source of MithrixSurpriseExpanded v1.0.0

MithrixSurpriseExpanded/BunsRoR2Mods.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
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 Microsoft.CodeAnalysis;
using On.EntityStates.BrotherMonster;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[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("BunsRoR2Mods")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BunsRoR2Mods")]
[assembly: AssemblyTitle("BunsRoR2Mods")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 BunsRoR2Mods
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
	[BepInPlugin("Lilybunvy.MithrixSurpriseExpanded", "MithrixSurpriseExpanded", "1.0.0")]
	public class MithrixSurpriseExpandedPlugin : BaseUnityPlugin
	{
		public const string PluginAuthor = "Lilybunvy";

		public const string PluginName = "MithrixSurpriseExpanded";

		public const string PluginGUID = "Lilybunvy.MithrixSurpriseExpanded";

		public const string PluginVersion = "1.0.0";

		public int currentStageGiven;

		public bool isMithrixSurprisingUs;

		public string[] mithrixPhrasesArrive;

		public string[] mithrixPhrasesTaunt;

		public string[] mithrixPhrasesLeave;

		public void Awake()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			currentStageGiven = -1;
			isMithrixSurprisingUs = false;
			mithrixPhrasesArrive = new string[4] { "YOUR END IS NOW.", "RUN, VERMIN.", "TOO SLOW.", "I FOUND YOU." };
			mithrixPhrasesTaunt = new string[10] { "BROTHERHURT_DAMAGEDEALT_1", "BROTHERHURT_DAMAGEDEALT_2", "BROTHERHURT_DAMAGEDEALT_3", "BROTHERHURT_DAMAGEDEALT_4", "BROTHERHURT_DAMAGEDEALT_5", "BROTHERHURT_DAMAGEDEALT_6", "BROTHERHURT_DAMAGEDEALT_7", "BROTHERHURT_DAMAGEDEALT_8", "BROTHERHURT_DAMAGEDEALT_9", "BROTHERHURT_DAMAGEDEALT_10" };
			mithrixPhrasesLeave = new string[2] { "BE GONE, VERMIN.", "INSIGNIFICANT - AND POINTLESS." };
			Run.onRunStartGlobal += OnRunStart;
			SkySpawnState.OnEnter += new hook_OnEnter(OnMithrixSpawn);
			SkyLeapDeathState.OnEnter += new hook_OnEnter(OnMithrixDeath);
		}

		private void OnRunStart(Run run)
		{
			currentStageGiven = -1;
			isMithrixSurprisingUs = false;
		}

		private void SendMithrixArrivalInChat()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (mithrixPhrasesArrive.Length != 0)
			{
				Chat.SendBroadcastChat((ChatMessageBase)new NpcChatMessage
				{
					formatStringToken = "BROTHER_DIALOGUE_FORMAT",
					baseToken = mithrixPhrasesArrive[Random.Range(0, mithrixPhrasesArrive.Length)],
					sender = null
				});
			}
		}

		private void SendMithrixDefeatInChat()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (mithrixPhrasesLeave.Length != 0)
			{
				Chat.SendBroadcastChat((ChatMessageBase)new NpcChatMessage
				{
					formatStringToken = "BROTHER_DIALOGUE_FORMAT",
					baseToken = mithrixPhrasesLeave[Random.Range(0, mithrixPhrasesLeave.Length)],
					sender = null
				});
			}
		}

		private void SendMithrixTauntInChat()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (mithrixPhrasesTaunt.Length != 0)
			{
				Chat.SendBroadcastChat((ChatMessageBase)new NpcChatMessage
				{
					formatStringToken = "BROTHER_DIALOGUE_FORMAT",
					baseToken = mithrixPhrasesTaunt[Random.Range(0, mithrixPhrasesTaunt.Length)],
					sender = null
				});
			}
		}

		private IEnumerator MithrixKeepDoingRandomTaunts()
		{
			while (isMithrixSurprisingUs)
			{
				yield return (object)new WaitForSeconds(8f);
				if (!isMithrixSurprisingUs)
				{
					break;
				}
				SendMithrixTauntInChat();
			}
		}

		private void OnMithrixSpawn(orig_OnEnter orig, SkySpawnState self)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				orig.Invoke(self);
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "moon2")
			{
				isMithrixSurprisingUs = true;
				SendMithrixArrivalInChat();
				((MonoBehaviour)this).StartCoroutine(MithrixKeepDoingRandomTaunts());
			}
			orig.Invoke(self);
		}

		private void OnMithrixDeath(orig_OnEnter orig, SkyLeapDeathState self)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				orig.Invoke(self);
				return;
			}
			if (currentStageGiven != Run.instance.stageClearCount)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name != "moon2")
				{
					isMithrixSurprisingUs = false;
					SendMithrixDefeatInChat();
					((MonoBehaviour)this).StartCoroutine(MithrixIsSlowlyLeaving(((EntityState)self).characterBody.footPosition));
				}
			}
			orig.Invoke(self);
		}

		private IEnumerator MithrixIsSlowlyLeaving(Vector3 pos)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(1f);
			int playerCount = Run.instance.participatingPlayerCount;
			float angle = 360f / (float)playerCount;
			Vector3 vector = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
			Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.up);
			for (int i = 0; i < playerCount; i++)
			{
				PickupDropletController.CreatePickupDroplet(new UniquePickup(PickupCatalog.FindPickupIndex(Items.ShinyPearl.itemIndex)), pos + new Vector3(0f, 3f, 0f), vector, false);
				vector = rotation * vector;
			}
		}
	}
}