Please disclose if your mod was created primarily 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 DisasterBox v1.1.0
BepinEx/plugins/DisasterBox.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GhoulMage.LethalCompany; using HarmonyLib; using LC_API.BundleAPI; 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("DisasterBox")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Mod for Lethal Company that changes the Jester's music by that of LENK64's.")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("DisasterBox")] [assembly: AssemblyTitle("DisasterBox")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.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 DisasterBox { public static class PluginInfo { public const string PLUGIN_GUID = "DisasterBox"; public const string PLUGIN_NAME = "DisasterBox"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace DisasterBoxMod { [BepInPlugin("ghoulmage.funny.disasterbox", "Disaster Box", "1.1.0")] [BepInProcess("Lethal Company.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DisasterBoxMod_Plugin : GhoulMagePlugin { public const string GUID = "ghoulmage.funny.disasterbox"; public const string NAME = "Disaster Box"; public const string VERSION = "1.1.0"; private const string ConfigName = "DisasterBox"; internal static ManualLogSource Log; internal static ConfigFile configFile; internal static ConfigEntry<bool> LoopThemeIfBoxIsOpen; internal static ConfigEntry<float> LoopAudioRange; internal static ConfigEntry<float> LoopVolume; internal static AudioClip DisasterBox_Theme_Flat; internal static AudioClip DisasterBox_Theme_PopUp; internal static AudioClip DisasterBox_Theme_Loop; protected override LethalGameVersions GameCompatibility => new LethalGameVersions(new string[3] { "v40", "v45", "v47" }); protected override Assembly AssemblyToPatch => Assembly.GetExecutingAssembly(); private static void LoadFromAssetBundle() { Log.LogInfo((object)"Loading Disaster Box music..."); if (LC_Info.HasLoadedMod("LC_API")) { if (Chainloader.PluginInfos["LC_API"].Metadata.Version.Major == 3) { BundleLoadVer3OrHigher(); } else { BundleLoadVersionUnder3(); } } else { BundleLoadVer3OrHigher(); } Log.LogInfo((object)"Disaster Box music loaded..!"); } private static void BundleLoadVersionUnder3() { DisasterBox_Theme_Flat = BundleLoader.GetLoadedAsset<AudioClip>("Assets/letha/disasterbox_1.ogg"); if ((Object)(object)DisasterBox_Theme_Flat == (Object)null) { Log.LogError((object)"Failed to load Disaster Box FLAT!"); return; } DisasterBox_Theme_Flat.LoadAudioData(); DisasterBox_Theme_PopUp = BundleLoader.GetLoadedAsset<AudioClip>("Assets/letha/disasterbox_2_popup.ogg"); if ((Object)(object)DisasterBox_Theme_PopUp == (Object)null) { Log.LogError((object)"Failed to load Disaster Box Popup!"); return; } DisasterBox_Theme_PopUp.LoadAudioData(); DisasterBox_Theme_Loop = BundleLoader.GetLoadedAsset<AudioClip>("Assets/letha/disasterbox_2_loop.ogg"); if ((Object)(object)DisasterBox_Theme_Loop == (Object)null) { Log.LogError((object)"Failed to load Disaster Box Loop!"); if (!LoopThemeIfBoxIsOpen.Value) { Log.LogInfo((object)"But looping is deactivated anyways so continuing..."); DisasterBox_Theme_Loop.LoadAudioData(); } } } private static void BundleLoadVer3OrHigher() { AssetBundle val = AssetBundle.LoadFromFile(Paths.PluginPath + "\\GhoulMage\\funny\\disasterbox"); DisasterBox_Theme_Flat = val.LoadAsset<AudioClip>("Assets/letha/disasterbox_1.ogg"); if ((Object)(object)DisasterBox_Theme_Flat == (Object)null) { Log.LogError((object)"Failed to load Disaster Box FLAT!"); return; } DisasterBox_Theme_Flat.LoadAudioData(); DisasterBox_Theme_PopUp = val.LoadAsset<AudioClip>("Assets/letha/disasterbox_2_popup.ogg"); if ((Object)(object)DisasterBox_Theme_PopUp == (Object)null) { Log.LogError((object)"Failed to load Disaster Box Popup!"); return; } DisasterBox_Theme_PopUp.LoadAudioData(); DisasterBox_Theme_Loop = val.LoadAsset<AudioClip>("Assets/letha/disasterbox_2_loop.ogg"); if ((Object)(object)DisasterBox_Theme_Loop == (Object)null) { Log.LogError((object)"Failed to load Disaster Box Loop!"); if (!LoopThemeIfBoxIsOpen.Value) { Log.LogInfo((object)"But looping is deactivated anyways so continuing..."); DisasterBox_Theme_Loop.LoadAudioData(); } } } private static void GetConfig() { LoopThemeIfBoxIsOpen = configFile.Bind<bool>("DisasterBox", "Loop Theme", true, "Loops the metal part of the song as long as the box is open?"); LoopAudioRange = configFile.Bind<float>("DisasterBox", "Loop Audio Range", 12.5f, "Audible range of the looping part."); LoopVolume = configFile.Bind<float>("DisasterBox", "Loop Volume", 0.65f, "Volume of the looping part, if enabled. Between 0 and 1."); } protected override void Initialize() { Log = ((BaseUnityPlugin)this).Logger; configFile = ((BaseUnityPlugin)this).Config; ((GhoulMagePlugin)this).Startup("ghoulmage.funny.disasterbox", "Disaster Box", "1.1.0", (Action)OnSuccesfulLoad, true); } private static void OnSuccesfulLoad() { GetConfig(); LoadFromAssetBundle(); } } public class DisasterBoxLoopBehaviour : MonoBehaviour { private AudioSource _audioSource; private void Awake() { _audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _audioSource.playOnAwake = false; _audioSource.Stop(); _audioSource.clip = DisasterBoxMod_Plugin.DisasterBox_Theme_Loop; _audioSource.rolloffMode = (AudioRolloffMode)0; float num = 0.5f + DisasterBoxMod_Plugin.LoopAudioRange.Value; _audioSource.maxDistance = num; _audioSource.minDistance = num * 0.25f; } public void Play() { _audioSource.Stop(); _audioSource.clip = DisasterBoxMod_Plugin.DisasterBox_Theme_Loop; _audioSource.volume = Mathf.Clamp01(DisasterBoxMod_Plugin.LoopVolume.Value); _audioSource.loop = true; _audioSource.Play(); } public void Stop() { _audioSource.Stop(); } } } namespace DisasterBoxMod.Patch { [HarmonyPatch(typeof(EnemyAI))] internal class EnemyAI_Patch { [HarmonyPatch("SwitchToBehaviourState")] [HarmonyPrefix] private static void AddLoopingOnTop(ref EnemyAI __instance, int stateIndex) { if (DisasterBoxMod_Plugin.LoopThemeIfBoxIsOpen.Value && __instance is JesterAI) { if (stateIndex == 2) { ((Component)__instance).GetComponentInChildren<DisasterBoxLoopBehaviour>().Play(); } else { ((Component)__instance).GetComponentInChildren<DisasterBoxLoopBehaviour>().Stop(); } } } } [HarmonyPatch(typeof(JesterAI))] internal class Jester_Patch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void CreateLooper(JesterAI __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (DisasterBoxMod_Plugin.LoopThemeIfBoxIsOpen.Value) { GameObject val = new GameObject("Disaster Box Loop"); val.transform.parent = ((Component)__instance).transform; val.transform.localPosition = Vector3.zero; val.AddComponent<DisasterBoxLoopBehaviour>(); } } [HarmonyPatch("SetJesterInitialValues")] [HarmonyPostfix] private static void ReplaceMusic(JesterAI __instance) { __instance.popUpTimer = 39.5f; __instance.popGoesTheWeaselTheme = DisasterBoxMod_Plugin.DisasterBox_Theme_Flat; __instance.popUpSFX = DisasterBoxMod_Plugin.DisasterBox_Theme_PopUp; } } }