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 MushBoomboxVisuals v1.0.1
BepInEx/plugins/BoomboxVisuals.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.Drawing; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; 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: AssemblyTitle("BetterBoombox")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BetterBoombox")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c47d6572-556c-40d1-8de7-aad7af0438e7")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace BoomboxControl { [BepInPlugin("Mush.BoomboxControl", "BoomboxControl", "1.1.2")] public class Plugin : BaseUnityPlugin { public static Plugin instance; private static Harmony HarmonyLib; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown instance = this; HarmonyLib = new Harmony("Mush.BoomboxControl"); HarmonyLib.PatchAll(typeof(BoomboxControl)); } } public class BoomboxControl : MonoBehaviour { public class VisualBoombox : MonoBehaviour { public static class MyPluginInfo { public const string PLUGIN_GUID = "BoomboxControl"; public const string PLUGIN_NAME = "BoomboxControl"; public const string PLUGIN_VERSION = "1.0.0"; } private static VisualBoombox _instance; public Coroutine Start(IEnumerator routine) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) if ((Object)_instance == (Object)null) { _instance = new GameObject("VisualBoombox").AddComponent<VisualBoombox>(); Object.DontDestroyOnLoad((Object)(object)_instance); } return ((MonoBehaviour)_instance).StartCoroutine(routine); } public IEnumerator GetTexture(string url, BoomboxItem boombox) { UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(url); try { yield return uwr.SendWebRequest(); if ((int)uwr.result == 1) { Texture2D originalTexture = DownloadHandlerTexture.GetContent(uwr); int targetWidth = 720; int targetHeight = 340; Texture2D texture = ResizeTexture(originalTexture, targetWidth, targetHeight); GameObject cube = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)cube).name = "CubeBoombox"; float textureWidth = ((Texture)texture).width; float textureHeight = ((Texture)texture).height; float aspectRatio = textureWidth / textureHeight; float scaleFactor = 0.38f; cube.transform.localScale = new Vector3(aspectRatio * scaleFactor, scaleFactor, 0.001f); Quaternion rotation = ((Component)boombox).transform.rotation * Quaternion.Euler(0f, 180f, -90f); cube.transform.rotation = rotation; Vector3 scale = cube.transform.localScale; scale.y *= -1f; cube.transform.localScale = scale; Vector3 offset = ((Component)boombox).transform.forward * 0.18f; cube.transform.position = ((Component)boombox).transform.position - offset; cube.transform.parent = ((Component)boombox).transform; BoxCollider collider = cube.GetComponent<BoxCollider>(); if ((Object)(object)collider != (Object)null) { ((Collider)collider).enabled = false; } Renderer renderer = (Renderer)(object)cube.GetComponent<MeshRenderer>(); if ((Object)(object)renderer != (Object)null) { Material material = new Material(Shader.Find("HDRP/Lit")); material.mainTexture = (Texture)(object)texture; renderer.material = material; } } } finally { ((IDisposable)uwr)?.Dispose(); } } private Texture2D ResizeTexture(Texture2D originalTexture, int newWidth, int newHeight) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) RenderTexture temporary = RenderTexture.GetTemporary(newWidth, newHeight, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1); Graphics.Blit((Texture)(object)originalTexture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(newWidth, newHeight); val.ReadPixels(new Rect(0f, 0f, (float)newWidth, (float)newHeight), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } } public static VisualBoombox vbom; public static BoomboxItem boomboxItem = new BoomboxItem(); [HarmonyPatch(typeof(BoomboxItem), "Start")] [HarmonyPrefix] private static void Start(BoomboxItem __instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) vbom = new VisualBoombox(); Color color = Random.ColorHSV(); bool flag = true; Color color2 = Random.ColorHSV(); bool flag2 = true; string path = Path.Combine(Paths.PluginPath, "MushMods-MushBoomboxVisuals", "BoomboxImages"); string[] files = Directory.GetFiles(path); Random random = new Random(); int num = random.Next(0, files.Length); string text = files[num]; try { Image val = Image.FromFile(text); vbom.Start(vbom.GetTexture("file:///\\" + text, __instance)); } catch (Exception) { } if (flag) { ((Renderer)((Component)__instance).gameObject.GetComponent<MeshRenderer>()).materials[3].color = color; } if (flag2) { ((Renderer)((Component)__instance).gameObject.GetComponent<MeshRenderer>()).materials[1].color = color2; } boomboxItem = __instance; } } } 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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } }