using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using UnityEngine;
[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 = "")]
[assembly: AssemblyCompany("CommandDropletFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CommandDropletFix")]
[assembly: AssemblyTitle("CommandDropletFix")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TPDespair.CommandDropletFix;
[BepInPlugin("com.TPDespair.CommandDropletFix", "CommandDropletFix", "1.0.2")]
public class CommandDropletFixPlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <>c__DisplayClass11_0
{
public MethodInfo methodInfo;
internal bool <CommandDropletFix>b__1(Instruction x)
{
return ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)methodInfo);
}
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<Instruction, bool> <>9__11_2;
public static Func<Instruction, bool> <>9__11_3;
public static Func<PickupDef, PickupDef> <>9__11_4;
public static Manipulator <>9__11_0;
internal void <CommandDropletFix>b__11_0(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
<>c__DisplayClass11_0 CS$<>8__locals0 = new <>c__DisplayClass11_0();
ILCursor val = new ILCursor(il);
CS$<>8__locals0.methodInfo = typeof(PickupCatalog).GetMethod("GetPickupDef");
int num2 = default(int);
int num = default(int);
if (val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)CS$<>8__locals0.methodInfo),
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num)
}))
{
val.Index += 3;
val.EmitDelegate<Func<PickupDef, PickupDef>>((Func<PickupDef, PickupDef>)delegate(PickupDef pickupDef)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (ZetAspects && !AspectsResolved)
{
ResolveAspects();
}
if ((int)pickupDef.itemIndex != -1 && (!ZetAspects || !AspectCommandGroupItems || !aspectItemIndexes.Contains(pickupDef.itemIndex)))
{
ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
if (itemDef.ContainsTag((ItemTag)9))
{
return null;
}
}
if ((int)pickupDef.equipmentIndex != -1 && (!ZetAspects || !AspectCommandGroupEquip || !aspectEquipIndexes.Contains(pickupDef.equipmentIndex)))
{
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
if (!equipmentDef.canDrop)
{
return null;
}
}
return pickupDef;
});
}
else
{
Debug.LogWarning((object)"CommandDropletFix Failed!");
}
}
internal bool <CommandDropletFix>b__11_2(Instruction x)
{
int num = default(int);
return ILPatternMatchingExt.MatchStloc(x, ref num);
}
internal bool <CommandDropletFix>b__11_3(Instruction x)
{
int num = default(int);
return ILPatternMatchingExt.MatchLdloc(x, ref num);
}
internal PickupDef <CommandDropletFix>b__11_4(PickupDef pickupDef)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (ZetAspects && !AspectsResolved)
{
ResolveAspects();
}
if ((int)pickupDef.itemIndex != -1 && (!ZetAspects || !AspectCommandGroupItems || !aspectItemIndexes.Contains(pickupDef.itemIndex)))
{
ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
if (itemDef.ContainsTag((ItemTag)9))
{
return null;
}
}
if ((int)pickupDef.equipmentIndex != -1 && (!ZetAspects || !AspectCommandGroupEquip || !aspectEquipIndexes.Contains(pickupDef.equipmentIndex)))
{
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
if (!equipmentDef.canDrop)
{
return null;
}
}
return pickupDef;
}
}
public const string ModVer = "1.0.2";
public const string ModName = "CommandDropletFix";
public const string ModGuid = "com.TPDespair.CommandDropletFix";
public static bool ZetAspects = false;
internal static bool AspectsResolved = false;
internal static bool AspectCommandGroupItems = false;
internal static bool AspectCommandGroupEquip = false;
internal static List<ItemIndex> aspectItemIndexes = new List<ItemIndex>();
internal static List<EquipmentIndex> aspectEquipIndexes = new List<EquipmentIndex>();
public void Awake()
{
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(LateSetup));
}
public void LateSetup()
{
if (Chainloader.PluginInfos.ContainsKey("com.TPDespair.ZetAspects"))
{
ZetAspects = true;
}
CommandDropletFix();
}
private static void CommandDropletFix()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
object obj = <>c.<>9__11_0;
if (obj == null)
{
Manipulator val = delegate(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
ILCursor val2 = new ILCursor(il);
MethodInfo methodInfo = typeof(PickupCatalog).GetMethod("GetPickupDef");
int num2 = default(int);
int num = default(int);
if (val2.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)methodInfo),
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num)
}))
{
val2.Index += 3;
val2.EmitDelegate<Func<PickupDef, PickupDef>>((Func<PickupDef, PickupDef>)delegate(PickupDef pickupDef)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (ZetAspects && !AspectsResolved)
{
ResolveAspects();
}
if ((int)pickupDef.itemIndex != -1 && (!ZetAspects || !AspectCommandGroupItems || !aspectItemIndexes.Contains(pickupDef.itemIndex)))
{
ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
if (itemDef.ContainsTag((ItemTag)9))
{
return null;
}
}
if ((int)pickupDef.equipmentIndex != -1 && (!ZetAspects || !AspectCommandGroupEquip || !aspectEquipIndexes.Contains(pickupDef.equipmentIndex)))
{
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
if (!equipmentDef.canDrop)
{
return null;
}
}
return pickupDef;
});
}
else
{
Debug.LogWarning((object)"CommandDropletFix Failed!");
}
};
<>c.<>9__11_0 = val;
obj = (object)val;
}
PickupDropletController.CreatePickup += (Manipulator)obj;
}
private static void ResolveAspects()
{
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
BaseUnityPlugin instance = Chainloader.PluginInfos["com.TPDespair.ZetAspects"].Instance;
Assembly assembly = Assembly.GetAssembly(((object)instance).GetType());
Type type = Type.GetType("TPDespair.ZetAspects.Configuration, " + assembly.FullName, throwOnError: false);
if (type != null)
{
MethodInfo method = type.GetMethod("get_AspectCommandGroupItems", bindingAttr);
if (method != null)
{
try
{
ConfigEntry<bool> val = (ConfigEntry<bool>)method.Invoke(null, null);
AspectCommandGroupItems = val.Value;
}
catch (Exception ex)
{
Debug.LogError((object)ex);
}
}
else
{
Debug.LogWarning((object)"[CommandDropletFix - ResolveAspects] - Could Not Find Method : Configuration.get_AspectCommandGroupItems");
}
method = type.GetMethod("get_AspectCommandGroupEquip", bindingAttr);
if (method != null)
{
try
{
ConfigEntry<bool> val2 = (ConfigEntry<bool>)method.Invoke(null, null);
AspectCommandGroupEquip = val2.Value;
}
catch (Exception ex2)
{
Debug.LogError((object)ex2);
}
}
else
{
Debug.LogWarning((object)"[CommandDropletFix - ResolveAspects] - Could Not Find Method : Configuration.get_AspectCommandGroupEquip");
}
}
else
{
Debug.LogWarning((object)"[CommandDropletFix - ResolveAspects] Could Not Find Type : TPDespair.ZetAspects.Configuration");
}
if (AspectCommandGroupItems || AspectCommandGroupEquip)
{
type = Type.GetType("TPDespair.ZetAspects.Catalog, " + assembly.FullName, throwOnError: false);
if (type != null)
{
if (AspectCommandGroupItems)
{
FieldInfo field = type.GetField("aspectItemIndexes", bindingAttr);
if (field != null)
{
try
{
aspectItemIndexes = (List<ItemIndex>)field.GetValue(null);
}
catch (Exception ex3)
{
Debug.LogError((object)ex3);
}
}
else
{
Debug.LogWarning((object)"[CommandDropletFix - ResolveAspects] - Could Not Find Field : Catalog.aspectItemIndexes");
}
}
if (AspectCommandGroupEquip)
{
FieldInfo field2 = type.GetField("aspectEquipIndexes", bindingAttr);
if (field2 != null)
{
try
{
aspectEquipIndexes = (List<EquipmentIndex>)field2.GetValue(null);
}
catch (Exception ex4)
{
Debug.LogError((object)ex4);
}
}
else
{
Debug.LogWarning((object)"[CommandDropletFix - ResolveAspects] - Could Not Find Field : Catalog.aspectEquipIndexes");
}
}
}
else
{
Debug.LogWarning((object)"[CommandDropletFix - ResolveAspects] Could Not Find Type : TPDespair.ZetAspects.Catalog");
}
}
AspectsResolved = true;
}
}