Decompiled source of OrderlyShrines v1.0.0

orderly_shrines.dll

Decompiled 2 months 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 Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
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("orderly_shrines")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("orderly_shrines")]
[assembly: AssemblyTitle("orderly_shrines")]
[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 OrderlyShrines
{
	[BepInPlugin("com.yourusername.orderlyshrines", "Orderly Shrines", "1.0.0")]
	public class OrderlyShrine : BaseUnityPlugin
	{
		public const string PluginGUID = "com.yourusername.orderlyshrines";

		public const string PluginName = "Orderly Shrines";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<bool> EnableMod;

		public static ConfigEntry<bool> ShowMessage;

		public void Awake()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "Enable or disable the Orderly Shrines mod");
			ShowMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Order Message", true, "Show 'You have been... sequenced.' message when using any shrine");
			PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(PurchaseInteraction_OnInteractionBegin);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Orderly Shrines v1.0.0 is loaded!");
		}

		private void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
		{
			orig.Invoke(self, activator);
			if (!EnableMod.Value || !NetworkServer.active)
			{
				return;
			}
			string text = ((Object)((Component)self).gameObject).name.ToLower();
			bool flag = false;
			bool flag2 = false;
			if (text.Contains("shrine"))
			{
				flag = true;
				if (text.Contains("shrinerest") || text.Contains("lunarrecycler") || text.Contains("order"))
				{
					flag2 = true;
				}
			}
			if (flag && !flag2)
			{
				ApplyOrderEffect(activator);
			}
		}

		private void ApplyOrderEffect(Interactor activator)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00a1: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
			{
				component.inventory.ShrineRestackInventory(Run.instance.treasureRng);
				if (ShowMessage.Value)
				{
					Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
					{
						subjectAsCharacterBody = component,
						baseToken = "SHRINE_RESTACK_USE_MESSAGE"
					});
				}
				EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
				{
					origin = ((Component)component).transform.position,
					rotation = Quaternion.identity,
					scale = 1f,
					color = Color32.op_Implicit(new Color(0.7f, 0.7f, 1f))
				}, true);
			}
		}

		public void OnDestroy()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			PurchaseInteraction.OnInteractionBegin -= new hook_OnInteractionBegin(PurchaseInteraction_OnInteractionBegin);
		}
	}
}