Decompiled source of GoldOnlyMod v1.0.5

ArrFel_OnlyGoldMod.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ArrFel_OnlyGoldMod.Patches;
using BepInEx;
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("ArFe_ChaosMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ArFe_ChaosMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cb8da1ea-d570-4b5e-b73f-9d0be8bd2ab0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ArrFel_OnlyGoldMod
{
	[BepInPlugin("ArrFel.OnlyGoldMod", "Only Gold Mod", "1.0.5")]
	public class Main : BaseUnityPlugin
	{
		public const string modGUID = "ArrFel.OnlyGoldMod";

		public const string modNAME = "Only Gold Mod";

		public const string modVER = "1.0.5";

		public const string modBY = "Mewings da Galaxia";

		private readonly Harmony harmony = new Harmony("ArrFel.OnlyGoldMod");

		internal ManualLogSource mls;

		public static Main inst;

		public SpawnableItemWithRarity goldBar = new SpawnableItemWithRarity();

		public bool hanstCreatedGold = true;

		private void Awake()
		{
			if ((Object)(object)inst == (Object)null)
			{
				inst = this;
			}
			else if ((Object)(object)inst != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
			}
			mls = Logger.CreateLogSource("ArrFel.OnlyGoldMod");
			mls.LogInfo((object)"Only Gold Mod has Awoken");
			mls.LogInfo((object)"Patching Scripts...");
			harmony.PatchAll(typeof(Main));
			harmony.PatchAll(typeof(RoundManagerPatches));
			mls.LogInfo((object)"Patched Scripts.");
		}
	}
}
namespace ArrFel_OnlyGoldMod.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatches
	{
		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPrefix]
		public static void Update_PreLoadNewLevel(ref int randomSeed, ref SelectableLevel newLevel)
		{
			bool flag = true;
			foreach (SpawnableItemWithRarity item in newLevel.spawnableScrap)
			{
				item.rarity = 0;
				if (item.spawnableItem.itemName == "Gold bar")
				{
					flag = false;
					item.rarity = 200;
				}
			}
			if (!flag)
			{
				return;
			}
			if (Main.inst.hanstCreatedGold)
			{
				foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
				{
					if (items.itemName == "Gold bar")
					{
						Main.inst.goldBar.rarity = 200;
						Main.inst.goldBar.spawnableItem = items;
						Main.inst.hanstCreatedGold = false;
					}
				}
			}
			newLevel.spawnableScrap.Add(Main.inst.goldBar);
		}
	}
}