Decompiled source of ShrineOfFIWB v1.0.0

plugins/ShrineOfFIWB.dll

Decompiled 2 days 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 IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;

[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("ShrineOfFIWB")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+68fb1e41de11f9d016fdcf9254e2128d19691102")]
[assembly: AssemblyProduct("ShrineOfFIWB")]
[assembly: AssemblyTitle("ShrineOfFIWB")]
[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 ShrineOfFIWB
{
	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);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Nerdman.ShrineOfFIWB", "ShrineOfFIWB", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "Nerdman.ShrineOfFIWB";

		public const string PluginAuthor = "Nerdman";

		public const string PluginName = "ShrineOfFIWB";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<string> ShrineActivationMessage;

		public static ConfigEntry<string> TpWithShrineMessage;

		public void Awake()
		{
			Init();
			CreateLang();
			Hooks();
		}

		public void Init()
		{
			ShrineActivationMessage = ((BaseUnityPlugin)this).Config.Bind<string>("Mod: ShrineOfFIWB", "Interaction message:", "FUCK IT WE BALL!!", "The message that should display when you activate a mountain shrine\n(Default: FUCK IT WE BALL!!)");
			TpWithShrineMessage = ((BaseUnityPlugin)this).Config.Bind<string>("Mod: ShrineOfFIWB", "Teleporter message:", "LET THE BALLING... BEGIN!!", "The message that should display when you activate a teleporter with a mountain shrine\n(Default: LET THE BALLING... BEGIN!!)");
			CoolerInit();
		}

		public void CoolerInit()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ShrineActivationMessage));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(TpWithShrineMessage));
		}

		public void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ShrineBossBehavior.AddShrineStack += new Manipulator(ActivationText);
			IdleState.OnInteractionBegin += new Manipulator(TpText);
		}

		private void ActivationText(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdstr(i, "SHRINE_BOSS_USE_MESSAGE")
			});
			val.Remove();
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<ShrineBossBehavior, string>>((Func<ShrineBossBehavior, string>)((ShrineBossBehavior self) => "SHRINE_FIWB_USE_MESSAGE"));
		}

		private void TpText(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdstr(i, "SHRINE_BOSS_BEGIN_TRIAL")
			});
			val.Remove();
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<ShrineBossBehavior, string>>((Func<ShrineBossBehavior, string>)((ShrineBossBehavior self) => "SHRINE_FIWB_BEGIN_TRIAL"));
		}

		public static void CreateLang()
		{
			LanguageAPI.Add("SHRINE_FIWB_USE_MESSAGE", "<style=cShrine>" + ShrineActivationMessage.Value + "</style>");
			LanguageAPI.Add("SHRINE_FIWB_USE_MESSAGE_2P", "<style=cShrine>" + ShrineActivationMessage.Value + "</style>");
			LanguageAPI.Add("SHRINE_FIWB_BEGIN_TRIAL", "<style=cShrine>" + TpWithShrineMessage.Value + "</style>");
		}
	}
}