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 RevisitStingers v1.3.0
RevisitStingers.dll
Decompiled a year agousing System; using System.Collections; 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 HarmonyLib; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; 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("RevisitStingers")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Replay interior stingers when they are somewhere they shouldn't be")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+f644f8d4fe8034b037e8e6b067ab8a7c07785bc7")] [assembly: AssemblyProduct("RevisitStingers")] [assembly: AssemblyTitle("RevisitStingers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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 RevisitStingers { internal static class LobbyCompatibility { internal static void Init() { PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.revisitstingers", Version.Parse("1.3.0"), (CompatibilityLevel)0, (VersionStrictness)0); } } [BepInPlugin("butterystancakes.lethalcompany.revisitstingers", "Revisit Stingers", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.revisitstingers"; internal const string PLUGIN_NAME = "Revisit Stingers"; internal const string PLUGIN_VERSION = "1.3.0"; internal static ConfigEntry<float> configMaxRarity; internal static ConfigEntry<float> configInterruptMusic; internal static ConfigEntry<float> configFallbackChance; internal static ManualLogSource Logger; private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility"; private void Awake() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility")) { Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected"); LobbyCompatibility.Init(); } AcceptableValueRange<float> val = new AcceptableValueRange<float>(0f, 1f); string text = " (0 = never, 1 = guaranteed, or anything in between - 0.5 = 50% chance)"; configMaxRarity = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "MaxRarity", 0.16f, new ConfigDescription("The highest spawn chance (0.16 = 16%) an interior can have on a specific moon for it to be considered \"rare\". Rare interiors will always play the stinger.", (AcceptableValueBase)(object)val, Array.Empty<object>())); configInterruptMusic = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "InterruptMusic", 0f, new ConfigDescription("The percentage chance for the stinger to play if you enter the building while an ambient music track is playing." + text, (AcceptableValueBase)(object)val, Array.Empty<object>())); configFallbackChance = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "FallbackChance", 0f, new ConfigDescription("The percentage chance that the stinger will still play, even if you are in a common interior and there is no music playing on the surface." + text, (AcceptableValueBase)(object)val, Array.Empty<object>())); new Harmony("butterystancakes.lethalcompany.revisitstingers").PatchAll(); Logger.LogInfo((object)"Revisit Stingers v1.3.0 loaded"); } } [HarmonyPatch] internal class RevisitStingersPatches { [HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")] [HarmonyPrefix] private static void EntranceTeleportPreTeleportPlayer(EntranceTeleport __instance, bool ___checkedForFirstTime) { if (ReplayStinger.beenInsideThisRound || !__instance.FindExitPoint()) { return; } ReplayStinger.beenInsideThisRound = true; if (!__instance.isEntranceToBuilding || ___checkedForFirstTime || !ES3.Load<bool>($"PlayedDungeonEntrance{RoundManager.Instance.currentDungeonType}", "LCGeneralSaveData", false)) { return; } try { AudioClip firstTimeAudio = RoundManager.Instance.dungeonFlowTypes[RoundManager.Instance.currentDungeonType].firstTimeAudio; if ((Object)(object)firstTimeAudio != (Object)null && ReplayStinger.StingerShouldReplay()) { ((MonoBehaviour)__instance).StartCoroutine(ReplayStinger.DelayedStinger(firstTimeAudio)); } } catch (Exception arg) { Plugin.Logger.LogWarning((object)$"Ran into an error attempting to replay stinger - this is likely due to an incompatibility with modded content\n{arg}"); } } [HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")] [HarmonyPostfix] private static void StartOfRoundPostSetShipReadyToLand() { ReplayStinger.beenInsideThisRound = false; } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void StartOfRoundPostAwake() { ReplayStinger.beenInsideThisRound = false; } [HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")] [HarmonyPostfix] private static void PostTeleportPlayerOutWithInverseTeleporter(int playerObj) { if ((Object)(object)StartOfRound.Instance.allPlayerScripts[playerObj] != (Object)(object)GameNetworkManager.Instance.localPlayerController || ReplayStinger.beenInsideThisRound) { return; } ReplayStinger.beenInsideThisRound = true; try { AudioClip firstTimeAudio = RoundManager.Instance.dungeonFlowTypes[RoundManager.Instance.currentDungeonType].firstTimeAudio; if ((Object)(object)firstTimeAudio != (Object)null && (ReplayStinger.StingerShouldReplay() || !ES3.Load<bool>($"PlayedDungeonEntrance{RoundManager.Instance.currentDungeonType}", "LCGeneralSaveData", false))) { ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(ReplayStinger.DelayedStinger(firstTimeAudio)); if (ReplayStinger.IsVanillaDungeon()) { ES3.Save<bool>($"PlayedDungeonEntrance{RoundManager.Instance.currentDungeonType}", true, "LCGeneralSaveData"); } } } catch (Exception arg) { Plugin.Logger.LogWarning((object)$"Ran into an error attempting to replay stinger - this is likely due to an incompatibility with modded content\n{arg}"); } } } internal class ReplayStinger { internal static bool beenInsideThisRound; internal static bool StingerShouldReplay() { if (Plugin.configInterruptMusic.Value > 0f && SoundManager.Instance.musicSource.isPlaying && Random.value <= Plugin.configInterruptMusic.Value) { return true; } IntWithRarity[] dungeonFlowTypes = StartOfRound.Instance.currentLevel.dungeonFlowTypes; if (dungeonFlowTypes != null && dungeonFlowTypes.Length > 1 && (!StartOfRound.Instance.isChallengeFile || !ES3.Load<bool>("FinishedChallenge", "LCChallengeFile", false))) { int num = 0; float num2 = 0f; IntWithRarity[] dungeonFlowTypes2 = StartOfRound.Instance.currentLevel.dungeonFlowTypes; foreach (IntWithRarity val in dungeonFlowTypes2) { if (val.id == RoundManager.Instance.currentDungeonType) { num = val.rarity; } num2 += (float)val.rarity; } if (num > 0 && (float)num / num2 <= Plugin.configMaxRarity.Value) { return true; } } if (Plugin.configFallbackChance.Value > 0f) { return Random.value <= Plugin.configFallbackChance.Value; } return false; } internal static bool IsVanillaDungeon() { if (RoundManager.Instance.currentDungeonType != 0 && RoundManager.Instance.currentDungeonType != 1) { return RoundManager.Instance.currentDungeonType == 4; } return true; } internal static IEnumerator DelayedStinger(AudioClip stinger) { yield return (object)new WaitForSeconds(0.6f); HUDManager.Instance.UIAudio.PlayOneShot(stinger); } } public static class PluginInfo { public const string PLUGIN_GUID = "RevisitStingers"; public const string PLUGIN_NAME = "RevisitStingers"; public const string PLUGIN_VERSION = "1.3.0"; } }