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 EmptyBag v1.0.1
EmptyBag.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChatCommandAPI; using ChatCommandAPI.Utils; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; 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: AssemblyCompany("EmptyBag")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("EmptyBag")] [assembly: AssemblyTitle("EmptyBag")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [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 EmptyBag { [BepInPlugin("Crispy_Depression.EmptyBag", "EmptyBag", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class EmptyBagPlugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<bool> AutoEmpty; internal static ConfigEntry<bool> AllowClients; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; AllowClients = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowClients", false, "Allow non-host players to use /empty. When false, only the host can use it."); AutoEmpty = ((BaseUnityPlugin)this).Config.Bind<bool>("Experimental", "AutoEmpty", false, "[EXPERIMENTAL - BUGGY] Automatically empty unheld belt bags in the ship (or a magneted Cruiser) when the ship leaves the moon. Host only. The /empty command works either way."); new Harmony("Crispy_Depression.EmptyBag").PatchAll(); new EmptyCommand(); Log.LogInfo((object)"EmptyBag loaded"); } } public class EmptyCommand : Command { public override string Name => "Empty bags"; public override string Command => "empty"; public override string Description => "Drops everything out of unheld belt bags in the ship"; public override void Invoke(string args) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { throw new CommandException("You need to be in a lobby"); } if (!((NetworkBehaviour)instance).IsHost && !EmptyBagPlugin.AllowClients.Value) { throw new CommandException("Only the host can use this (AllowClients is off)"); } int num = BagEmptier.EmptyBags(instance); Chat.Print($"Dropped {num} item(s) from unheld bags", (Color?)null); } } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] internal static class ShipLeavePatch { [HarmonyPriority(800)] private static void Prefix(StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsServer && EmptyBagPlugin.AutoEmpty.Value) { BagEmptier.EmptyBags(__instance); } } } internal static class BagEmptier { private static bool IsInShip(BeltBagItem bag) { VehicleController componentInParent = ((Component)bag).GetComponentInParent<VehicleController>(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent.magnetedToShip; } if (!((GrabbableObject)bag).isInShipRoom) { return ((GrabbableObject)bag).isInElevator; } return true; } internal static int EmptyBags(StartOfRound round) { //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) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) int num = 0; BeltBagItem[] array = Object.FindObjectsOfType<BeltBagItem>(); foreach (BeltBagItem val in array) { if ((Object)(object)val.insideAnotherBeltBag != (Object)null || ((GrabbableObject)val).isHeld || (Object)(object)((GrabbableObject)val).playerHeldBy != (Object)null || !IsInShip(val)) { continue; } Vector3 val2 = ((Component)val).transform.position + Vector3.up * 0.2f; Queue<BeltBagItem> queue = new Queue<BeltBagItem>(); queue.Enqueue(val); int num2 = 0; while (queue.Count > 0 && num2++ < 500) { BeltBagItem val3 = queue.Dequeue(); if ((Object)(object)val3 == (Object)null || val3.objectsInBag == null) { continue; } int num3 = 0; while (val3.objectsInBag.Count > 0 && num3++ < 500) { GrabbableObject val4 = val3.objectsInBag[0]; if ((Object)(object)val4 == (Object)null) { val3.objectsInBag.RemoveAt(0); continue; } Vector2 val5 = Random.insideUnitCircle * 0.25f; ((Component)val4).transform.position = val2 + new Vector3(val5.x, 0f, val5.y); int count = val3.objectsInBag.Count; val3.RemoveObjectFromBag(0); if (val3.objectsInBag.Count >= count) { break; } num++; BeltBagItem val6 = (BeltBagItem)(object)((val4 is BeltBagItem) ? val4 : null); if ((Object)(object)val6 != (Object)null) { queue.Enqueue(val6); } } } } EmptyBagPlugin.Log.LogInfo((object)$"Dropped {num} item(s) from unheld bags"); return num; } } }