Decompiled source of SaleStarReminder v1.1.0

BepInEx/plugins/SaleStarReminder/SaleStarReminder.dll

Decompiled a day 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.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.UI;

[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("SaleStarReminder")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SaleStarReminder")]
[assembly: AssemblyTitle("SaleStarReminder")]
[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 SaleStarReminder
{
	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.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("OppositeWolf770.SaleStarReminder", "SaleStarReminder", "1.0.0")]
	public class SaleStarReminder : BaseUnityPlugin
	{
		public class SaleStarVisibilityController : MonoBehaviour
		{
			private Text _textComponent;

			private ItemIndex _saleStarIndex;

			private bool _indexFound = false;

			private bool temporarilyDisabled = false;

			public void Start()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Invalid comparison between Unknown and I4
				_textComponent = ((Component)this).GetComponent<Text>();
				((Behaviour)_textComponent).enabled = false;
				_saleStarIndex = ItemCatalog.FindItemIndex("LowerPricedChests");
				if ((int)_saleStarIndex != -1)
				{
					_indexFound = true;
				}
			}

			public void Update()
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				if (!_indexFound)
				{
					temporarilyDisabled = false;
					return;
				}
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				if (firstLocalUser != null && (Object)(object)firstLocalUser.cachedMaster != (Object)null && (Object)(object)firstLocalUser.cachedMaster.inventory != (Object)null)
				{
					int itemCount = firstLocalUser.cachedMaster.inventory.GetItemCount(_saleStarIndex);
					((Behaviour)_textComponent).enabled = itemCount > 0 && !temporarilyDisabled;
				}
				if (Input.GetKeyDown((KeyCode)284))
				{
					temporarilyDisabled = !temporarilyDisabled;
					Chat.AddMessage("Sale Star Reminder message set to " + (temporarilyDisabled ? "disabled" : "enabled") + ".");
				}
			}
		}

		public const string PluginGUID = "OppositeWolf770.SaleStarReminder";

		public const string PluginAuthor = "OppositeWolf770";

		public const string PluginName = "SaleStarReminder";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			HUD.Awake += new hook_Awake(HUD_Awake);
		}

		private void HUD_Awake(orig_Awake orig, HUD self)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			GameObject val = new GameObject("SaleStarOverlay");
			val.transform.SetParent(self.mainContainer.transform);
			RectTransform val2 = val.AddComponent<RectTransform>();
			((Transform)val2).localPosition = Vector3.zero + new Vector3(0f, 60f);
			val2.anchorMin = new Vector2(0.5f, 0.5f);
			val2.anchorMax = new Vector2(0.5f, 0.5f);
			val2.pivot = new Vector2(0.5f, 0.5f);
			val2.sizeDelta = new Vector2(500f, 100f);
			Text val3 = val.AddComponent<Text>();
			val3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val3.text = "★ SALE STAR ACTIVE ★";
			val3.fontSize = 32;
			val3.alignment = (TextAnchor)4;
			((Graphic)val3).color = Color.yellow;
			val.AddComponent<SaleStarVisibilityController>();
		}
	}
}