Decompiled source of MoreResources v1.0.0

BepInEx/plugins/MoreResources.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Numerics;
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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MoreResources")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Increase minerals dropped")]
[assembly: AssemblyTitle("MoreResources")]
[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 MoreResources
{
	[BepInPlugin("MoreResources", "Increase minerals dropped", "1.0.0")]
	public class Plugin : BasePlugin
	{
		private static ConfigEntry<float> _multiplierGold;

		private static ConfigEntry<float> _multiplierNitra;

		private static ConfigEntry<float> _multiplierRedSugar;

		private static ConfigEntry<float> _multiplierCredits;

		private static ConfigEntry<float> _multiplierRankXP;

		private static ConfigEntry<float> _multiplierRunXP;

		private static ConfigEntry<float> _multiplierBismor;

		private static ConfigEntry<float> _multiplierCroppa;

		private static ConfigEntry<float> _multiplierEnorPearls;

		private static ConfigEntry<float> _multiplierJadiz;

		private static ConfigEntry<float> _multiplierMagnite;

		private static ConfigEntry<float> _multiplierUmanite;

		private static ConfigEntry<float> _multiplierMorkite;

		private static readonly Random Random = new Random();

		private static ManualLogSource Log;

		public override void Load()
		{
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Expected O, but got Unknown
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			_multiplierGold = ((BasePlugin)this).Config.Bind<float>("In-run resources", "Gold", 1f, "Multiplier for gold. Used to buy things during the run.");
			_multiplierNitra = ((BasePlugin)this).Config.Bind<float>("In-run resources", "Nitra", 1f, "Multiplier for nitra. Used to buy things during the run.");
			_multiplierRedSugar = ((BasePlugin)this).Config.Bind<float>("In-run resources", "Red sugar", 1f, "Multiplier for red sugar. Used to heal during the run.");
			_multiplierRunXP = ((BasePlugin)this).Config.Bind<float>("In-run resources", "Run XP", 1f, "Multiplier for XP gained during a run. Gives access to meta-upgrades that only last for that run.");
			_multiplierCredits = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Credits", 2f, "Multiplier for credits. Used to upgrade things between runs. Note that this is based on the resources earned during a run, so if you're increasing those, you will already have an increase to credits.");
			_multiplierRankXP = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Rank XP", 2f, "Multiplier for rank XP. Levels up your character between runs. Note that this is based on the resources earned during a run, so if you're increasing those, you will already have an increase to rank XP.");
			_multiplierBismor = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Bismor", 2f, "Multiplier for Bismor, the yellow+red mineral. Used to upgrade things between runs.");
			_multiplierCroppa = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Croppa", 2f, "Multiplier for Croppa, the purple+teal mineral. Used to upgrade things between runs.");
			_multiplierEnorPearls = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Enor pearls", 2f, "Multiplier for Enor pearls, the white mineral. Used to upgrade things between runs.");
			_multiplierJadiz = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Jadiz", 2f, "Multiplier for Jadiz, the green mineral. Used to upgrade things between runs.");
			_multiplierMagnite = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Magnite", 2f, "Multiplier for Magnite, the red+gray mineral. Used to upgrade things between runs.");
			_multiplierUmanite = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Umanite", 2f, "Multiplier for Umanite, the green+yellow mineral. Used to upgrade things between runs.");
			_multiplierMorkite = ((BasePlugin)this).Config.Bind<float>("Post-run resources", "Morkite", 2f, "Multiplier for Morkite, the blue mineral that can only be found in masteries and anomaly dives. Used to upgrade things between runs.");
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MoreResources");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
		}

		[HarmonyPatch(typeof(PickupSpawner), "SpawnMaterial")]
		[HarmonyPrefix]
		private static void SpawnMaterialPrefix(PickupSpawner __instance, ref ECurrency material, ref int count, ref Vector3 position, ref float forceMod)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected I4, but got Unknown
			ECurrency val = material;
			float num = (int)val switch
			{
				0 => _multiplierGold.Value, 
				2 => _multiplierNitra.Value, 
				3 => _multiplierRedSugar.Value, 
				10 => _multiplierBismor.Value, 
				11 => _multiplierCroppa.Value, 
				12 => _multiplierEnorPearls.Value, 
				13 => _multiplierJadiz.Value, 
				14 => _multiplierMagnite.Value, 
				15 => _multiplierUmanite.Value, 
				1 => _multiplierMorkite.Value, 
				_ => 1f, 
			};
			count = RoundRandomly((float)count * num);
		}

		[HarmonyPatch(typeof(PickupSpawner), "SpawnXP")]
		[HarmonyPrefix]
		private static void SpawnXpPrefix(PickupSpawner __instance, ref int amount)
		{
			amount = RoundRandomly((float)amount * _multiplierRunXP.Value);
		}

		[HarmonyPatch(typeof(Economy), "CalculateCreditsEarned")]
		[HarmonyPostfix]
		private static void CalculateCreditsEarnedPostfix(ref int __result)
		{
			__result = RoundRandomly((float)__result * _multiplierCredits.Value);
		}

		[HarmonyPatch(typeof(Economy), "CalculateRankXpEarned")]
		[HarmonyPostfix]
		private static void CalculateRankXpEarnedPostfix(ref int __result)
		{
			__result = RoundRandomly((float)__result * _multiplierRankXP.Value);
		}

		private static int RoundRandomly(float roundMe)
		{
			int num = (int)Math.Floor(roundMe);
			float num2 = roundMe - (float)num;
			if (!(num2 > 0f) || !((double)num2 > Random.NextDouble()))
			{
				return num;
			}
			return num + 1;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MoreResources";

		public const string PLUGIN_NAME = "Increase minerals dropped";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}