Decompiled source of EveryItemIsX v1.2.3

BepInEx/plugins/pauli-EveryItemIsX/EveryItemIsX.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Atomicrops.Core.Loot;
using Atomicrops.Core.SoDb2;
using Atomicrops.Core.Upgrades;
using Atomicrops.Game.Data;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SharedLib;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("EveryItemIsX")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EveryItemIsX")]
[assembly: AssemblyTitle("EveryItemIsX")]
[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 Template
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EveryItemIsX";

		public const string PLUGIN_NAME = "EveryItemIsX";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace EveryItemIsX
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "pauli.plugin.EveryItemIsX";

		public const string PLUGIN_NAME = "EveryItemIsX";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("pauli.plugin.EveryItemIsX", "EveryItemIsX", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin pauli.plugin.EveryItemIsX is loaded!");
			Harmony val = new Harmony("pauli.plugin.EveryItemIsX");
			val.PatchAll();
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(new Type[]
	{
		typeof(LootCollectionDef),
		typeof(LootCollectionIdsEnum),
		typeof(int),
		typeof(bool),
		typeof(bool),
		typeof(bool)
	})]
	internal class LootCollection_Constructor_Patch
	{
		private static void Postfix(LootCollection __instance, LootCollectionDef collectionDef, LootCollectionIdsEnum id, int seed, bool doDlcCheck, bool isCrow, bool isClassic)
		{
			List<string> list = new List<string> { "CrowCropLeveling", "DeerShop", "PowerSow", "GardenBed" };
			if (list.Contains(((object)(LootCollectionIdsEnum)(ref id)).ToString()))
			{
				return;
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "chosen_item.txt");
			if (File.Exists(text))
			{
				if (int.TryParse(File.ReadAllText(text), out var result))
				{
					FieldInfo field = typeof(LootCollection).GetField("_loots", BindingFlags.Instance | BindingFlags.NonPublic);
					Plugin.Log.LogInfo((object)$"{field}");
					if (field != null && field.GetValue(__instance) is List<ILootDef> list2)
					{
						list2.Clear();
						for (int i = 0; i < 300; i++)
						{
							UpgradeDef item = SoDb2Utils.GetItem<UpgradeDef>(result);
							list2.Add((ILootDef)(object)item);
						}
						Plugin.Log.LogInfo((object)"500 instances of chosen item successfully added");
						field.SetValue(__instance, list2);
					}
				}
				else
				{
					Plugin.Log.LogError((object)("Failed to parse item ID from file at " + text));
				}
			}
			else
			{
				Plugin.Log.LogError((object)("File does not exist at " + text));
			}
		}
	}
	[HarmonyPatch(typeof(TallySeasonTurnInInteractable), "_getSpecialLoot")]
	internal class GetSpecialLoot_Patch
	{
		private static bool Prefix(ref ILootDef __result)
		{
			__result = SingletonScriptableObject<GameData>.I.SpecialLootCollection.CheckOutNoRepeats(1, (Rarity_)15, (Rarity_)0, false, (Func<ILootDef, bool>)null, false)[0];
			return false;
		}
	}
}