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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[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("BetterDynamicScrapsAmount")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("BetterDynamicScrapsAmount")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterDynamicScrapsAmount")]
[assembly: AssemblyTitle("BetterDynamicScrapsAmount")]
[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 DynamicScrapsAmount
{
internal class DynamicScrapsConfig
{
public static ConfigEntry<int> RequiredMinimumQuota;
public static ConfigEntry<int> QuotaInterval;
public static ConfigEntry<int> MaxScrapsAdded;
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)");
ModManager.Instance.BindConfig(ref MaxScrapsAdded, "Settings", "Max Scraps Added", 10, "Maximum amount of scraps that can be added to the dungeon.");
}
}
[BepInPlugin("Aliaks.BetterDynamicScrapsAmount", "BetterDynamicScrapsAmount", "1.0.0")]
public class ModManager : BaseUnityPlugin
{
private const string modGUID = "Aliaks.BetterDynamicScrapsAmount";
private const string modName = "BetterDynamicScrapsAmount";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Aliaks.BetterDynamicScrapsAmount");
public static ModManager Instance;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if ((Object)Instance == (Object)null)
{
Instance = this;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Aliaks.BetterDynamicScrapsAmount: 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;
int value3 = DynamicScrapsConfig.MaxScrapsAdded.Value;
if (profitQuota > value)
{
int num = Mathf.CeilToInt((float)((profitQuota - value) / value2));
num = Mathf.Min(num, value3);
SelectableLevel val = ___currentLevel;
val.minScrap += num;
SelectableLevel val2 = ___currentLevel;
val2.maxScrap += num;
}
}
}
}