Decompiled source of LunarBottledChaos v2.0.1

LunarBottledChaos.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HDeMods.LUNAR;
using HDeMods.LunarBottleOptionalMods;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LunarBottledChaos")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LunarBottledChaos")]
[assembly: AssemblyTitle("LunarBottledChaos")]
[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 HDeMods
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.HDeDeDe.LunarBottledChaos", "LunarBottledChaos", "2.0.0")]
	public class LunarBottledChaos : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__LunarIt;

			public static hook_RegisterEquipment <1>__AddAllLunars;
		}

		public const string PluginGUID = "com.HDeDeDe.LunarBottledChaos";

		public const string PluginAuthor = "HDeDeDe";

		public const string PluginName = "LunarBottledChaos";

		public const string PluginVersion = "2.0.0";

		private static AssetBundle m_bottle;

		private static Sprite m_bottlePicsOrItDidntHappen;

		private static ConfigEntry<bool> m_addLunarsToBottledChaos;

		private static ConfigEntry<string> m_lunarBlacklist;

		private static string[] m_blacklist;

		private void Awake()
		{
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			m_addLunarsToBottledChaos = ((BaseUnityPlugin)this).Config.Bind<bool>("Equip Pool", "Add Lunar Equipment", true, "Adds all lunar equipment to bottled chaos's effect pool.");
			m_lunarBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("Equip Pool", "Blacklist", "BloodOfTheLamb,Tonic,EliteLunarEquipment,LunarPortalOnUse", "Prevent specific lunar equipment from being added to bottled chaos's effect pool. Use equipment name listed by DebugToolkit in single row csv format.");
			m_bottle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("LunarBottledChaos.dll", "lunarbottledchaos"));
			m_bottlePicsOrItDidntHappen = m_bottle.LoadAsset<Sprite>("Bottled_Chaos_Fuck");
			((ResourceAvailability)(ref ItemCatalog.availability)).onAvailable += LunarIt;
			if (RoO.Enabled)
			{
				RoO.AddCheck(m_addLunarsToBottledChaos, requireRestart: true);
				RoO.AddString(m_lunarBlacklist, requireRestart: true);
				ModSettingsManager.SetModIcon(m_bottlePicsOrItDidntHappen);
				ModSettingsManager.SetModDescription("Settings for Lunar Bottled Chaos.");
			}
			if (m_addLunarsToBottledChaos.Value)
			{
				m_blacklist = m_lunarBlacklist.Value.Replace(" ", "").Split(',');
				object obj = <>O.<1>__AddAllLunars;
				if (obj == null)
				{
					hook_RegisterEquipment val = AddAllLunars;
					<>O.<1>__AddAllLunars = val;
					obj = (object)val;
				}
				EquipmentCatalog.RegisterEquipment += (hook_RegisterEquipment)obj;
				LanguageAPI.Add("ITEM_RANDOMEQUIPMENTTRIGGER_PICKUP", "Activating your Equipment triggers an additional, <color=#FF7F7F>random</color> Equipment effect.");
				LanguageAPI.Add("ITEM_RANDOMEQUIPMENTTRIGGER_DESC", "Trigger a <color=#FF7F7F>random</color> <style=cIsDamage>equipment</style> effect <style=cIsDamage>1</style> <style=cStack>(+1 per stack)</style> time(s).");
			}
		}

		private static void AddAllLunars(orig_RegisterEquipment registerEquipment, EquipmentIndex index, EquipmentDef def)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (def.isLunar && !m_blacklist.Contains(((Object)def).name))
			{
				Log.Info("Added " + ((Object)def).name + " to Bottled Chaos effect pool.");
				def.canBeRandomlyTriggered = true;
			}
			registerEquipment.Invoke(index, def);
		}

		private static void LunarIt()
		{
			Items.RandomEquipmentTrigger.tier = (ItemTier)3;
			Items.RandomEquipmentTrigger.pickupIconSprite = m_bottlePicsOrItDidntHappen;
		}
	}
}
namespace HDeMods.LUNAR
{
	internal static class Log
	{
		private static ManualLogSource logMe;

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

		internal static void Debug(object data)
		{
			logMe.LogDebug(data);
		}

		internal static void Error(object data)
		{
			logMe.LogError(data);
		}

		internal static void Fatal(object data)
		{
			logMe.LogFatal(data);
		}

		internal static void Info(object data)
		{
			logMe.LogInfo(data);
		}

		internal static void Message(object data)
		{
			logMe.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			logMe.LogWarning(data);
		}
	}
}
namespace HDeMods.LunarBottleOptionalMods
{
	internal static class RoO
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddCheck(ConfigEntry<bool> option, bool requireRestart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(option, requireRestart), "com.HDeDeDe.LunarBottledChaos", "LunarBottledChaos");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddString(ConfigEntry<string> option, bool requireRestart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(option, requireRestart), "com.HDeDeDe.LunarBottledChaos", "LunarBottledChaos");
		}
	}
}