Decompiled source of DuckLoot v1.0.22

DuckLoot.dll

Decompiled a month ago
using System.Collections.Generic;
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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DuckLoot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DuckLoot")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6145c54b-df4d-44b5-9677-31bd959c819a")]
[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 DuckLoot;

[BepInPlugin("LuckyLeaf333.DuckLoot", "DuckLoot", "1.0.22")]
public class DuckLootMod : BaseUnityPlugin
{
	public const string modGUID = "LuckyLeaf333.DuckLoot";

	public const string modName = "DuckLoot";

	public const string modVersion = "1.0.22";

	internal static ManualLogSource Logger;

	private readonly Harmony harmony = new Harmony("LuckyLeaf333.DuckLoot");

	public static ConfigEntry<float> configMultiplier;

	private void Awake()
	{
		configMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Duck Spawn Modification", "DuckSpawnMultiplier", 1f, "Multiplies the amount of ducks by the given multiplier.");
		Logger = ((BaseUnityPlugin)this).Logger;
		Logger.LogInfo((object)"Plugin LuckyLeaf333.DuckLoot is loaded!");
		harmony.PatchAll(typeof(StartOfRoundPatch));
		harmony.PatchAll(typeof(RoundManagerPatch));
	}
}
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyPatch("StartGame")]
internal class StartOfRoundPatch
{
	private static SpawnableItemWithRarity duckItem;

	[HarmonyPrefix]
	private static void Prefix(ref SelectableLevel[] ___levels)
	{
		if (duckItem == null)
		{
			DuckLootMod.Logger.LogDebug((object)"Attempting to grab duck item info");
			SelectableLevel[] array = ___levels;
			foreach (SelectableLevel val in array)
			{
				if (!(val.PlanetName == "56 Vow"))
				{
					continue;
				}
				foreach (SpawnableItemWithRarity item in val.spawnableScrap)
				{
					if (item.spawnableItem.itemName == "Rubber Ducky")
					{
						duckItem = item;
						break;
					}
				}
				break;
			}
			if (duckItem == null)
			{
				DuckLootMod.Logger.LogDebug((object)"Error: Duck item info not found");
			}
			else
			{
				DuckLootMod.Logger.LogDebug((object)"Success: Duck item info found");
			}
			DuckLootMod.Logger.LogDebug((object)"Attempting to set spawnableScrap to only rubber duckies for all levels");
			if (duckItem != null)
			{
				List<SpawnableItemWithRarity> list = new List<SpawnableItemWithRarity>();
				list.Add(duckItem);
				SelectableLevel[] array2 = ___levels;
				foreach (SelectableLevel val2 in array2)
				{
					DuckLootMod.Logger.LogDebug((object)("Attempting to set " + val2.PlanetName + " spawnableScrap to ducks only"));
					val2.spawnableScrap = list;
					DuckLootMod.Logger.LogDebug((object)$"Length of {val2.PlanetName} spawnableScrap is now {val2.spawnableScrap.Count}");
				}
				DuckLootMod.Logger.LogDebug((object)"Success: All levels' spawnable scrap set to duck");
			}
			else
			{
				DuckLootMod.Logger.LogDebug((object)"Error: Duck info is null");
			}
		}
		else
		{
			DuckLootMod.Logger.LogDebug((object)"StartOfRoundPatch skipped: duck item info already found");
		}
	}
}
[HarmonyPatch(typeof(RoundManager))]
[HarmonyPatch("SpawnScrapInLevel")]
internal class RoundManagerPatch
{
	[HarmonyPrefix]
	private static void Prefix(ref float ___scrapAmountMultiplier)
	{
		DuckLootMod.Logger.LogDebug((object)"Attempting to set scrapAmountMultiplier");
		___scrapAmountMultiplier = DuckLootMod.configMultiplier.Value;
		DuckLootMod.Logger.LogDebug((object)$"scrapAmountMultiplier set to {___scrapAmountMultiplier}");
	}
}