using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 RemoveVanillaArrowDrops
{
[BepInPlugin("johbenji.removevanillaarrowdrops", "Remove Vanilla Arrow Drops", "1.0.0")]
public class RemoveVanillaArrowDropsPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("johbenji.removevanillaarrowdrops").PatchAll();
Log.LogInfo((object)"RemoveVanillaArrowDrops loaded.");
}
}
[HarmonyPatch(typeof(SelfFilledItemContainer), "GenerateContents")]
public static class RemoveVanillaArrowsFromContainersPatch
{
private static readonly HashSet<int> BlockedItemIDs = new HashSet<int> { 5200002, 5200003, 5200004, 5200005, 5200007, 5200008, 5200009, 5200010, 5200019 };
private static readonly FieldRef<SelfFilledItemContainer, List<Dropable>> DropsRef = AccessTools.FieldRefAccess<SelfFilledItemContainer, List<Dropable>>("m_drops");
private static readonly FieldRef<Dropable, List<DropTable>> MainDropTablesRef = AccessTools.FieldRefAccess<Dropable, List<DropTable>>("m_mainDropTables");
private static readonly HashSet<DropTable> _processed = new HashSet<DropTable>();
private static readonly FieldRef<DropTable, List<ItemDropChance>> ItemDropsRef = AccessTools.FieldRefAccess<DropTable, List<ItemDropChance>>("m_itemDrops");
private static void Prefix(SelfFilledItemContainer __instance)
{
List<Dropable> list = DropsRef.Invoke(__instance);
if (list == null)
{
return;
}
foreach (Dropable item in list)
{
if ((Object)(object)item == (Object)null)
{
continue;
}
List<DropTable> list2 = MainDropTablesRef.Invoke(item);
if (list2 == null)
{
continue;
}
foreach (DropTable item2 in list2)
{
if (!((Object)(object)item2 == (Object)null) && _processed.Add(item2))
{
StripArrows(item2);
}
}
}
}
private static void StripArrows(DropTable table)
{
List<ItemDropChance> list = ItemDropsRef.Invoke(table);
if (list != null && list.Count != 0)
{
list.RemoveAll((ItemDropChance d) => d != null && BlockedItemIDs.Contains(((BasicItemDrop)d).ItemID));
}
}
}
}