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 RandomTheme v1.1.1
RandomTheme.dll
Decompiled 10 hours agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; [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("RandomTheme")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RandomTheme")] [assembly: AssemblyTitle("RandomTheme")] [assembly: AssemblyVersion("1.0.0.0")] [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 RandomTheme { [BepInPlugin("operation.randomtheme", "RandomTheme", "1.1.1")] public class Plugin : BaseUnityPlugin, IOnEventCallback { private const byte PlayEventCode = 173; private ConfigEntry<float> minMinutes; private ConfigEntry<float> maxMinutes; private ConfigEntry<float> volume; private ConfigEntry<string> fileName; private AudioSource source; private AudioClip clip; private Func<bool> runIsLevel; private bool lookedUp; private void Awake() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; minMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinMinutes", 4f, "Shortest wait between plays, in minutes. Only the host's value matters."); maxMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxMinutes", 6f, "Longest wait between plays, in minutes. Only the host's value matters."); volume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Volume", 1f, new ConfigDescription("Your own playback volume (0 to 1). 1 is the maximum.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); fileName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AudioFile", "theme.ogg", "Audio file in the same folder as this plugin (.ogg, .wav or .mp3)."); source = ((Component)this).gameObject.AddComponent<AudioSource>(); source.playOnAwake = false; source.loop = false; source.spatialBlend = 0f; ((MonoBehaviour)this).StartCoroutine(Run()); } private void OnEnable() { PhotonNetwork.AddCallbackTarget((object)this); } private void OnDisable() { PhotonNetwork.RemoveCallbackTarget((object)this); } public void OnEvent(EventData photonEvent) { if (photonEvent.Code == 173) { PlayLocal(); } } private IEnumerator Run() { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), fileName.Value); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)("Audio file not found: " + text)); yield break; } UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + text.Replace('\\', '/'), GetAudioType(text)); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load audio: " + req.error)); yield break; } clip = DownloadHandlerAudioClip.GetContent(req); } finally { ((IDisposable)req)?.Dispose(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("RandomTheme ready. Clip length: " + clip.length + "s")); while (true) { float num = Mathf.Min(minMinutes.Value, maxMinutes.Value); float num2 = Mathf.Max(minMinutes.Value, maxMinutes.Value); float num3 = Random.Range(num, num2) * 60f; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Next check in " + num3.ToString("F0") + " seconds.")); yield return (object)new WaitForSecondsRealtime(num3); if (!PhotonNetwork.IsMasterClient) { continue; } if (!InLevel()) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Not in a level, skipping this play."); continue; } try { PhotonNetwork.RaiseEvent((byte)173, (object)1, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not send play event: " + ex.Message)); } PlayLocal(); } } private void PlayLocal() { if (!((Object)(object)clip == (Object)null) && InLevel()) { source.volume = volume.Value; source.PlayOneShot(clip); } } private bool InLevel() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (!lookedUp) { lookedUp = true; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("SemiFunc"); if (!(type == null)) { MethodInfo method = type.GetMethod("RunIsLevel", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null) { runIsLevel = (Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), method); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Using SemiFunc.RunIsLevel() for level detection."); break; } } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("RunIsLevel lookup failed: " + ex.Message)); } if (runIsLevel == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"SemiFunc.RunIsLevel not found, using scene name fallback."); } } try { if (runIsLevel != null) { return runIsLevel(); } } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("RunIsLevel call failed: " + ex2.Message)); } Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name.ToLowerInvariant(); if (!text.Contains("menu") && !text.Contains("lobby") && !text.Contains("shop") && !text.Contains("arena") && !text.Contains("splash")) { return !text.Contains("boot"); } return false; } private static AudioType GetAudioType(string path) { string text = Path.GetExtension(path).ToLowerInvariant(); if (!(text == ".wav")) { if (text == ".mp3") { return (AudioType)13; } return (AudioType)14; } return (AudioType)20; } } }