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 OrganizeItems v1.0.2
OrganizeItems/OrganizeItems.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using OrganizeItems.Networking; using Unity.Collections; using Unity.Netcode; 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.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OrganizeItems")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OrganizeItems")] [assembly: AssemblyTitle("OrganizeItems")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 OrganizeItems { internal class ItemList { public static readonly Dictionary<string, Vector3> GoodItems = new Dictionary<string, Vector3> { { "Hairdryer", new Vector3(-0.69f, 0.35f, -12.76f) }, { "Hairbrush", new Vector3(3.02f, 0.38f, -13.46f) }, { "EasterEgg", new Vector3(-5.05f, 0.35f, -14.6f) }, { "Mug", new Vector3(-1.18f, 0.35f, -14.37f) }, { "Dentures", new Vector3(-1.87f, 0.36f, -13.35f) }, { "FancyLamp", new Vector3(2.89f, 0.29f, -14.23f) }, { "ComedyMask", new Vector3(-2.65f, 0.35f, -14.5f) }, { "FancyRing", new Vector3(-2.06f, 0.35f, -14.41f) }, { "TragedyMask", new Vector3(-2.81f, 0.35f, -13.96f) }, { "BinFullOfBottles", new Vector3(-3.76f, 0.35f, -14.61f) }, { "ToyCube", new Vector3(-2.21f, 0.35f, -12.43f) }, { "FancyGlass", new Vector3(-4.63f, 0.35f, -12.38f) }, { "FishTestProp", new Vector3(-5.07f, 0.35f, -15.2f) }, { "PerfumeBottle", new Vector3(0.02f, 0.35f, -15.96f) }, { "Painting", new Vector3(2.56f, 0.29f, -15.86f) }, { "Airhorn", new Vector3(1.21f, 0.35f, -13.02f) }, { "RedSodaCan", new Vector3(-0.61f, 0.35f, -13.66f) }, { "RubberDucky", new Vector3(9.65f, 1.73f, -13.98f) }, { "MagnifyingGlass", new Vector3(-2.66f, 0.38f, -14.95f) }, { "Toothpaste", new Vector3(-3.68f, 0.35f, -15.28f) }, { "Candy", new Vector3(-2.3f, 0.35f, -15.96f) }, { "RedLocustHive", new Vector3(7.59f, 0.29f, -12.63f) }, { "TeaKettle", new Vector3(-3.71f, 0.35f, -13.75f) }, { "HandBell", new Vector3(-3.21f, 0.35f, -13.04f) }, { "RobotToy", new Vector3(1.02f, 0.29f, -15.95f) }, { "Clownhorn", new Vector3(1.21f, 0.35f, -13.02f) }, { "OldPhone", new Vector3(-0.53f, 0.35f, -14.55f) }, { "LaserPointer", new Vector3(-5.07f, 0.35f, -14.35f) }, { "Magic7Ball", new Vector3(-4.93f, 0.37f, -13.61f) } }; public static readonly Dictionary<string, Vector3> BadItems = new Dictionary<string, Vector3> { { "StopSign", new Vector3(4.13f, 0.37f, -13.58f) }, { "YieldSign", new Vector3(4.13f, 0.37f, -13.58f) }, { "CookieMoldPan", new Vector3(4.13f, 0.37f, -13.58f) }, { "DiyFlashbang", new Vector3(4.13f, 0.37f, -13.58f) }, { "PillBottle", new Vector3(4.13f, 0.37f, -13.58f) }, { "Dustpan", new Vector3(4.13f, 0.37f, -13.58f) }, { "SteeringWheel", new Vector3(4.13f, 0.37f, -13.58f) }, { "Remote", new Vector3(4.13f, 0.37f, -13.58f) }, { "ChemicalJug", new Vector3(4.13f, 0.37f, -13.58f) }, { "Flask", new Vector3(4.13f, 0.37f, -13.58f) }, { "EnginePart", new Vector3(4.13f, 0.37f, -13.58f) }, { "EggBeater", new Vector3(4.13f, 0.37f, -13.58f) }, { "BigBolt", new Vector3(4.13f, 0.37f, -13.58f) }, { "MetalSheet", new Vector3(4.13f, 0.37f, -13.58f) }, { "WhoopieCushion", new Vector3(9.73f, 1.74f, -15.2f) }, { "Cog", new Vector3(4.13f, 0.37f, -13.58f) } }; } [BepInPlugin("Rbmukthegreat.OrganizeItems", "Organize Items", "1.0.2")] public class Plugin : BaseUnityPlugin { private const string modGUID = "Rbmukthegreat.OrganizeItems"; private const string modName = "Organize Items"; private const string modVersion = "1.0.2"; private readonly Harmony harmony = new Harmony("Rbmukthegreat.OrganizeItems"); internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin OrganizeItems is loaded!"); harmony.PatchAll(Assembly.GetExecutingAssembly()); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "OrganizeItems"; public const string PLUGIN_NAME = "OrganizeItems"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace OrganizeItems.Patches { [HarmonyPatch] internal class OrganizeItemsPatch { private static readonly ManualLogSource Log = Plugin.Log; private static GameObject Ship; [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void OnLocalPlayerConnect() { NetworkFunctions.NetworkingObjectManager.NetworkManagerInit(); } [HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")] [HarmonyPostfix] private static void GetText(string chatMessage) { if (chatMessage == ".organize") { Log.LogMessage((object)"Organizing items!"); OrganizeItems(); } } private static void OrganizeItems() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) List<GrabbableObject> itemList = GetItemList(); foreach (string key in ItemList.GoodItems.Keys) { Log.LogMessage((object)("Teleporting " + key + "!")); TeleportItemsToPosition(Filter(key, itemList), ItemList.GoodItems[key]); } foreach (string key2 in ItemList.BadItems.Keys) { Log.LogMessage((object)("Teleporting " + key2 + "!")); TeleportItemsToPosition(Filter(key2, itemList), ItemList.BadItems[key2]); } } private static List<GrabbableObject> Filter(string itemType, List<GrabbableObject> itemList) { string Clone = "(Clone)"; return itemList.Where((GrabbableObject item) => ((Object)item).name.Substring(0, ((Object)item).name.Count() - Clone.Count()) == itemType).ToList(); } private static List<GrabbableObject> GetItemList() { if (!Object.op_Implicit((Object)(object)Ship)) { Ship = GameObject.Find("/Environment/HangarShip"); } return (from obj in Ship.GetComponentsInChildren<GrabbableObject>() where obj.itemProperties.isScrap && !(obj is RagdollGrabbableObject) select obj).ToList(); } private static void TeleportItemsToPosition(List<GrabbableObject> itemList, Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (itemList.Count == 0) { return; } foreach (GrabbableObject item in itemList) { DropItem(item, position); } } private static void DropItem(GrabbableObject item, Vector3 position) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0035: 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) NetworkFunctions.NetworkingObjectManager.RunClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)item).NetworkObject), position + new Vector3(Random.Range(-0.1f, 0.1f), 0f, Random.Range(-0.1f, 0.1f)), ((Component)item).transform.rotation); } } } namespace OrganizeItems.Networking { internal class NetworkFunctions { public class NetworkingObjectManager : NetworkBehaviour { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__3_0; internal void <NetworkManagerInit>b__3_0(ulong senderClientId, FastBufferReader reader) { //IL_001c: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (senderClientId != Player.playerClientId) { NetworkObjectReference val = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref val, default(ForNetworkSerializable)); Vector3 placementPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementPosition); Quaternion placementRotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementRotation); NetworkObject val2 = default(NetworkObject); if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null)) { GrabbableObject component = ((Component)val2).GetComponent<GrabbableObject>(); MakeObjectFall(component, placementPosition, placementRotation); } } } } public static void MakeObjectFall(GrabbableObject obj, Vector3 placementPosition, Quaternion placementRotation) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) ((Component)obj).gameObject.transform.SetPositionAndRotation(placementPosition, placementRotation); obj.hasHitGround = false; obj.startFallingPosition = placementPosition; obj.floorYRot = -1; if ((Object)(object)((Component)obj).transform.parent != (Object)null) { obj.startFallingPosition = ((Component)obj).transform.parent.InverseTransformPoint(obj.startFallingPosition); } obj.FallToGround(false); obj.floorYRot = -1; } [ClientRpc] public static void MakeObjectFallClientRpc(NetworkObjectReference obj, Vector3 placementPosition, Quaternion placementRotation) { //IL_0034: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || !singleton.IsListening) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementPosition); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementRotation); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("MakeObjectFall", val, (NetworkDelivery)2); NetworkObject val2 = default(NetworkObject); if (((NetworkObjectReference)(ref obj)).TryGet(ref val2, (NetworkManager)null)) { GrabbableObject obj2 = default(GrabbableObject); if (((Component)val2).TryGetComponent<GrabbableObject>(ref obj2)) { MakeObjectFall(obj2, placementPosition, placementRotation); } else { Log.LogError((object)"Failed to get grabbable object ref from network object - ClientRpc"); } } } [ServerRpc] public static void MakeObjectFallServerRpc(NetworkObjectReference obj, Vector3 placementPosition, Quaternion placementRotation) { //IL_00a6: 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_00d7: 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_0070: Invalid comparison between Unknown and I4 //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { Log.LogError((object)"Network Manager == null"); return; } if (!singleton.IsListening) { Log.LogError((object)"Network Manager not listening"); return; } if (((NetworkBehaviour)Player).OwnerClientId != singleton.LocalClientId) { if ((int)singleton.LogLevel <= 1) { Log.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementPosition); ((FastBufferWriter)(ref val)).WriteValueSafe(ref placementRotation); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("MakeObjectFall", val, (NetworkDelivery)2); NetworkObject val2 = default(NetworkObject); if (((NetworkObjectReference)(ref obj)).TryGet(ref val2, (NetworkManager)null)) { GrabbableObject obj2 = default(GrabbableObject); if (((Component)val2).TryGetComponent<GrabbableObject>(ref obj2)) { MakeObjectFall(obj2, placementPosition, placementRotation); } else { Log.LogError((object)"Failed to get grabbable object ref from network object - ServerRpc"); } } } public static void NetworkManagerInit() { //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_003f: Expected O, but got Unknown Log.LogMessage((object)"Registering named message"); CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>c.<>9__3_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong senderClientId, FastBufferReader reader) { //IL_001c: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (senderClientId != Player.playerClientId) { NetworkObjectReference val2 = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref val2, default(ForNetworkSerializable)); Vector3 placementPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementPosition); Quaternion placementRotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref placementRotation); NetworkObject val3 = default(NetworkObject); if (((NetworkObjectReference)(ref val2)).TryGet(ref val3, (NetworkManager)null)) { GrabbableObject component = ((Component)val3).GetComponent<GrabbableObject>(); MakeObjectFall(component, placementPosition, placementRotation); } } }; <>c.<>9__3_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("MakeObjectFall", (HandleNamedMessageDelegate)obj); } [ClientRpc] public static void RunClientRpc(NetworkObjectReference obj, Vector3 placementPosition, Quaternion placementRotation) { //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_0003: Unknown result type (might be due to invalid IL or missing references) MakeObjectFallServerRpc(obj, placementPosition, placementRotation); } } private static readonly ManualLogSource Log = Plugin.Log; private static PlayerControllerB Player => StartOfRound.Instance?.localPlayerController; } }