Decompiled source of DynamicScrapsAmount v1.0.4

BepInEx/plugins/DynamicScrapsAmount.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DynamicScrapsAmount")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DynamicScrapsAmount")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3b24fd98-00c9-4e13-badc-8a703e51cc65")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DynamicScrapsAmount;

internal class DynamicScrapsConfig
{
	public static ConfigEntry<int> RequiredMinimumQuota;

	public static ConfigEntry<int> QuotaInterval;

	public static void InitConfig()
	{
		ModManager.Instance.BindConfig(ref RequiredMinimumQuota, "Settings", "Required Minimum Quota", 1000, "Additional scraps will be added to the dungeon when profit quota has reached this value.");
		ModManager.Instance.BindConfig(ref QuotaInterval, "Settings", "Quota Interval", 100, "One additional scrap will be added to the dungeon based on the given interval, only after required minimum quota has been met.\n(So if your profit quota is at 1500 and your required minimum quota is 1000 with a 100 quota interval, 5 additional scraps will spawn in the dungeon)");
	}
}
[BepInPlugin("zMods.DynamicScrapsAmount", "DynamicScrapsAmount", "1.0.4")]
public class ModManager : BaseUnityPlugin
{
	private const string modGUID = "zMods.DynamicScrapsAmount";

	private const string modName = "DynamicScrapsAmount";

	private const string modVersion = "1.0.4";

	private readonly Harmony harmony = new Harmony("zMods.DynamicScrapsAmount");

	public static ModManager Instance;

	internal ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("zMods.DynamicScrapsAmount");
		mls.LogInfo((object)"zMods.DynamicScrapsAmount: Awake()");
		harmony.PatchAll(typeof(ModManager));
		harmony.PatchAll(typeof(SpawnScrapsInLevel));
		DynamicScrapsConfig.InitConfig();
	}

	public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "")
	{
		config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
	}
}
[HarmonyPatch(typeof(RoundManager))]
internal class SpawnScrapsInLevel
{
	[HarmonyPatch("SpawnScrapInLevel")]
	[HarmonyPrefix]
	private static void IncreasedScrapsFromQuota(ref SelectableLevel ___currentLevel)
	{
		int value = DynamicScrapsConfig.RequiredMinimumQuota.Value;
		int value2 = DynamicScrapsConfig.QuotaInterval.Value;
		int profitQuota = TimeOfDay.Instance.profitQuota;
		if (profitQuota > value)
		{
			int num = Mathf.CeilToInt((float)((profitQuota - value) / value2));
			SelectableLevel obj = ___currentLevel;
			obj.minScrap += num;
			SelectableLevel obj2 = ___currentLevel;
			obj2.maxScrap += num;
		}
	}
}