Decompiled source of DontCareAboutLunarCoins v1.0.4

DontCareAboutLunarCoins.dll

Decompiled a day 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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
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: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NewMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0e7eef2ea4f70bbe14a14f1ed72b02ee491e3eb7")]
[assembly: AssemblyProduct("NewMod")]
[assembly: AssemblyTitle("NewMod")]
[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 NewMod
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("NewMod");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "NewMod".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogDebug((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Debug_NoCallerPrefix(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("com.themysticsword.dontcareaboutlunarcoins", "Don't Care About Lunar Coins", "1.0.4")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "com.themysticsword.dontcareaboutlunarcoins";

		public const string PluginName = "Don't Care About Lunar Coins";

		public const string PluginVersion = "1.0.4";

		public ConfigEntry<int> setLunarCoins;

		public ConfigEntry<bool> noLunarCoinDeduction;

		public ConfigEntry<bool> lunarCommandEssences;

		public void Awake()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			setLunarCoins = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Set Lunar Coins To", int.MaxValue, "Sets your Lunar Coins to this value at the start of a run. If -1, Lunar Coins don't get changed");
			noLunarCoinDeduction = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "No Lunar Coin Deduction", true, "Prevents Lunar Coin purchases from reducing your coin count");
			lunarCommandEssences = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Lunar Command Essences", true, "Turns all Lunar item drops into Blue Command Essences, allowing you to choose your Lunar item");
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				SetUpRiskOfOptionsSupport();
			}
			Run.onRunStartGlobal += Run_onRunStartGlobal;
			NetworkUser.DeductLunarCoins += new hook_DeductLunarCoins(NetworkUser_DeductLunarCoins);
			PickupDropletController.CreatePickup += new hook_CreatePickup(PickupDropletController_CreatePickup);
		}

		private void Run_onRunStartGlobal(Run obj)
		{
			if (!NetworkServer.active || setLunarCoins.Value == -1)
			{
				return;
			}
			foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
			{
				uint num = (readOnlyInstances.NetworknetLunarCoins = (uint)setLunarCoins.Value);
				uint coins = num;
				if (readOnlyInstances.localUser != null)
				{
					readOnlyInstances.localUser.userProfile.coins = coins;
				}
			}
		}

		private void NetworkUser_DeductLunarCoins(orig_DeductLunarCoins orig, NetworkUser self, uint count)
		{
			if (noLunarCoinDeduction.Value)
			{
				count = 0u;
			}
			orig.Invoke(self, count);
		}

		private void PickupDropletController_CreatePickup(orig_CreatePickup orig, PickupDropletController self)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			if (lunarCommandEssences.Value)
			{
				PickupIndex pickupIndex = ((CreatePickupInfo)(ref self.createPickupInfo)).pickupIndex;
				PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
				if (pickupDef != null && ((int)pickupDef.itemIndex != -1 || (int)pickupDef.equipmentIndex != -1 || (int)pickupDef.itemTier != 5) && pickupDef.isLunar)
				{
					GameObject val = Object.Instantiate<GameObject>(CommandArtifactManager.commandCubePrefab, self.createPickupInfo.position, self.createPickupInfo.rotation);
					val.GetComponent<PickupIndexNetworker>().pickupIndex = pickupIndex;
					PickupPickerController component = val.GetComponent<PickupPickerController>();
					component.SetOptionsFromPickupForCommandArtifact(pickupIndex);
					component.chestGeneratedFrom = self.createPickupInfo.chest;
					NetworkServer.Spawn(val);
					return;
				}
			}
			orig.Invoke(self);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void SetUpRiskOfOptionsSupport()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_009b: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("");
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "icon.png")));
			Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), 100f);
			ModSettingsManager.SetModIcon(modIcon);
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(setLunarCoins, new IntSliderConfig
			{
				min = -1,
				max = int.MaxValue
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(noLunarCoinDeduction));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(lunarCommandEssences));
		}
	}
}