using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using EntityStates;
using EntityStates.Duplicator;
using EntityStates.Scrapper;
using IL.EntityStates.Scrapper;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Duplicator;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
[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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PrintToInventory")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+09a5226dbd88daacdb812b117b38b6d5d75c5702")]
[assembly: AssemblyProduct("PrintToInventory")]
[assembly: AssemblyTitle("PrintToInventory")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PrintToInventory
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Moffein.PrintToInventory", "PrintToInventory", "1.2.0")]
public class PrintToInventory : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<Instruction, bool> <>9__4_1;
public static Func<Instruction, bool> <>9__4_2;
public static Func<PickupIndex, ScrappingToIdle, PickupIndex> <>9__4_3;
public static Manipulator <>9__4_0;
internal void <Awake>b__4_0(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext(new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(PickupIndex), "none")
});
int index = val.Index;
val.Index = index + 1;
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<PickupIndex, ScrappingToIdle, PickupIndex>>((Func<PickupIndex, ScrappingToIdle, PickupIndex>)delegate(PickupIndex pickupIndex, ScrappingToIdle self)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
if (pickupIndex != PickupIndex.none && Object.op_Implicit((Object)(object)((ScrapperBaseState)self).scrapperController) && Object.op_Implicit((Object)(object)((ScrapperBaseState)self).scrapperController.interactor))
{
CharacterBody component = ((Component)((ScrapperBaseState)self).scrapperController.interactor).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
{
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef != null && (int)pickupDef.itemIndex != -1)
{
component.inventory.GiveItem(pickupDef.itemIndex, ((ScrapperBaseState)self).scrapperController.itemsEaten);
((ScrapperBaseState)self).scrapperController.itemsEaten = 0;
return PickupIndex.none;
}
}
}
return pickupIndex;
});
}
internal bool <Awake>b__4_1(Instruction x)
{
return ILPatternMatchingExt.MatchLdloc(x, 0);
}
internal bool <Awake>b__4_2(Instruction x)
{
return ILPatternMatchingExt.MatchLdsfld(x, typeof(PickupIndex), "none");
}
internal PickupIndex <Awake>b__4_3(PickupIndex pickupIndex, ScrappingToIdle self)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
if (pickupIndex != PickupIndex.none && Object.op_Implicit((Object)(object)((ScrapperBaseState)self).scrapperController) && Object.op_Implicit((Object)(object)((ScrapperBaseState)self).scrapperController.interactor))
{
CharacterBody component = ((Component)((ScrapperBaseState)self).scrapperController.interactor).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
{
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef != null && (int)pickupDef.itemIndex != -1)
{
component.inventory.GiveItem(pickupDef.itemIndex, ((ScrapperBaseState)self).scrapperController.itemsEaten);
((ScrapperBaseState)self).scrapperController.itemsEaten = 0;
return PickupIndex.none;
}
}
}
return pickupIndex;
}
}
public static bool affectScrappers = true;
public static bool affectPrinters = true;
public static bool affectCauldrons = true;
public static bool affectCleanse = true;
public void Awake()
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Expected O, but got Unknown
if (Chainloader.PluginInfos.ContainsKey("com.funkfrog_sipondo.sharesuite"))
{
Debug.LogError((object)"PrintToInventory: ShareSuite detected! PrintToInventory will be disabled due to incompatibilities.");
return;
}
affectCauldrons = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Cauldron", true, "Affect this interactable.").Value;
affectPrinters = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Printer", true, "Affect this interactable.").Value;
affectScrappers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Scrapper", true, "Affect this interactable.").Value;
affectCleanse = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Cleansing Pool", true, "Affect this interactable.").Value;
if (affectPrinters)
{
Duplicating.OnEnter += new hook_OnEnter(Duplicating_OnEnter);
}
if (affectCauldrons || affectCleanse)
{
PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(ImmediatelyGiveItem);
ShopTerminalBehavior.DropPickup += new hook_DropPickup(PreventDrop);
}
if (!affectScrappers)
{
return;
}
object obj = <>c.<>9__4_0;
if (obj == null)
{
Manipulator val = delegate(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
ILCursor val2 = new ILCursor(il);
val2.GotoNext(new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(PickupIndex), "none")
});
int index = val2.Index;
val2.Index = index + 1;
val2.Emit(OpCodes.Ldarg_0);
val2.EmitDelegate<Func<PickupIndex, ScrappingToIdle, PickupIndex>>((Func<PickupIndex, ScrappingToIdle, PickupIndex>)delegate(PickupIndex pickupIndex, ScrappingToIdle self)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
if (pickupIndex != PickupIndex.none && Object.op_Implicit((Object)(object)((ScrapperBaseState)self).scrapperController) && Object.op_Implicit((Object)(object)((ScrapperBaseState)self).scrapperController.interactor))
{
CharacterBody component = ((Component)((ScrapperBaseState)self).scrapperController.interactor).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
{
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef != null && (int)pickupDef.itemIndex != -1)
{
component.inventory.GiveItem(pickupDef.itemIndex, ((ScrapperBaseState)self).scrapperController.itemsEaten);
((ScrapperBaseState)self).scrapperController.itemsEaten = 0;
return PickupIndex.none;
}
}
}
return pickupIndex;
});
};
<>c.<>9__4_0 = val;
obj = (object)val;
}
ScrappingToIdle.OnEnter += (Manipulator)obj;
}
private void Duplicating_OnEnter(orig_OnEnter orig, Duplicating self)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Invalid comparison between Unknown and I4
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (!NetworkServer.active)
{
return;
}
PurchaseInteraction component = ((EntityState)self).GetComponent<PurchaseInteraction>();
ShopTerminalBehavior component2 = ((EntityState)self).GetComponent<ShopTerminalBehavior>();
if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2))
{
return;
}
CharacterBody component3 = ((Component)component.lastActivator).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component3.inventory))
{
PickupDef pickupDef = PickupCatalog.GetPickupDef(component2.pickupIndex);
if (pickupDef != null && (int)pickupDef.itemIndex != -1)
{
component3.inventory.GiveItem(pickupDef.itemIndex, 1);
component2.SetHasBeenPurchased(true);
self.hasDroppedDroplet = true;
self.hasStartedCooking = true;
}
}
}
private void ImmediatelyGiveItem(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Invalid comparison between Unknown and I4
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Invalid comparison between Unknown and I4
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, activator);
PurchaseInteraction component = ((Component)self).GetComponent<PurchaseInteraction>();
if (!Object.op_Implicit((Object)(object)component))
{
return;
}
bool flag = affectCauldrons && component.displayNameToken == "BAZAAR_CAULDRON_NAME";
bool flag2 = affectCleanse && component.displayNameToken == "SHRINE_CLEANSE_NAME";
if (!(flag || flag2))
{
return;
}
CharacterBody component2 = ((Component)activator).GetComponent<CharacterBody>();
ShopTerminalBehavior component3 = ((Component)self).GetComponent<ShopTerminalBehavior>();
if (!Object.op_Implicit((Object)(object)component2) || !Object.op_Implicit((Object)(object)component2.inventory) || !Object.op_Implicit((Object)(object)component3))
{
return;
}
PickupDef pickupDef = PickupCatalog.GetPickupDef(component3.pickupIndex);
if (pickupDef != null && (int)pickupDef.itemIndex != -1)
{
int num = 1;
if (flag && component.cost == 1 && (int)component.costType == 6)
{
num = 3;
}
component2.inventory.GiveItem(pickupDef.itemIndex, num);
component3.SetHasBeenPurchased(true);
component.lastActivator = null;
}
}
private void PreventDrop(orig_DropPickup orig, ShopTerminalBehavior self)
{
if (NetworkServer.active)
{
PurchaseInteraction component = ((Component)self).GetComponent<PurchaseInteraction>();
if (Object.op_Implicit((Object)(object)component))
{
bool flag = affectCauldrons && component.displayNameToken == "BAZAAR_CAULDRON_NAME";
bool flag2 = affectCleanse && component.displayNameToken == "SHRINE_CLEANSE_NAME";
if ((flag || flag2) && (Object)(object)component.lastActivator == (Object)null)
{
return;
}
}
}
orig.Invoke(self);
}
}
}
namespace R2API.Utils
{
[AttributeUsage(AttributeTargets.Assembly)]
public class ManualNetworkRegistrationAttribute : Attribute
{
}
}