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 RemoveVanillaFragmentBombDrops
{
[BepInPlugin("johbenji.removevanillafragmentbombdrops", "Remove Vanilla Fragment Bomb Drops", "1.0.0")]
public class RemoveVanillaFragmentBombDropsPlugin : 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.removevanillafragmentbombdrops").PatchAll();
Log.LogInfo((object)"RemoveVanillaFragmentBombDrops loaded.");
}
}
[HarmonyPatch(typeof(SelfFilledItemContainer), "GenerateContents")]
public static class RemoveVanillaBombsFromContainersPatch
{
private static readonly HashSet<int> BlockedItemIDs = new HashSet<int> { 4600010, 4600020, 4600030, 4600040, 4600050, 4600060, 4600070, 4600080 };
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 FieldRef<DropTable, List<ItemDropChance>> ItemDropsRef = AccessTools.FieldRefAccess<DropTable, List<ItemDropChance>>("m_itemDrops");
private static readonly HashSet<DropTable> _processed = new HashSet<DropTable>();
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))
{
StripBombs(item2);
}
}
}
}
private static void StripBombs(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));
}
}
}
}