using System;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[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("Leftovers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Leftovers")]
[assembly: AssemblyTitle("Leftovers")]
[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 = "Leftovers";
public const string PLUGIN_NAME = "Leftovers";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace Leftovers
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ImJustBag.plugin.Leftovers";
public const string PLUGIN_NAME = "Leftovers";
public const string PLUGIN_VERSION = "1.0.2";
}
[BepInPlugin("ImJustBag.plugin.Leftovers", "Leftovers", "1.0.2")]
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 ImJustBag.plugin.Leftovers is loaded!");
Harmony val = new Harmony("ImJustBag.plugin.Leftovers");
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)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)id != 0)
{
return;
}
FieldInfo field = typeof(LootCollection).GetField("_loots", BindingFlags.Instance | BindingFlags.NonPublic);
Plugin.Log.LogInfo((object)$"{field}");
if (!(field != null) || !(field.GetValue(__instance) is List<ILootDef> list))
{
return;
}
List<int> list2 = new List<int>
{
23, 30, 36, 45, 46, 51, 55, 62, 63, 75,
83, 93, 99, 104, 105, 122, 127, 154, 915, 916,
934
};
Random random = new Random();
foreach (int item2 in list2)
{
UpgradeDef item = SoDb2Utils.GetItem<UpgradeDef>(item2);
int index = random.Next(list.Count);
list.Insert(index, (ILootDef)(object)item);
Plugin.Log.LogInfo((object)$"Item {item2} successfully added at random position");
}
field.SetValue(__instance, list);
}
}
}