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 JumpScream v1.0.16
JumpScream.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JumpScream; using LCSoundTool; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; using moose.dev; [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("JumpScream")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("JumpScream")] [assembly: AssemblyTitle("JumpScream")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } 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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace moose.dev { [BepInPlugin("devmoose.jumpscream", "JumpScream", "1.0.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class JumpScreamPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <DisplayForDuration>d__22 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public JumpScreamPlugin <>4__this; private bool <hasWaited>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DisplayForDuration>d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown int num = <>1__state; JumpScreamPlugin jumpScreamPlugin = <>4__this; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; } else { <>1__state = -1; <hasWaited>5__2 = false; jumpScreamPlugin.textObject.SetActive(true); } if (<hasWaited>5__2) { jumpScreamPlugin.textObject.SetActive(false); return false; } <hasWaited>5__2 = true; <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string modGUID = "devmoose.jumpscream"; public const string modName = "JumpScream"; public const string modVersion = "1.0.0.0"; public static JumpScreamPlugin Instance; internal static ManualLogSource Log; private readonly Harmony harmony = new Harmony("devmoose.jumpscream"); public static List<AudioClip> Screams = new List<AudioClip>(); public static string ScreamsDirectory; private static string[] AllowedSoundExtensions = new string[3] { ".mp3", ".wav", ".ogg" }; public static ConfigEntry<int> ScreamTriggerPercent; public static ConfigEntry<double> ScreamTimeoutSeconds; public static Queue<AudioClip> MusicBoxClips; public static AssetBundle Assets; public GameObject textObject; public TextMeshProUGUI textComponent; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Log = Logger.CreateLogSource("devmoose.jumpscream"); Log.LogMessage((object)"Applying patch."); LoadConfig(); LoadAssetBundle(); LoadScreams(); ChangeMusicBox(); LoadScrap(); harmony.PatchAll(); Log.LogMessage((object)"Loaded succesfully."); } private void LoadConfig() { ScreamTriggerPercent = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "ScreamTriggerPercent", 5, "The chance, in percent (0-100), that a door action will trigger a scream. Defaults to 5 percent."); ScreamTimeoutSeconds = ((BaseUnityPlugin)this).Config.Bind<double>("Config", "ScreamTimeout", 30.0, "The minimum amount of seconds between screams. Defaults to 30 seconds."); Log.LogMessage((object)"Configuration loaded."); Log.LogDebug((object)$"ScreamTriggerPercent: {ScreamTriggerPercent.Value}"); Log.LogDebug((object)$"ScreamTimeout: {ScreamTimeoutSeconds.Value}"); } private void LoadAssetBundle() { Assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "peanutbutter")); } private void ChangeMusicBox() { MusicBoxClips = new Queue<AudioClip>(); string[] array = new string[9] { "Music1.mp3", "Music2.mp3", "Music3.mp3", "Music4.mp3", "Music5.mp3", "Music6.mp3", "Music7.mp3", "Music8.mp3", "Music9.mp3" }; foreach (string text in array) { AudioClip val = Assets.LoadAsset<AudioClip>("Assets/" + text); Log.LogDebug((object)("Loaded " + ((Object)val).name)); ((Object)val).name = text; MusicBoxClips.Enqueue(val); } foreach (AudioClip item in MusicBoxClips.ToList()) { SoundTool.ReplaceAudioClip("RecordPlayerJazz", item, 1f / (float)MusicBoxClips.Count); } } private void LoadScreams() { if (ScreamsDirectory == null) { ScreamsDirectory = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location)); Log.LogMessage((object)("Sounds directory set to: " + ScreamsDirectory)); } if (!Directory.Exists(ScreamsDirectory)) { Log.LogMessage((object)"Sounds directory not found, creating"); Directory.CreateDirectory(ScreamsDirectory); } foreach (string item in from file in Directory.GetFiles(ScreamsDirectory) where AllowedSoundExtensions.Any(file.ToLower().EndsWith) select file) { try { string fileName = Path.GetFileName(item); AudioClip audioClip = SoundTool.GetAudioClip(ScreamsDirectory, fileName); ((Object)audioClip).name = "JumpScream"; Screams.Add(audioClip); Log.LogDebug((object)("Loaded scream: " + item)); } catch (Exception) { Log.LogError((object)("Failed to load scream: " + item)); } } } private void LoadScrap() { int num = 60; Item val = Assets.LoadAsset<Item>("Assets/PeanutButter.asset"); PeanutButterScript peanutButterScript = val.spawnPrefab.AddComponent<PeanutButterScript>(); ((GrabbableObject)peanutButterScript).grabbable = true; ((GrabbableObject)peanutButterScript).isInFactory = true; ((GrabbableObject)peanutButterScript).isInShipRoom = true; ((GrabbableObject)peanutButterScript).scrapPersistedThroughRounds = true; ((GrabbableObject)peanutButterScript).itemProperties = val; NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Items.RegisterScrap(val, num, (LevelTypes)(-1)); Item val2 = Assets.LoadAsset<Item>("Assets/BirthdayCake.asset"); BirthdayCakeMusic birthdayCakeMusic = val2.spawnPrefab.AddComponent<BirthdayCakeMusic>(); ((GrabbableObject)birthdayCakeMusic).grabbable = true; ((GrabbableObject)birthdayCakeMusic).isInFactory = true; ((GrabbableObject)birthdayCakeMusic).isInShipRoom = true; ((GrabbableObject)birthdayCakeMusic).scrapPersistedThroughRounds = true; ((GrabbableObject)birthdayCakeMusic).itemProperties = val2; NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab); Items.RegisterScrap(val2, num, (LevelTypes)(-1)); } public void DisplayText(string message) { if ((Object)(object)textObject == (Object)null) { ConstructGameObject(); } ((TMP_Text)textComponent).text = message; ((MonoBehaviour)CoroutineRunner.Instance).StartCoroutine(DisplayForDuration()); } [IteratorStateMachine(typeof(<DisplayForDuration>d__22))] private IEnumerator DisplayForDuration() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DisplayForDuration>d__22(0) { <>4__this = this }; } public void ConstructGameObject() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0082: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Systems/UI/Canvas"); if ((Object)(object)val == (Object)null) { Log.LogError((object)"Failed to find Canvas GameObject"); return; } textObject = new GameObject("JumpScreamText"); textObject.SetActive(false); RectTransform obj = textObject.AddComponent<RectTransform>(); ((Transform)obj).SetParent(val.transform); ((Transform)obj).SetAsLastSibling(); textObject.layer = LayerMask.NameToLayer("UI"); obj.anchoredPosition3D = new Vector3(0f, 0f, 0f); ((Transform)obj).localScale = new Vector3(1f, 1f, 1f); obj.anchorMin = new Vector2(0.5f, 0.5f); obj.anchorMax = new Vector2(0.5f, 0.5f); obj.sizeDelta = new Vector2(500f, 100f); textComponent = textObject.AddComponent<TextMeshProUGUI>(); TMP_FontAsset val2 = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "b")); if ((Object)(object)val2 == (Object)null) { Log.LogError((object)"Font 'b' not found"); return; } ((TMP_Text)textComponent).font = val2; Material material = ((TMP_Asset)val2).material; if ((Object)(object)material == (Object)null) { Log.LogError((object)"FontMaterial not found"); return; } ((TMP_Text)textComponent).fontMaterial = material; ((Graphic)textComponent).color = new Color(0.6462264f, 0.95584375f, 1f, 47f / 85f); ((TMP_Text)textComponent).fontSize = 18f; ((TMP_Text)textComponent).horizontalAlignment = (HorizontalAlignmentOptions)2; ((TMP_Text)textComponent).enableWordWrapping = true; } } public class CoroutineRunner : MonoBehaviour { private static CoroutineRunner instance; public static CoroutineRunner Instance { get { //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_0027: Expected O, but got Unknown if ((Object)(object)instance == (Object)null) { GameObject val = new GameObject("JumpScreamCoroutineRunner"); instance = val.AddComponent<CoroutineRunner>(); Object.DontDestroyOnLoad((Object)val); } return instance; } } } [HarmonyPatch(typeof(BoomboxItem), "Start")] internal class BoomboxItem_Start { [HarmonyPostfix] private static void Postfix(BoomboxItem __instance) { __instance.musicAudios = JumpScreamPlugin.MusicBoxClips.ToArray(); } } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] internal class BoomboxItem_StartMusic { [HarmonyPostfix] private static void Postfix(BoomboxItem __instance, bool startMusic, ref int ___timesPlayedWithoutTurningOff) { if (startMusic) { Queue<AudioClip> musicBoxClips = JumpScreamPlugin.MusicBoxClips; AudioClip val = musicBoxClips.Dequeue(); musicBoxClips.Enqueue(val); __instance.musicAudios = musicBoxClips.ToArray(); __instance.boomboxAudio.clip = val; __instance.boomboxAudio.pitch = 1f; __instance.boomboxAudio.volume = 1f; __instance.boomboxAudio.Play(); } else if (__instance.isPlayingMusic) { __instance.boomboxAudio.Stop(); __instance.boomboxAudio.PlayOneShot(__instance.stopAudios[Random.Range(0, __instance.stopAudios.Length)]); ___timesPlayedWithoutTurningOff = 0; } ((GrabbableObject)__instance).isBeingUsed = startMusic; __instance.isPlayingMusic = startMusic; } } [HarmonyPatch(typeof(AudioSource))] internal class JumpScreamDoors { private static string[] doors = new string[2] { "DoorOpen", "EntranceTeleport" }; public static DateTimeOffset lastScreamPlayed; public static object screamLock = new object(); public static int lastPlayedIndex = -1; [HarmonyPatch("PlayOneShot", new Type[] { typeof(AudioClip) })] [HarmonyPatch("PlayOneShot", new Type[] { typeof(AudioClip), typeof(float) })] [HarmonyPostfix] public static void RandomAudioTrigger(AudioSource __instance, AudioClip clip) { string audioTrigger = ((clip != null) ? ((Object)clip).name : null) ?? ""; DateTimeOffset now = DateTimeOffset.Now; if (((clip == null) ? null : ((Object)clip).name?.Equals("JumpScream", StringComparison.OrdinalIgnoreCase)).GetValueOrDefault() || !(now >= lastScreamPlayed.AddSeconds(JumpScreamPlugin.ScreamTimeoutSeconds.Value)) || !doors.Any((string door) => audioTrigger.Contains(door, StringComparison.OrdinalIgnoreCase)) || new Random().Next(100) >= JumpScreamPlugin.ScreamTriggerPercent.Value || JumpScreamPlugin.Screams.Count <= 0) { return; } int num = -1; do { num = new Random().Next(JumpScreamPlugin.Screams.Count); } while (num == lastPlayedIndex); AudioClip val = JumpScreamPlugin.Screams[num]; try { lock (screamLock) { HUDManager.Instance.UIAudio.PlayOneShot(val, 1f); } lastScreamPlayed = now; lastPlayedIndex = num; } catch { } } } } namespace JumpScream { internal class BirthdayCakeMusic : PhysicsProp { private bool isPlaying; private AudioSource? itemAudio; public override void Start() { ((GrabbableObject)this).Start(); itemAudio = ((Component)this).gameObject.GetComponent<AudioSource>(); if ((Object)(object)itemAudio.clip == (Object)null) { AudioClip clip = JumpScreamPlugin.Assets.LoadAsset<AudioClip>("Assets/birthday.mp3"); itemAudio.clip = clip; itemAudio.pitch = 1f; itemAudio.volume = 1f; } } public override void ItemActivate(bool used, bool buttonDown = true) { ((GrabbableObject)this).ItemActivate(used, buttonDown); if (Object.op_Implicit((Object)(object)((GrabbableObject)this).playerHeldBy) && (Object)(object)itemAudio != (Object)null) { if (buttonDown && !isPlaying) { itemAudio.Play(); isPlaying = true; } else if (buttonDown && isPlaying) { itemAudio.Stop(); isPlaying = false; } } } public override void OnPlaceObject() { ((GrabbableObject)this).OnPlaceObject(); Stop(); } public override void DiscardItem() { ((GrabbableObject)this).DiscardItem(); Stop(); } public override void OnHitGround() { ((GrabbableObject)this).OnHitGround(); Stop(); } public override void PocketItem() { ((GrabbableObject)this).PocketItem(); Stop(); } private void Stop() { AudioSource? obj = itemAudio; if (obj != null && obj.isPlaying) { itemAudio.Stop(); isPlaying = false; } } } internal class PeanutButterScript : PhysicsProp { private int spawnChance = 10; internal static ManualLogSource Log; internal string[] SpawnMessages = new string[3] { "The smell of peanut butter permeates the air.", "Holding the peanut butter, you hear a faint rumble. Was that your stomach?", "The magical aroma of peanut butter entices you, and maybe someone else." }; internal int Next; public PeanutButterScript() { Log = Logger.CreateLogSource("devmoose.jumpscream"); } public override void OnGainedOwnership() { CheckSpawn(); ((NetworkBehaviour)this).OnGainedOwnership(); } private void CheckSpawn() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (Random.Range(0, 1000) < spawnChance) { _ = RoundManager.Instance; Object.FindAnyObjectByType<NetworkManager>(); Vector3 position = GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length - 1)].transform.position; SpawnableEnemyWithRarity val = (from enemy in GetEnemies() where enemy.enemyType.enemyName.Contains("mouthdog", StringComparison.OrdinalIgnoreCase) select enemy).FirstOrDefault(); if (val != null) { Object.Instantiate<GameObject>(val.enemyType.enemyPrefab, position, Quaternion.Euler(Vector3.zero)).gameObject.GetComponentInChildren<NetworkObject>().Spawn(true); JumpScreamPlugin.Instance.DisplayText(SpawnMessages[Next]); spawnChance /= 2; Next++; Next %= SpawnMessages.Length; } } if (spawnChance < 1) { spawnChance = 1; } spawnChance *= 2; } private static List<SpawnableEnemyWithRarity> GetEnemies() { return (from x in GameObject.Find("Terminal").GetComponentInChildren<Terminal>().moonsCatalogueList.SelectMany((SelectableLevel x) => x.Enemies.Concat(x.DaytimeEnemies).Concat(x.OutsideEnemies)) where x != null && (Object)(object)x.enemyType != (Object)null && ((Object)x.enemyType).name != null select x).GroupBy((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name, (string k, IEnumerable<SpawnableEnemyWithRarity> v) => v.First()).ToList(); } } }