Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BetterDropItem v3.0.0
BetterDropItem.dll
Decompiled 2 days agousing 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 BepInEx.Configuration; using BepInEx.Logging; using IL.RoR2; using IL.RoR2.UI; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using R2API; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BetterDropItem")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+117c2a06abc000520ddd36b376efec8d0036e835")] [assembly: AssemblyProduct("BetterDropItem")] [assembly: AssemblyTitle("BetterDropItem")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace BetterDropItem { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("BetterDropItem", "BetterDropItem", "3.0.0")] [R2APISubmoduleDependency(new string[] { "NetworkingAPI", "CommandHelper" })] public class BetterDropItemPlugin : BaseUnityPlugin { private const string ModGuid = "BetterDropItem"; private const string ModName = "BetterDropItem"; private const string ModVersion = "3.0.0"; public static ConfigEntry<bool> allowDropLunar; public static ConfigEntry<bool> allowDropVoid; public static ConfigEntry<bool> enableNotifications; public static ConfigEntry<bool> allowInBazaar; public static ConfigEntry<bool> preventRecycle; public static ConfigEntry<bool> preventPrayerBeadsAbuse; public static ConfigEntry<bool> commandArtifact; public static GameObject RootObject { get; set; } public static DropItemHandler DropItemHandler { get; set; } internal static ManualLogSource Logger { get; set; } public static event Action<ItemIcon> OnItemIconAdded; public static event Action<EquipmentIcon> OnEquipmentIconAdded; public void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown ReadConfig(); Logger = ((BaseUnityPlugin)this).Logger; NetworkingAPI.RegisterMessageType<DropItemMessage>(); ItemInventoryDisplay.AllocateIcons += new Manipulator(OnItemIconAddedHook); ScoreboardStrip.SetMaster += new Manipulator(OnEquipmentIconAddedHook); RootObject = new GameObject("BetterDropItem"); Object.DontDestroyOnLoad((Object)(object)RootObject); DropItemHandler = RootObject.AddComponent<DropItemHandler>(); CommandHelper.AddToConsoleWhenReady(); OnItemIconAdded += delegate(ItemIcon itemIcon) { if (!((Object)(object)((Component)itemIcon).GetComponent<DropItemHandler>() != (Object)null)) { Func<CharacterMaster> getMaster = () => ((Component)((Component)((Transform)itemIcon.rectTransform).parent).GetComponent<ItemInventoryDisplay>().inventory).GetComponent<CharacterMaster>(); ((Component)((Component)itemIcon).transform).gameObject.AddComponent<DropItemHandler>().SetData(getMaster, () => PickupCatalog.FindPickupIndex(itemIcon.itemIndex)); } }; OnEquipmentIconAdded += delegate(EquipmentIcon equipmentIcon) { if (!((Object)(object)((Component)equipmentIcon).GetComponent<DropItemHandler>() != (Object)null)) { ((Component)((Component)equipmentIcon).transform).gameObject.AddComponent<DropItemHandler>().SetData(() => ((Component)equipmentIcon.targetInventory).GetComponent<CharacterMaster>(), () => PickupCatalog.FindPickupIndex(equipmentIcon.targetInventory.GetEquipmentIndex())); } }; PickupDropletController.CreatePickup += new Manipulator(PickupDropletController_CreatePickup); } private void PickupDropletController_CreatePickup(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(GenericPickupController), "CreatePickup") }); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<GenericPickupController, PickupDropletController, GenericPickupController>>((Func<GenericPickupController, PickupDropletController, GenericPickupController>)delegate(GenericPickupController pickup, PickupDropletController self) { if (Object.op_Implicit((Object)(object)((Component)self).GetComponent<MarkNonRecyclableComponent>())) { ((Component)pickup).gameObject.AddComponent<MarkNonRecyclableComponent>(); } return pickup; }); } private void ReadConfig() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_002b: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_008b: Expected O, but got Unknown //IL_00a0: 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) //IL_00bb: Expected O, but got Unknown //IL_00bb: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00eb: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_011b: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_014b: Expected O, but got Unknown enableNotifications = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Enable Notifications"), true, new ConfigDescription("Display a notification when an item is dropped. Not sure if this is even networked properly.", (AcceptableValueBase)null, Array.Empty<object>())); allowInBazaar = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Allow in Bazaar (Server-Side)"), true, new ConfigDescription("Allow items to be dropped while in the Bazaar.", (AcceptableValueBase)null, Array.Empty<object>())); preventRecycle = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Prevent Recycle (Server-Side)"), true, new ConfigDescription("Dropped items cannot be recycled or duplicated.", (AcceptableValueBase)null, Array.Empty<object>())); preventPrayerBeadsAbuse = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Prevent Prayer Beads Abuse (Server-Side)"), true, new ConfigDescription("Prayer Beads are undroppable to prevent players from repeatedly gaining stats.", (AcceptableValueBase)null, Array.Empty<object>())); commandArtifact = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Command Artifact Support (Server-Side)"), false, new ConfigDescription("While the Command artifact is enabled, dropped items become Command cubes so the dropper can pick a replacement item.", (AcceptableValueBase)null, Array.Empty<object>())); allowDropLunar = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Tiers (Server-Side)", "Allow Lunar"), false, new ConfigDescription("Allow items of this tier to be dropped.", (AcceptableValueBase)null, Array.Empty<object>())); allowDropVoid = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Tiers (Server-Side)", "Allow Void"), false, new ConfigDescription("Allow items of this tier to be dropped.", (AcceptableValueBase)null, Array.Empty<object>())); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { RiskOfOptionsCompat(); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void RiskOfOptionsCompat() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableNotifications)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(preventRecycle)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(preventPrayerBeadsAbuse)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(commandArtifact)); } private static void OnItemIconAddedHook(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il).Goto(0, (MoveType)0, false); int num = default(int); val.GotoNext(new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<ItemInventoryDisplay>(x, "itemIcons") }); val.Emit(OpCodes.Dup); val.EmitDelegate<Action<ItemIcon>>((Action<ItemIcon>)delegate(ItemIcon i) { BetterDropItemPlugin.OnItemIconAdded?.Invoke(i); }); } private static void OnEquipmentIconAddedHook(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il).Goto(0, (MoveType)0, false); MethodInfo setSubscribedInventory = Reflection.GetMethodCached(typeof(ItemInventoryDisplay), "SetSubscribedInventory"); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)setSubscribedInventory) }); val.Index += 1; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<ScoreboardStrip>>((Action<ScoreboardStrip>)delegate(ScoreboardStrip eq) { if ((Object)(object)eq != (Object)null && (Object)(object)eq.equipmentIcon != (Object)null) { BetterDropItemPlugin.OnEquipmentIconAdded?.Invoke(eq.equipmentIcon); } }); } } public static class ConsoleCommands { [ConCommand(/*Could not decode attribute arguments.*/)] private unsafe static void DropItemCommand(ConCommandArgs args) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (((ConCommandArgs)(ref args)).Count < 1) { Log("Usage: drop_item <item> [count]"); return; } ItemIndex val = ItemNameToIndex(((ConCommandArgs)(ref args)).GetArgString(0)); if ((int)val == -1) { Log("Can't find item specified"); return; } int num = ((ConCommandArgs)(ref args)).TryGetArgInt(1) ?? 1; if (num <= 0) { return; } CharacterMaster senderMaster = ((ConCommandArgs)(ref args)).GetSenderMaster(); if (!Object.op_Implicit((Object)(object)senderMaster) || !Object.op_Implicit((Object)(object)senderMaster.inventory)) { return; } CharacterBody body = senderMaster.GetBody(); if (!Object.op_Implicit((Object)(object)body)) { return; } num = Math.Min(num, senderMaster.inventory.GetItemCountPermanent(val)); num = Math.Min(num, 100); if (num <= 0) { Log("You don't have that item"); return; } BetterDropItemPlugin.Logger.LogDebug((object)("Item index: " + ((object)(*(ItemIndex*)(&val))/*cast due to .constrained prefix*/).ToString())); PickupIndex pickupIndex = PickupCatalog.FindPickupIndex(val); for (int i = 0; i < num; i++) { DropItemHandler.DropItem(body, senderMaster.inventory, pickupIndex); } } [ConCommand(/*Could not decode attribute arguments.*/)] private static void DropEquipCommand(ConCommandArgs args) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_003c: Invalid comparison between Unknown and I4 //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) CharacterMaster senderMaster = ((ConCommandArgs)(ref args)).GetSenderMaster(); if (!Object.op_Implicit((Object)(object)senderMaster) || !Object.op_Implicit((Object)(object)senderMaster.inventory)) { return; } CharacterBody body = senderMaster.GetBody(); if (Object.op_Implicit((Object)(object)body)) { EquipmentIndex equipmentIndex = senderMaster.inventory.GetEquipmentIndex(); if ((int)equipmentIndex == -1) { Log("No equipment to drop"); } else { DropItemHandler.DropItem(body, senderMaster.inventory, PickupCatalog.FindPickupIndex(equipmentIndex)); } } } public unsafe static ItemIndex ItemNameToIndex(string name) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(name)) { return (ItemIndex)(-1); } if (Enum.TryParse<ItemIndex>(name, ignoreCase: true, out ItemIndex result) && ItemCatalog.IsIndexValid(ref result)) { return result; } AllItemsEnumerator enumerator = ItemCatalog.allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemDef itemDef = ItemCatalog.GetItemDef(((AllItemsEnumerator)(ref enumerator)).Current); if (!((Object)(object)itemDef == (Object)null) && !string.IsNullOrEmpty(((Object)itemDef).name) && ((Object)itemDef).name.ToUpper().Contains(name.ToUpper())) { return itemDef.itemIndex; } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } return (ItemIndex)(-1); } private static void Log(string message) { BetterDropItemPlugin.Logger.LogInfo((object)message); RoR2Application.Print(message); } } public class DropItemHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { private Func<CharacterMaster> getMaster; private Func<PickupIndex> getPickupIndex; public void SetData(Func<CharacterMaster> getMaster, Func<PickupIndex> getPickupIndex) { this.getMaster = getMaster; this.getPickupIndex = getPickupIndex; } public void OnPointerClick(PointerEventData eventData) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) BetterDropItemPlugin.Logger.LogDebug((object)"BDI: Pointer click, trying to send network message"); CharacterMaster val = getMaster(); BetterDropItemPlugin.Logger.LogDebug((object)"1"); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.inventory) || !((NetworkBehaviour)val.inventory).hasAuthority) { return; } BetterDropItemPlugin.Logger.LogDebug((object)"2"); PickupIndex pickupIndex = getPickupIndex(); BetterDropItemPlugin.Logger.LogDebug((object)"2.1"); CharacterBody body = val.GetBody(); BetterDropItemPlugin.Logger.LogDebug((object)"2.2"); if (!Object.op_Implicit((Object)(object)body)) { BetterDropItemPlugin.Logger.LogDebug((object)"2.3"); return; } BetterDropItemPlugin.Logger.LogDebug((object)"3"); NetworkIdentity component = ((Component)body).gameObject.GetComponent<NetworkIdentity>(); BetterDropItemPlugin.Logger.LogDebug((object)"4"); if (VerifyIsDroppable(pickupIndex, val.inventory)) { BetterDropItemPlugin.Logger.LogDebug((object)"BDI: Sending network message"); NetMessageExtensions.Send((INetMessage)(object)new DropItemMessage(component.netId, pickupIndex), (NetworkDestination)2); } } public unsafe static bool DropItem(Vector3 position, Vector3 direction, Inventory inventory, PickupIndex pickupIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Invalid comparison between Unknown and I4 //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Invalid comparison between Unknown and I4 //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (!VerifyIsDroppable(pickupIndex, inventory)) { return false; } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef == null) { return false; } ManualLogSource logger = BetterDropItemPlugin.Logger; Vector3 val = position; logger.LogDebug((object)("Position: " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); ManualLogSource logger2 = BetterDropItemPlugin.Logger; val = direction; logger2.LogDebug((object)("Direction: " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); BetterDropItemPlugin.Logger.LogDebug((object)("Inventory: " + ((Object)inventory).name)); BetterDropItemPlugin.Logger.LogDebug((object)("Pickup Index: " + ((object)(*(PickupIndex*)(&pickupIndex))/*cast due to .constrained prefix*/).ToString())); if ((int)pickupDef.equipmentIndex != -1) { if (inventory.GetEquipmentIndex() != pickupDef.equipmentIndex) { return false; } inventory.SetEquipmentIndex((EquipmentIndex)(-1), true); } else { if (inventory.GetItemCountPermanent(pickupDef.itemIndex) <= 0) { return false; } inventory.RemoveItemPermanent(pickupDef.itemIndex, 1); } CreatePickupInfo val2 = default(CreatePickupInfo); ((CreatePickupInfo)(ref val2)).pickupIndex = pickupIndex; val2.position = position; CreatePickupInfo pickupInfo = val2; if (BetterDropItemPlugin.commandArtifact.Value && (int)pickupDef.equipmentIndex == -1 && (Object)(object)RunArtifactManager.instance != (Object)null && RunArtifactManager.instance.IsArtifactEnabled(Artifacts.Command)) { pickupInfo.artifactFlag = (PickupArtifactFlag)1; } CreatePickupDroplet(pickupInfo, Vector3.up * 20f + direction * 10f); return true; } public static bool DropItem(CharacterBody body, Inventory inventory, PickupIndex pickupIndex) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)body)) { return false; } Vector3 corePosition = body.corePosition; Vector3 direction = (Object.op_Implicit((Object)(object)body.characterDirection) ? body.characterDirection.forward : body.transform.forward); if (Object.op_Implicit((Object)(object)body.inputBank)) { Ray aimRay = body.inputBank.GetAimRay(); direction = ((Ray)(ref aimRay)).direction; direction.y = 0f; ((Vector3)(ref direction)).Normalize(); } return DropItem(corePosition, direction, inventory, pickupIndex); } private static void CreatePickupDroplet(CreatePickupInfo pickupInfo, Vector3 velocity) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(PickupDropletController.pickupDropletPrefab, pickupInfo.position, Quaternion.identity); PickupDropletController component = val.GetComponent<PickupDropletController>(); if (Object.op_Implicit((Object)(object)component)) { component.createPickupInfo = pickupInfo; component.NetworkpickupState = ((CreatePickupInfo)(ref pickupInfo)).pickup; } Rigidbody component2 = val.GetComponent<Rigidbody>(); component2.velocity = velocity; component2.AddTorque(Random.Range(150f, 120f) * Random.onUnitSphere); if (BetterDropItemPlugin.preventRecycle.Value) { val.AddComponent<MarkNonRecyclableComponent>(); } NetworkServer.Spawn(val); } private static bool VerifyIsDroppable(PickupIndex pickupIndex, Inventory inventory) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Invalid comparison between Unknown and I4 //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Invalid comparison between Unknown and I4 //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Invalid comparison between Unknown and I4 //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Invalid comparison between Unknown and I4 //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)inventory)) { return false; } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef == null) { return false; } if ((int)pickupDef.equipmentIndex != -1) { return true; } if ((int)pickupDef.itemIndex != -1 && inventory.GetItemCountPermanent(pickupDef.itemIndex) <= 0) { return false; } if ((int)pickupDef.itemTier == 5) { return false; } if (BetterDropItemPlugin.preventPrayerBeadsAbuse.Value && (int)pickupDef.itemIndex != -1 && (Object)(object)ItemCatalog.GetItemDef(pickupDef.itemIndex) == (Object)(object)Items.ExtraStatsOnLevelUp) { return false; } if (!BetterDropItemPlugin.allowInBazaar.Value) { SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene(); if (Object.op_Implicit((Object)(object)sceneDefForCurrentScene) && sceneDefForCurrentScene.baseSceneName == "bazaar") { return false; } } ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(pickupDef.itemTier); bool result = (Object)(object)itemTierDef == (Object)null || itemTierDef.isDroppable; if ((Object)(object)itemTierDef != (Object)null) { if ((int)itemTierDef.tier == 3) { result = BetterDropItemPlugin.allowDropLunar.Value || (int)pickupDef.equipmentIndex != -1; } else if ((int)itemTierDef.tier == 9 || (int)itemTierDef.tier == 6 || (int)itemTierDef.tier == 7 || (int)itemTierDef.tier == 8) { result = BetterDropItemPlugin.allowDropVoid.Value; } } return result; } public static void CreateNotification(CharacterBody character, PickupIndex pickupIndex) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)character)) { return; } PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef != null) { if ((int)pickupDef.equipmentIndex != -1) { CreateNotification(character, character.transform, pickupDef.equipmentIndex); } else { CreateNotification(character, character.transform, pickupDef.itemIndex); } } } private static void CreateNotification(CharacterBody character, Transform transform, EquipmentIndex equipmentIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex); string description = Language.GetString(equipmentDef.nameToken); Texture pickupIconTexture = equipmentDef.pickupIconTexture; CreateNotification(character, transform, "Equipment dropped", description, pickupIconTexture); } private static void CreateNotification(CharacterBody character, Transform transform, ItemIndex itemIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); string description = Language.GetString(itemDef.nameToken); Texture pickupIconTexture = itemDef.pickupIconTexture; CreateNotification(character, transform, "Item dropped", description, pickupIconTexture); } private static void CreateNotification(CharacterBody character, Transform transform, string title, string description, Texture texture) { DropItemNotification dropItemNotification = ((Component)character).gameObject.GetComponent<DropItemNotification>(); if ((Object)(object)dropItemNotification == (Object)null) { dropItemNotification = ((Component)character).gameObject.AddComponent<DropItemNotification>(); ((Component)dropItemNotification).transform.SetParent(transform); } dropItemNotification.SetNotification(title, description, texture); } } public class DropItemMessage : INetMessage, ISerializableObject { private NetworkInstanceId netId; private PickupIndex pickupIndex; public DropItemMessage() { } public DropItemMessage(NetworkInstanceId netId, PickupIndex pickupIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) this.netId = netId; this.pickupIndex = pickupIndex; } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) writer.Write(netId); PickupIndex.WriteToNetworkWriter(writer, pickupIndex); } public void Deserialize(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) netId = reader.ReadNetworkId(); pickupIndex = NetworkExtensions.ReadPickupIndex(reader); } public override string ToString() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return $"DropItemMessage: {pickupIndex}"; } private void Log(string message) { BetterDropItemPlugin.Logger.LogDebug((object)message); } public void OnReceived() { //IL_0056: 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_00c2: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } Log("Received drop item message"); Log("NetworkID" + ((object)Unsafe.As<NetworkInstanceId, NetworkInstanceId>(ref netId)/*cast due to .constrained prefix*/).ToString()); Log("PickupIndex" + ((object)Unsafe.As<PickupIndex, PickupIndex>(ref pickupIndex)/*cast due to .constrained prefix*/).ToString()); GameObject val = Util.FindNetworkObject(netId); if (!Object.op_Implicit((Object)(object)val)) { return; } CharacterBody component = val.GetComponent<CharacterBody>(); Log("Body is null: " + ((Object)(object)component == (Object)null)); if (Object.op_Implicit((Object)(object)component)) { Inventory inventory = component.master.inventory; if (DropItemHandler.DropItem(component, inventory, pickupIndex) && BetterDropItemPlugin.enableNotifications.Value) { DropItemHandler.CreateNotification(component, pickupIndex); } } } } public class DropItemNotification : MonoBehaviour { private Notification notification; private float startTime; private float duration = 6f; private void Update() { if (!((Object)(object)notification == (Object)null)) { if (Run.instance.fixedTime - startTime > duration) { Object.Destroy((Object)(object)notification); Object.Destroy((Object)(object)this); } else { float notificationT = (Run.instance.fixedTime - startTime) / duration; notification.GenericNotification.SetNotificationT(notificationT); } } } private void OnDestroy() { if ((Object)(object)notification != (Object)null) { Object.Destroy((Object)(object)notification); } } public void SetNotification(string title, string description, Texture texture) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)notification == (Object)null) { notification = ((Component)this).gameObject.AddComponent<Notification>(); ((Component)notification).transform.SetParent(((Component)this).transform); notification.SetPosition(new Vector3((float)((double)Screen.width * 0.8), (float)((double)Screen.height * 0.25), 0f)); } startTime = Run.instance.fixedTime; notification.SetIcon(texture); notification.GetTitle = () => title; notification.GetDescription = () => description; } } public class MarkNonRecyclableComponent : MonoBehaviour { public void Start() { GenericPickupController component = ((Component)this).GetComponent<GenericPickupController>(); if (Object.op_Implicit((Object)(object)component)) { component.Duplicated = true; component.Recycled = true; Object.Destroy((Object)(object)this); } } } }