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 LuckReservedPersonalBoombox v1.0.4
ReservedPersonalBoomboxSlot.dll
Decompiled 2 years agousing 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 GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using PersonalBoombox; using ReservedItemSlotCore; using ReservedItemSlotCore.Networking; using ReservedItemSlotCore.Patches; 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("ReservedPersonalBoomboxSlot")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ReservedPersonalBoomboxSlot")] [assembly: AssemblyTitle("ReservedPersonalBoomboxSlot")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 ReservedPersonalBoomboxSlot { [BepInPlugin("Luck.ReservedPersonalBoomboxSlot", "ReservedPersonalBoomboxSlot", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { public static Plugin instance; private Harmony _harmony; public static ReservedItemInfo defaultBoombox = new ReservedItemInfo("Boombox", 21, false, false, false, false); public static ReservedItemInfo assholeBoombox = new ReservedItemInfo("pbA AssholeBox", 21, false, false, false, false); public static ReservedItemInfo crimmasBoombox = new ReservedItemInfo("pbB ChristmasSongs", 21, false, false, false, false); public static ReservedItemInfo starkidBoombox1 = new ReservedItemInfo("pbA MemeBox", 21, false, false, false, false); public static ReservedItemInfo starkidBoombox2 = new ReservedItemInfo("pbB OffBroadwayBox", 21, false, false, false, false); private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown instance = this; _harmony = new Harmony("ReservedPersonalBoomboxSlot"); if (Chainloader.PluginInfos.ContainsKey("Luck.ReservedPersonalBoomboxSlot")) { } _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ReservedPersonalBoomboxSlot loaded"); } public static void Log(string message) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } } } namespace ReservedPersonalBoomboxSlot.Patches { [HarmonyPatch] internal static class Patcher { private static Vector3 playerShoulderPositionOffset = new Vector3(-0.4f, 0.3f, 0f); private static Vector3 playerShoulderRotationOffset = new Vector3(0f, 90f, 90f); public static HashSet<BoomboxItem> pocketingBoomboxes = new HashSet<BoomboxItem>(); public static HashSet<PersonalBoomboxItem> pocketingPersonalBoomboxes = new HashSet<PersonalBoomboxItem>(); public static PlayerControllerB localPlayerController => PlayerPatcher.localPlayerController; public static PlayerControllerB GetPreviousPlayerHeldBy(BoomboxItem boomboxItem) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown return (PlayerControllerB)Traverse.Create((object)boomboxItem).Field("previousPlayerHeldBy").GetValue(); } public static BoomboxItem GetMainBoombox(PlayerControllerB playerController) { return GetCurrentlySelectedBoombox(playerController) ?? GetReservedBoombox(playerController); } public static BoomboxItem GetReservedBoombox(PlayerControllerB playerController) { return (BoomboxItem)(SyncManager.syncReservedItemsList.Contains(Plugin.defaultBoombox) ? /*isinst with value type is only supported in some contexts*/: null); } public static PersonalBoomboxItem GetReservedBoombox2(PlayerControllerB playerController) { return (PersonalBoomboxItem)(SyncManager.syncReservedItemsList.Contains(Plugin.assholeBoombox) ? /*isinst with value type is only supported in some contexts*/: null); } public static PersonalBoomboxItem GetReservedBoombox3(PlayerControllerB playerController) { return (PersonalBoomboxItem)(SyncManager.syncReservedItemsList.Contains(Plugin.crimmasBoombox) ? /*isinst with value type is only supported in some contexts*/: null); } public static PersonalBoomboxItem GetReservedBoomboxStarkid1(PlayerControllerB playerController) { return (PersonalBoomboxItem)(SyncManager.syncReservedItemsList.Contains(Plugin.starkidBoombox1) ? /*isinst with value type is only supported in some contexts*/: null); } public static PersonalBoomboxItem GetReservedBoomboxStarkid2(PlayerControllerB playerController) { return (PersonalBoomboxItem)(SyncManager.syncReservedItemsList.Contains(Plugin.starkidBoombox2) ? /*isinst with value type is only supported in some contexts*/: null); } public static BoomboxItem GetCurrentlySelectedBoombox(PlayerControllerB playerController) { GrabbableObject obj = ((playerController != null) ? playerController.ItemSlots[playerController.currentItemSlot] : null); return (BoomboxItem)(object)((obj is BoomboxItem) ? obj : null); } [HarmonyPatch(typeof(GrabbableObject), "PocketItem")] [HarmonyPostfix] public static void OnPocketBoomboxLocal(GrabbableObject __instance) { if (__instance is BoomboxItem || __instance is PersonalBoomboxItem) { OnPocketBoombox(__instance); } } private static void OnPocketBoombox(GrabbableObject boomboxItem) { if ((boomboxItem is BoomboxItem || boomboxItem is PersonalBoomboxItem) && !((Object)(object)boomboxItem.playerHeldBy == (Object)null)) { if ((Object)(object)boomboxItem.playerHeldBy == (Object)(object)localPlayerController) { ((Component)boomboxItem).gameObject.layer = 23; } else { ((Component)boomboxItem).gameObject.layer = 6; } if ((Object)(object)boomboxItem == (Object)(object)GetReservedBoombox(boomboxItem.playerHeldBy)) { boomboxItem.parentObject = boomboxItem.playerHeldBy.playerGlobalHead.parent; } if ((Object)(object)boomboxItem == (Object)(object)GetReservedBoombox2(boomboxItem.playerHeldBy)) { boomboxItem.parentObject = boomboxItem.playerHeldBy.playerGlobalHead.parent; } if ((Object)(object)boomboxItem == (Object)(object)GetReservedBoombox3(boomboxItem.playerHeldBy)) { boomboxItem.parentObject = boomboxItem.playerHeldBy.playerGlobalHead.parent; } if ((Object)(object)boomboxItem == (Object)(object)GetReservedBoomboxStarkid1(boomboxItem.playerHeldBy)) { boomboxItem.parentObject = boomboxItem.playerHeldBy.playerGlobalHead.parent; } if ((Object)(object)boomboxItem == (Object)(object)GetReservedBoomboxStarkid2(boomboxItem.playerHeldBy)) { boomboxItem.parentObject = boomboxItem.playerHeldBy.playerGlobalHead.parent; } } } [HarmonyPatch(typeof(GrabbableObject), "EquipItem")] [HarmonyPostfix] public static void OnEquipBoombox(GrabbableObject __instance) { if ((__instance is BoomboxItem || __instance is PersonalBoomboxItem) && !((Object)(object)__instance.playerHeldBy == (Object)null)) { ((Component)__instance).gameObject.layer = 6; __instance.parentObject = (((Object)(object)__instance.playerHeldBy == (Object)(object)localPlayerController) ? __instance.playerHeldBy.localItemHolder : __instance.playerHeldBy.serverItemHolder); } } [HarmonyPatch(typeof(GrabbableObject), "DiscardItem")] [HarmonyPostfix] public static void ResetLayerAfterDiscard(GrabbableObject __instance) { if (__instance is BoomboxItem || __instance is PersonalBoomboxItem) { ((Component)__instance).gameObject.layer = 6; } } [HarmonyPatch(typeof(GrabbableObject), "LateUpdate")] [HarmonyPostfix] public static void SetPositionOffset(GrabbableObject __instance) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if ((__instance is BoomboxItem || __instance is PersonalBoomboxItem) && (Object)(object)__instance.playerHeldBy != (Object)null && (Object)(object)__instance.parentObject != (Object)null && __instance.isPocketed && ((Object)(object)__instance == (Object)(object)GetReservedBoombox(__instance.playerHeldBy) || (Object)(object)__instance == (Object)(object)GetReservedBoombox2(__instance.playerHeldBy) || (Object)(object)__instance == (Object)(object)GetReservedBoombox3(__instance.playerHeldBy) || (Object)(object)__instance == (Object)(object)GetReservedBoomboxStarkid1(__instance.playerHeldBy) || (Object)(object)__instance == (Object)(object)GetReservedBoomboxStarkid2(__instance.playerHeldBy)) && (Object)(object)__instance != (Object)(object)GetCurrentlySelectedBoombox(__instance.playerHeldBy)) { Transform transform = ((Component)__instance.parentObject).transform; ((Component)__instance).transform.rotation = ((Component)__instance.parentObject).transform.rotation * Quaternion.Euler(playerShoulderRotationOffset); ((Component)__instance).transform.position = transform.position + transform.rotation * playerShoulderPositionOffset; } } [HarmonyPatch(typeof(GrabbableObject), "EnableItemMeshes")] [HarmonyPrefix] public static void OnEnableItemMeshes(ref bool enable, GrabbableObject __instance) { if (__instance is BoomboxItem || __instance is PersonalBoomboxItem) { enable = true; } } [HarmonyPatch(typeof(BoomboxItem), "PocketItem")] [HarmonyPrefix] public static void OnPocketBoombox(BoomboxItem __instance) { pocketingBoomboxes.Add(__instance); } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] [HarmonyPrefix] public static bool PreventStoppingMusicOnPocket(bool startMusic, BoomboxItem __instance) { if (pocketingBoomboxes.Contains(__instance)) { pocketingBoomboxes.Remove(__instance); return false; } return true; } [HarmonyPatch(typeof(PersonalBoomboxItem), "PocketItem")] [HarmonyPrefix] public static void OnPocketPersonalBoombox(PersonalBoomboxItem __instance) { pocketingPersonalBoomboxes.Add(__instance); } [HarmonyPatch(typeof(PersonalBoomboxItem), "StartMusic")] [HarmonyPrefix] public static bool PreventStoppingPersonalMusicOnPocket(bool startMusic, PersonalBoomboxItem __instance) { if (pocketingPersonalBoomboxes.Contains(__instance)) { pocketingPersonalBoomboxes.Remove(__instance); return false; } return true; } } }