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 RugratThemeSong v1.0.1
RugratThemeSong.dll
Decompiled 12 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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("RugratThemeSong")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RugratThemeSong")] [assembly: AssemblyTitle("RugratThemeSong")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 RugratThemeSong { internal static class RugratAudioSync { public static double SyncStartDspTime = -1.0; public static AudioClip SharedClip = null; private static bool isInitialized = false; public static void Initialize() { if (!isInitialized) { SyncStartDspTime = AudioSettings.dspTime + 0.1; isInitialized = true; } } public static void Reset() { SyncStartDspTime = -1.0; isInitialized = false; } } [HarmonyPatch(typeof(EnemyValuableThrower), "OnSpawn")] internal static class Patch_ThrowerLoopSound { [CompilerGenerated] private sealed class <LoadAndCacheClip>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public WWW www; public EnemyValuableThrower instance; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAndCacheClip>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = www; <>1__state = 1; return true; case 1: { <>1__state = -1; if (!string.IsNullOrEmpty(www.error)) { Plugin.Log.LogError((object)("Failed to load rugrat.ogg: " + www.error)); return false; } AudioClip audioClip = www.GetAudioClip(false, false, (AudioType)14); if ((Object)(object)audioClip == (Object)null) { Plugin.Log.LogError((object)"Failed to decode rugrat.ogg"); return false; } RugratAudioSync.SharedClip = audioClip; RugratAudioSync.Initialize(); AttachAndSync(instance, audioClip); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static void Postfix(EnemyValuableThrower __instance) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown if (!((Object)(object)((Component)__instance).gameObject.GetComponent<AudioSource>() != (Object)null) && !SemiFunc.MenuLevel() && !SemiFunc.RunIsLobbyMenu() && !SemiFunc.RunIsShop() && !SemiFunc.RunIsArena() && !((Object)(object)LevelGenerator.Instance == (Object)null) && LevelGenerator.Instance.Generated) { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "rugrat.ogg"); if (!File.Exists(text)) { Plugin.Log.LogWarning((object)"Missing rugrat.ogg"); } else if ((Object)(object)RugratAudioSync.SharedClip == (Object)null) { WWW www = new WWW("file://" + text); ((MonoBehaviour)__instance).StartCoroutine(LoadAndCacheClip(www, __instance)); } else { AttachAndSync(__instance, RugratAudioSync.SharedClip); } } } [IteratorStateMachine(typeof(<LoadAndCacheClip>d__1))] private static IEnumerator LoadAndCacheClip(WWW www, EnemyValuableThrower instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAndCacheClip>d__1(0) { www = www, instance = instance }; } private static void AttachAndSync(EnemyValuableThrower target, AudioClip clip) { RugratAudioSync.Initialize(); GameObject gameObject = ((Component)target).gameObject; if ((Object)(object)target.anim != (Object)null && (Object)(object)((Component)target.anim).gameObject != (Object)null) { gameObject = ((Component)target.anim).gameObject; } AudioSource val = gameObject.AddComponent<AudioSource>(); val.clip = clip; val.loop = true; val.playOnAwake = false; val.spatialBlend = 1f; val.minDistance = 1f; val.maxDistance = 20f; val.dopplerLevel = 0f; val.volume = 0.2f; val.rolloffMode = (AudioRolloffMode)0; ((Component)target).gameObject.AddComponent<RugratAudioController>().Initialize(val, clip, target); } } public class RugratAudioController : MonoBehaviour { private AudioSource audioSource; private AudioClip clip; private EnemyValuableThrower enemy; public void Initialize(AudioSource source, AudioClip audioClip, EnemyValuableThrower enemyRef) { audioSource = source; clip = audioClip; enemy = enemyRef; StartPlayback(); } private void Update() { //IL_008b: 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) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)audioSource == (Object)null || (Object)(object)clip == (Object)null || (Object)(object)enemy == (Object)null) { return; } if ((Object)(object)enemy.anim != (Object)null && (Object)(object)((Component)enemy.anim).gameObject != (Object)null && (Object)(object)((Component)audioSource).transform != (Object)(object)((Component)enemy.anim).transform) { Vector3 position = ((Component)enemy.anim).transform.position; Vector3 val = ((Component)audioSource).transform.position - position; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Component)audioSource).transform.position = position; } } if (((Behaviour)audioSource).enabled && !audioSource.isPlaying && (Object)(object)audioSource.clip != (Object)null && audioSource.time == 0f) { ResyncAudio(); } } private void StartPlayback() { if (!((Object)(object)audioSource == (Object)null) && !((Object)(object)clip == (Object)null)) { double syncStartDspTime = RugratAudioSync.SyncStartDspTime; if (AudioSettings.dspTime > syncStartDspTime) { double num = AudioSettings.dspTime - syncStartDspTime; double num2 = AudioSettings.dspTime + ((double)clip.length - num % (double)clip.length); audioSource.PlayScheduled(num2); } else { audioSource.PlayScheduled(syncStartDspTime); } } } private void ResyncAudio() { if (((Behaviour)audioSource).enabled && ((Component)audioSource).gameObject.activeInHierarchy) { if (RugratAudioSync.SyncStartDspTime > 0.0) { double num = AudioSettings.dspTime - RugratAudioSync.SyncStartDspTime; double num2 = RugratAudioSync.SyncStartDspTime + Math.Ceiling(num / (double)clip.length) * (double)clip.length; audioSource.PlayScheduled(num2); } else { audioSource.Play(); } } } private void OnDestroy() { if ((Object)(object)audioSource != (Object)null) { audioSource.Stop(); Object.Destroy((Object)(object)audioSource); } } } [BepInPlugin("FluxTeam.RugratThemeSong", "Rugrat Theme Song", "1.0.1")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static Harmony Harmony; public void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony = new Harmony("FluxTeam.RugratThemeSong"); Harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Rugrat Theme Song loaded."); } } }