Decompiled source of ImmersiveLore v1.0.0

ImmersiveLore/BunsRoR2Mods.dll

Decompiled 18 hours ago
using System;
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 Microsoft.CodeAnalysis;
using On.RoR2;
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
{
	[BepInPlugin("Lilybunvy.ImmersiveLore", "ImmersiveLore", "1.0.0")]
	public class ImmersiveLorePlugin : BaseUnityPlugin
	{
		public const string PluginAuthor = "Lilybunvy";

		public const string PluginName = "ImmersiveLore";

		public const string PluginGUID = "Lilybunvy.ImmersiveLore";

		public const string PluginVersion = "1.0.0";

		public int chargedPillarsNum;

		public string[] pillarPrefixes;

		public string[] loreEntries;

		public void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			chargedPillarsNum = 0;
			LoadLoreStrings();
			Run.onRunStartGlobal += OnRunStart;
			MoonBatteryMissionController.OnBatteryCharged += new hook_OnBatteryCharged(MoonBatteryMissionController_OnBatteryCharged);
		}

		private void OnRunStart(Run run)
		{
			chargedPillarsNum = 0;
		}

		private void MoonBatteryMissionController_OnBatteryCharged(orig_OnBatteryCharged orig, MoonBatteryMissionController self, HoldoutZoneController holdoutZone)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				orig.Invoke(self, holdoutZone);
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "moon2")
			{
				orig.Invoke(self, holdoutZone);
				return;
			}
			string name = ((((Object)holdoutZone).name[11] == 'M') ? "Pillar of Mass" : ((((Object)holdoutZone).name[11] == 'D') ? "Pillar of Design" : ((((Object)holdoutZone).name[11] == 'B') ? "Pillar of Blood" : ((((Object)holdoutZone).name[11] != 'S') ? "Pillar" : "Pillar of Soul"))));
			chargedPillarsNum++;
			SendLore(chargedPillarsNum, name);
			orig.Invoke(self, holdoutZone);
		}

		private void SendLore(int num, string name)
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			if (num > loreEntries.Length)
			{
				chargedPillarsNum = 1;
				num = 1;
			}
			string text = "";
			int num2 = 0;
			for (int i = 0; i < loreEntries[num - 1].Length; i++)
			{
				if (loreEntries[num - 1][i] == '%' && loreEntries[num - 1][i + 1] == 'N')
				{
					text = text + loreEntries[num - 1].Substring(num2, i - num2) + name + ": ";
					num2 = i + 2;
				}
			}
			text += loreEntries[num - 1].Substring(num2, loreEntries[num - 1].Length - num2);
			text = text.Replace("%\"", "");
			text = pillarPrefixes[Random.Range(0, pillarPrefixes.Length)].Replace("%N", name) + "...\n" + text;
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "<style=cLunarObjective>" + text + "</style>"
			});
		}

		private void LoadLoreStrings()
		{
			pillarPrefixes = new string[3] { "The %N speaks", "The %N trembles", "The %N echoes" };
			loreEntries = new string[8];
			loreEntries[0] = "%N%\"...It looks like starseed, tanning in dirt...%\"\n%N%\"...It sounds like two brothers, chasing glass frogs in the sun...";
			loreEntries[1] = "%N%\"...He knew his brother loved worms...\n%N%\"...So, when his brother wasn't looking, he threw them to the gravity wells... Thorp!";
			loreEntries[2] = "%N%\"...He never cared much for worms or vermin, he was just curious...%\"\n%N%\"...But one day, his brother was watching...%\"\n%N%\"...and Providence loved worms.";
			loreEntries[3] = "%N%\"...Over time, as he began to fear his brother was too dangerous, Providence vowed to protect all life...%\"\n%N%\"...And so, Providence sealed his brother far, far away, to a desolate place...%\"\n%N%\"...To be a King of Nothing.";
			loreEntries[4] = "%N%\"...Overcome with vengeance, the King of Nothing created powerful lunar relics...%\"\n%N%\"...And sent them down to the planet, corrupting it's inhabitants with his influence...%\"";
			loreEntries[5] = "%N%\"...The King of Nothing designed new constructs...%\"\n%N%\"...Lunar Chimeras, beings of Design, Soul, Mass and Blood...%\"\n%N%\"...Slowly, he began to build his own kingdom...%\"";
			loreEntries[6] = "%N%\"...Though even as the King of Nothing toiled, Petrichor V was changing...%\"\n%N%\"...With the fall of Providence, the balance of power was shifting...%\"\n%N%\"...And still, The King of Nothing remained trapped on the moon, oblivious to it all...%\"";
			loreEntries[7] = "%N%\"...%\"\n%N%\"...%\"";
		}
	}
	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));
		}
	}
}