Decompiled source of Schizophrenia v0.1.1
Schizophrenia.dll
Decompiled 29 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using AudioImportLib; using BoneLib; using BoneLib.BoneMenu; using BoneLib.Notifications; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Bonelab; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Audio; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.PuppetMasta; using Il2CppTMPro; using MelonLoader; using MelonLoader.Utils; using Schizophrenia; using Schizophrenia.Severitys; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(SchizophreniaMod), "Schizophrenia", "0.1.1", "matrix", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: AssemblyTitle("schizophrenia")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("matrix")] [assembly: AssemblyProduct("schizophrenia")] [assembly: AssemblyCopyright("Copyright © HP 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ba6b392f-cdcc-47e0-9918-fd905ca28729")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace Schizophrenia { public class SchizophreniaMod : MelonMod { private Page schizophreniaPage; private Page spatialSoundOptionsPage; private Page headSoundOptionsPage; private Page entitySoundOptionsPage; private Page medicationSoundOptionsPage; private Page severity3HeadSoundOptionsPage; private Page severity3DisappearSoundOptionsPage; private Page entityImageOptionsPage; private Page severity3EntityImageOptionsPage; private readonly HashSet<string> registeredSoundOptions = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private readonly HashSet<string> registeredEntityImageOptions = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private readonly HashSet<string> registeredSeverity3EntityImageOptions = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private bool schizophreniaEnabled; private int currentSeverity; private float currentSeverityEndTime; private bool severity1AudioEnabled = true; private bool severityDelusionsEnabled = true; private bool gameMusicMuteEnabled = true; private bool medicationSoundEnabled = true; private const float MinimumNormalcyDurationSeconds = 300f; private const float MaximumNormalcyDurationSeconds = 900f; private const float MinimumSeverityDurationSeconds = 300f; private const float MaximumSeverityDurationSeconds = 600f; private static readonly string[] Delusions = new string[15] { "The object you touched made you unclean before the Holy Lamb of God", "They are coming for you now", "Demons are possessing you", "They are all watching you", "The chip the CIA put inside your brain is making this happen", "They live inside the walls around you", "They all can see you", "Run before they catch you for eternity", "Your family is conspiring against you", "Blood is needed for your true repentance", "Medication only makes it worse", "Don't stand still, they can see you that way", "Breathe quiet, they can hear you", "Beings are here", "Never close your eyes, they move when you don't look" }; private bool timerRunning; private int timerVersion; private int previousDelusionIndex = -1; private float pendingSeverityTimeAdjustmentSeconds; private BoolElement schizophreniaToggleElement; private bool originalMusicVolumeCaptured; private bool musicMuteFailureLogged; private float originalMusicVolume; private severities1 severities1; private severities2 severities2; private severities3 severities3; public override void OnInitializeMelon() { severities1 = new severities1(); severities2 = new severities2(); severities3 = new severities3(severities2); fightprotector.Initialize(((MelonBase)this).HarmonyInstance); severities3.HeadAudioClipLoaded += AddSeverity3SpecificSoundOption; severities3.DisappearAudioClipLoaded += AddSeverity3DisappearSoundOption; severities3.EntityImageLoaded += AddSeverity3EntityImageOption; CreateBoneMenu(); Hooking.OnLevelUnloaded += StopSeverity3FakeFight; severities2.LoadAudioFiles(); severities3.LoadAudioFiles(); severities3.LoadEntityEventAudioFiles(); if (schizophreniaEnabled) { StartSeverityCycle(); } } public override void OnUpdate() { audioplaceratio.Update(); SchizophreniaAudio.Update(); if (schizophreniaEnabled && gameMusicMuteEnabled) { KeepGameMusicMuted(); } severities2?.Update(); severities3?.Update(); } public override void OnDeinitializeMelon() { Hooking.OnLevelUnloaded -= StopSeverity3FakeFight; severities3?.StopFakeFightNow(); RestoreGameMusicVolume(); } private void StopSeverity3FakeFight() { severities3?.StopFakeFightNow(); } private void CreateBoneMenu() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06d7: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_071f: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Unknown result type (might be due to invalid IL or missing references) string text = "<color=#FF0000>S</color><color=#FF7F00>c</color><color=#FFFF00>h</color><color=#00FF00>i</color><color=#00FFFF>z</color><color=#4DB8FF>o</color><color=#8B00FF>p</color><color=#FF0000>h</color><color=#FF7F00>r</color><color=#FFFF00>e</color><color=#00FF00>n</color><color=#00FFFF>i</color><color=#8B00FF>a</color>"; schizophreniaPage = Page.Root.CreatePage(text, Color.white, 0, true); schizophreniaToggleElement = schizophreniaPage.CreateBool("Schizophrenia", Color.white, schizophreniaEnabled, (Action<bool>)ToggleSchizophrenia); schizophreniaPage.CreateFunction("Take Your Meds", Color.white, (Action)TakeYourMeds); Page obj = schizophreniaPage.CreatePage("Developer Options", Color.white, 0, true); Page obj2 = obj.CreatePage("Severity Controls", Color.white, 0, true); obj2.CreateFunction("Start Severity 1 Now", Color.white, (Action)delegate { StartDevelopmentSeverity(1); }); obj2.CreateFunction("Start Severity 2 Now", Color.white, (Action)delegate { StartDevelopmentSeverity(2); }); obj2.CreateFunction("Start Severity 3 Now", Color.white, (Action)delegate { StartDevelopmentSeverity(3); }); obj2.CreateFunction("Return to Normal", Color.white, (Action)RestartNormalCycleNow); obj2.CreateFunction("Advance Severity Timer 30 Seconds", Color.white, (Action)delegate { ShiftCurrentSeverityTimer(-30f); }); obj2.CreateFunction("Rewind Severity Timer 30 Seconds", Color.white, (Action)delegate { ShiftCurrentSeverityTimer(30f); }); Page obj3 = obj.CreatePage("Global Effects", Color.white, 0, true); obj3.CreateBool("Severity Delusion Notifications", Color.white, severityDelusionsEnabled, (Action<bool>)SetSeverityDelusionsEnabled); obj3.CreateBool("Mute Game OST While Mod Is On", Color.white, gameMusicMuteEnabled, (Action<bool>)SetGameMusicMuteEnabled); obj3.CreateBool("Audio4 on Take Your Meds", Color.white, medicationSoundEnabled, (Action<bool>)SetMedicationSoundEnabled); obj3.CreateFunction("Send Random Delusion Now", Color.white, (Action)delegate { ShowSeverityDelusion((currentSeverity <= 0) ? 1 : currentSeverity, force: true); }); obj3.CreateFunction("Play Random Audio4 Medication Sound Now", Color.white, (Action)delegate { severities2.PlayMedicationSound(); }); obj3.CreateFunction("Fade Out All Mod Audio Now", Color.white, (Action)delegate { SchizophreniaAudio.FadeOutCurrent(); }); obj3.CreateFunction("Clear All Severity Entities Now", Color.white, (Action)ClearAllSeverityEntities); Page obj4 = obj.CreatePage("Severity 1 Features", Color.white, 0, true); obj4.CreateBool("Automatic NPC Audio", Color.white, severity1AudioEnabled, (Action<bool>)ToggleSeverity1Audio); obj4.CreateFunction("Play Random NPC Sound Now", Color.white, (Action)delegate { severities1.PlayRandomNpcSoundNow(); }); obj4.CreateFunction("Play Ford Big Pain Now", Color.white, (Action)delegate { severities1.PlayFordBigPainNow(); }); Page obj5 = obj.CreatePage("Severity 2 Features", Color.white, 0, true); obj5.CreateBool("Contrast / Saturation", Color.white, true, (Action<bool>)severities2.SetVisualsEnabled); obj5.CreateBool("Radial Menu: Error", Color.white, true, (Action<bool>)severities2.SetRadialMenuErrorEnabled); obj5.CreateBool("NO ESCAPE Clipboards", Color.white, true, (Action<bool>)severities2.SetClipboardMessageEnabled); obj5.CreateBool("Audio (Around You)", Color.white, true, (Action<bool>)severities2.SetSpatialAudioEnabled); obj5.CreateBool("Audio1 (Inside Your Head)", Color.white, true, (Action<bool>)severities2.SetHeadAudioEnabled); obj5.CreateBool("Severity 2 Entity Images", Color.white, true, (Action<bool>)severities2.SetEntityImagesEnabled); obj5.CreateBool("Audio2 on Entity Disappear", Color.white, true, (Action<bool>)severities2.SetEntityAudioEnabled); obj5.CreateFunction("Play Random Audio Sound Now", Color.white, (Action)delegate { severities2.PlayRandomSpatialSoundNow(); }); obj5.CreateFunction("Play Random Audio1 Sound Now", Color.white, (Action)delegate { severities2.PlayRandomHeadSoundNow(); }); obj5.CreateFunction("Play Random Audio2 Sound Now", Color.white, (Action)delegate { severities2.PlayRandomEntitySoundNow(); }); obj5.CreateFunction("Spawn Severity 2 Entity Now", Color.white, (Action)delegate { severities2.SpawnEntityImageForDeveloper(); }); obj5.CreateFunction("Apply NO ESCAPE to Clipboards Now", Color.white, (Action)delegate { severities2.ApplyClipboardMessageNow(); }); Page obj6 = obj.CreatePage("Severity 3 Features", Color.white, 0, true); obj6.CreateBool("Contrast / Saturation / Red Tint", Color.white, true, (Action<bool>)severities3.SetVisualsEnabled); obj6.CreateBool("Radial Menu: NO ESCAPE FOR YOU", Color.white, true, (Action<bool>)severities3.SetRadialMenuWordsEnabled); obj6.CreateBool("Continuous Audio5 In-Head", Color.white, true, (Action<bool>)severities3.SetHeadAudioEnabled); obj6.CreateBool("Severity 3 Entity Waves", Color.white, true, (Action<bool>)severities3.SetEntitySpawnsEnabled); obj6.CreateBool("Automatic NPC Waves (30-60 sec)", Color.white, true, (Action<bool>)severities3.SetNpcWavesEnabled); obj6.CreateBool("Audio3 Disappear Sounds", Color.white, true, (Action<bool>)severities3.SetDisappearSoundsEnabled); obj6.CreateBool("Automatic Flash Images (5-15 sec)", Color.white, true, (Action<bool>)severities3.SetFlashImagesEnabled); obj6.CreateFunction("Flash Menu Phrase Now", Color.white, (Action)delegate { severities3.FlashMenuPhraseNow(); }); obj6.CreateFunction("Play Random Audio5 Sound Now", Color.white, (Action)delegate { severities3.PlayRandomHeadSoundNow(); }); obj6.CreateFunction("Spawn Severity 3 Entity Wave Now", Color.white, (Action)delegate { severities3.SpawnEntityWaveNow(); }); obj6.CreateFunction("Play Random Audio3 Sound Now", Color.white, (Action)delegate { severities3.PlayRandomDisappearSoundNow(); }); obj6.CreateFunction("Flash Random Image Now", Color.white, (Action)delegate { severities3.FlashRandomImageNow(); }); obj6.CreateFunction("Start NPC Wave Now", Color.white, (Action)delegate { severities3.StartFakeFightNow(); }); obj6.CreateFunction("Stop / Clear NPC Wave Now", Color.white, (Action)delegate { severities3.StopFakeFightNow(); }); Page val = obj.CreatePage("Initiate Specific Entity", Color.white, 0, true); entityImageOptionsPage = val.CreatePage("Severity 2 PNGs (entities)", Color.white, 0, true); entityImageOptionsPage.CreateFunction("Load / Refresh Severity 2 Entity List", Color.white, (Action)delegate { severities2.LoadEntityImageOptions(); }); severity3EntityImageOptionsPage = val.CreatePage("Severity 3 PNGs (entities1)", Color.white, 0, true); severity3EntityImageOptionsPage.CreateFunction("Load / Refresh Severity 3 Entity List", Color.white, (Action)delegate { severities3.LoadEntityImageOptions(); }); Page val2 = obj.CreatePage("Initiate Specific Sound", Color.white, 0, true); val2.CreateFunction("Load / Refresh All Sound Lists", Color.white, (Action)RefreshSpecificSoundList); spatialSoundOptionsPage = val2.CreatePage("Audio (Around You)", Color.white, 0, true); headSoundOptionsPage = val2.CreatePage("Audio1 (Inside Your Head)", Color.white, 0, true); entitySoundOptionsPage = val2.CreatePage("Audio2 (Severity 2 Entity Sounds)", Color.white, 0, true); medicationSoundOptionsPage = val2.CreatePage("Audio4 (Medication UI Sounds)", Color.white, 0, true); severity3DisappearSoundOptionsPage = val2.CreatePage("Audio3 (Severity 3 Disappear Sounds)", Color.white, 0, true); severity3HeadSoundOptionsPage = val2.CreatePage("Audio5 (Severity 3 In-Head)", Color.white, 0, true); severities2.AudioClipLoaded += AddSpecificSoundOption; severities2.EntityAudioClipLoaded += AddEntitySoundOption; severities2.MedicationAudioClipLoaded += AddMedicationSoundOption; severities2.EntityImageLoaded += AddEntityImageOption; severities2.LoadEntityImageOptions(); severities3.LoadEntityImageOptions(); } private void AddSpecificSoundOption(AudioClip clip, bool playInsideHead) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null) { return; } string item = (playInsideHead ? "Audio1|" : "Audio|") + ((Object)clip).name; if (!registeredSoundOptions.Add(item)) { return; } Page val = (playInsideHead ? headSoundOptionsPage : spatialSoundOptionsPage); if (val != null) { val.CreateFunction(((Object)clip).name, Color.white, (Action)delegate { severities2.PlaySpecificSound(clip, playInsideHead); }); } } private void AddEntitySoundOption(AudioClip clip) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null || entitySoundOptionsPage == null) { return; } string item = "Audio2|" + ((Object)clip).name; if (registeredSoundOptions.Add(item)) { entitySoundOptionsPage.CreateFunction(((Object)clip).name, Color.white, (Action)delegate { severities2.PlaySpecificEntitySound(clip); }); } } private void AddMedicationSoundOption(AudioClip clip) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null || medicationSoundOptionsPage == null) { return; } string item = "Audio4|" + ((Object)clip).name; if (registeredSoundOptions.Add(item)) { medicationSoundOptionsPage.CreateFunction(((Object)clip).name, Color.white, (Action)delegate { severities2.PlaySpecificMedicationSound(clip); }); } } private void AddSeverity3SpecificSoundOption(AudioClip clip) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null || severity3HeadSoundOptionsPage == null) { return; } string item = "Audio5|" + ((Object)clip).name; if (registeredSoundOptions.Add(item)) { severity3HeadSoundOptionsPage.CreateFunction(((Object)clip).name, Color.white, (Action)delegate { severities3.PlaySpecificHeadSound(clip); }); } } private void AddSeverity3DisappearSoundOption(AudioClip clip) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null || severity3DisappearSoundOptionsPage == null) { return; } string item = "Audio3|" + ((Object)clip).name; if (registeredSoundOptions.Add(item)) { severity3DisappearSoundOptionsPage.CreateFunction(((Object)clip).name, Color.white, (Action)delegate { severities3.PlaySpecificDisappearSoundNow(clip); }); } } private void RefreshSpecificSoundList() { severities2.LoadAudioFiles(); severities3.LoadAudioFiles(); severities3.LoadEntityEventAudioFiles(); } private void AddEntityImageOption(string imageName, string imagePath) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(imagePath) && entityImageOptionsPage != null && registeredEntityImageOptions.Add(imagePath)) { string text = (string.IsNullOrEmpty(imageName) ? Path.GetFileNameWithoutExtension(imagePath) : imageName); string selectedImagePath = imagePath; entityImageOptionsPage.CreateFunction(text, Color.white, (Action)delegate { severities2.SpawnSpecificEntityImageForDeveloper(selectedImagePath); }); } } private void AddSeverity3EntityImageOption(string imageName, string imagePath) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(imagePath) && severity3EntityImageOptionsPage != null && registeredSeverity3EntityImageOptions.Add(imagePath)) { string text = (string.IsNullOrEmpty(imageName) ? Path.GetFileNameWithoutExtension(imagePath) : imageName); string selectedImagePath = imagePath; severity3EntityImageOptionsPage.CreateFunction(text, Color.white, (Action)delegate { severities3.SpawnSpecificEntityImageNow(selectedImagePath); }); } } private void ToggleSeverity1Audio(bool enabled) { severity1AudioEnabled = enabled; if (currentSeverity == 1) { if (enabled) { severities1?.Start(GetCurrentSeveritySecondsRemaining()); } else { severities1?.Stop(); } } } private void SetSeverityDelusionsEnabled(bool enabled) { severityDelusionsEnabled = enabled; } private void SetGameMusicMuteEnabled(bool enabled) { gameMusicMuteEnabled = enabled; if (enabled && schizophreniaEnabled) { KeepGameMusicMuted(); } else { RestoreGameMusicVolume(); } } private void SetMedicationSoundEnabled(bool enabled) { medicationSoundEnabled = enabled; } private void RestartNormalCycleNow() { timerVersion++; pendingSeverityTimeAdjustmentSeconds = 0f; ResetToNormal(); if (schizophreniaEnabled) { StartSeverityCycle(); } } private void ClearAllSeverityEntities() { severities2?.DismissEntityForMedication(); severities3?.ClearEntityImagesNow(); } private void ToggleSchizophrenia(bool enabled) { schizophreniaEnabled = enabled; timerVersion++; if (schizophreniaEnabled) { if (gameMusicMuteEnabled) { KeepGameMusicMuted(); } ResetToNormal(); StartSeverityCycle(); } else { severities3?.StopFakeFightNow(); RestoreGameMusicVolume(); severities2?.DismissEntityForMedication(); SchizophreniaAudio.FadeOutCurrent(); ResetToNormal(); } } private void KeepGameMusicMuted() { try { if (!originalMusicVolumeCaptured) { originalMusicVolume = Audio3dManager.audio_Music; originalMusicVolumeCaptured = true; } if (Audio3dManager.audio_Music != 0f) { Audio.SetMusicVolume(0); } } catch (Exception) { if (!musicMuteFailureLogged) { musicMuteFailureLogged = true; } } } private void RestoreGameMusicVolume() { if (!originalMusicVolumeCaptured) { return; } try { Audio3dManager.audio_Music = originalMusicVolume; } catch (Exception) { } finally { originalMusicVolumeCaptured = false; } } private void StartSeverityCycle() { if (!timerRunning) { timerRunning = true; int thisTimerVersion = timerVersion; MelonCoroutines.Start(SeverityCycle(thisTimerVersion)); } } private IEnumerator SeverityCycle(int thisTimerVersion) { float duration = RandomNormalcyDuration(); yield return WaitForDuration(duration, thisTimerVersion, "Severity 1"); if (!IsCurrentCycle(thisTimerVersion)) { yield break; } float num = RandomSeverityDuration(); SetSeverity(1, num); int nextSeverity = 2; bool randomFluctuationStarted = false; while (true) { yield return WaitForDuration(num, thisTimerVersion, $"Severity {nextSeverity}"); if (!IsCurrentCycle(thisTimerVersion)) { break; } int num2 = nextSeverity; num = RandomSeverityDuration(); SetSeverity(num2, num); if (!randomFluctuationStarted && num2 < 3) { nextSeverity = num2 + 1; continue; } randomFluctuationStarted = true; nextSeverity = RandomDifferentSeverity(num2); } } private IEnumerator WaitForDuration(float duration, int thisTimerVersion, string targetSeverity) { float remaining = duration; if (!string.IsNullOrEmpty(targetSeverity)) { MelonLogger.Msg("[Schizophrenia][Timer] " + targetSeverity + " in " + FormatCountdown(remaining) + "."); } while (remaining > 0f && IsCurrentCycle(thisTimerVersion)) { float waitDuration = Mathf.Min(1f, remaining); yield return (object)new WaitForSeconds(waitDuration); remaining -= waitDuration; if (currentSeverity > 0 && pendingSeverityTimeAdjustmentSeconds != 0f) { float num = pendingSeverityTimeAdjustmentSeconds; if (currentSeverity == 1) { severities1?.AdjustSeverityDuration(num); } remaining = Mathf.Max(0f, remaining + num); pendingSeverityTimeAdjustmentSeconds = 0f; MelonLogger.Msg("[Schizophrenia][Timer] Developer adjustment applied; " + targetSeverity + " in " + FormatCountdown(remaining) + "."); } if (!string.IsNullOrEmpty(targetSeverity) && remaining > 0f) { MelonLogger.Msg("[Schizophrenia][Timer] " + targetSeverity + " in " + FormatCountdown(remaining) + "."); } } } private string FormatCountdown(float seconds) { int num = Mathf.Max(0, Mathf.CeilToInt(seconds)); return $"{num / 60:00}:{num % 60:00}"; } private bool IsCurrentCycle(int thisTimerVersion) { if (thisTimerVersion == timerVersion) { return schizophreniaEnabled; } return false; } private float RandomSeverityDuration() { return Random.Range(300f, 600f); } private float RandomNormalcyDuration() { return Random.Range(300f, 900f); } private int RandomDifferentSeverity(int severity) { int num = Random.Range(1, 3); return (severity - 1 + num) % 3 + 1; } private void SetSeverity(int severity, float severityDurationSeconds = 0f) { int num = currentSeverity; if (num == 1 && severity != 1) { severities1?.Stop(); } if (num == 2 && severity != 2) { severities2?.Stop(); } if (num == 3 && severity != 3) { severities3?.Stop(); } currentSeverity = severity; currentSeverityEndTime = Time.time + Mathf.Max(0f, severityDurationSeconds); if (currentSeverity > 0) { ShowSeverityDelusion(currentSeverity); } if (num != 1 && currentSeverity == 1 && severity1AudioEnabled) { severities1?.Start(severityDurationSeconds); } if (num != 2 && currentSeverity == 2) { severities2?.Start(); } if (num != 3 && currentSeverity == 3) { severities3?.Start(); } } private void ShowSeverityDelusion(int severity, bool force = false) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_0099: Expected O, but got Unknown if ((!severityDelusionsEnabled && !force) || Delusions.Length == 0) { return; } int num = Random.Range(0, Delusions.Length); if (Delusions.Length > 1 && num == previousDelusionIndex) { num = (num + Random.Range(1, Delusions.Length)) % Delusions.Length; } previousDelusionIndex = num; try { Notifier.Send(new Notification { Title = NotificationText.op_Implicit("Schizophrenia:"), Message = NotificationText.op_Implicit(Delusions[num]), ShowTitleOnPopup = true, PopupLength = 6f, Type = (NotificationType)0 }); } catch (Exception) { } } private void TakeYourMeds() { severities3?.StopFakeFightNow(); severities2?.DismissEntityForMedication(); if (!schizophreniaEnabled) { SchizophreniaAudio.FadeOutCurrent(); if (medicationSoundEnabled) { severities2?.PlayMedicationSound(); } return; } timerVersion++; pendingSeverityTimeAdjustmentSeconds = 0f; ResetToNormal(); StartSeverityCycle(); SchizophreniaAudio.FadeOutCurrent(); if (medicationSoundEnabled) { severities2?.PlayMedicationSound(); } } private void ResetToNormal() { SetSeverity(0); timerRunning = false; pendingSeverityTimeAdjustmentSeconds = 0f; } private void StartDevelopmentSeverity(int severity) { if (severity < 1 || severity > 3) { return; } if (!schizophreniaEnabled) { if (schizophreniaToggleElement != null) { schizophreniaToggleElement.Value = true; } if (!schizophreniaEnabled) { ToggleSchizophrenia(enabled: true); } } timerVersion++; timerRunning = true; pendingSeverityTimeAdjustmentSeconds = 0f; if (currentSeverity == 1) { severities1?.Stop(); } else if (currentSeverity == 2) { severities2?.Stop(); } else if (currentSeverity == 3) { severities3?.Stop(); } currentSeverity = 0; float num = RandomSeverityDuration(); SetSeverity(severity, num); MelonLogger.Msg($"[Schizophrenia][Developer] Started Severity {severity} directly for " + FormatCountdown(num) + "."); int nextSeverity = ((severity < 3) ? (severity + 1) : RandomDifferentSeverity(severity)); bool randomFluctuationStarted = severity >= 3; MelonCoroutines.Start(DevelopmentSeverityCycle(timerVersion, num, nextSeverity, randomFluctuationStarted)); } private IEnumerator DevelopmentSeverityCycle(int thisTimerVersion, float currentSeverityDuration, int nextSeverity, bool randomFluctuationStarted) { while (IsCurrentCycle(thisTimerVersion)) { yield return WaitForDuration(currentSeverityDuration, thisTimerVersion, $"Severity {nextSeverity}"); if (!IsCurrentCycle(thisTimerVersion)) { break; } int num = nextSeverity; currentSeverityDuration = RandomSeverityDuration(); SetSeverity(num, currentSeverityDuration); if (!randomFluctuationStarted && num < 3) { nextSeverity = num + 1; continue; } randomFluctuationStarted = true; nextSeverity = RandomDifferentSeverity(num); } } private void ShiftCurrentSeverityTimer(float adjustmentSeconds) { if (timerRunning && currentSeverity != 0) { pendingSeverityTimeAdjustmentSeconds += adjustmentSeconds; currentSeverityEndTime -= adjustmentSeconds; _ = 0f; } } private float GetCurrentSeveritySecondsRemaining() { return Mathf.Max(1f, currentSeverityEndTime - Time.time); } } internal static class ModAssetPaths { private const string DataFolderName = "Schizophrenia"; public static string Root { get { string text = Path.GetDirectoryName(typeof(SchizophreniaMod).Assembly.Location); if (string.IsNullOrEmpty(text)) { text = MelonEnvironment.ModsDirectory; } return Path.Combine(text, "Schizophrenia"); } } } internal static class audioplaceratio { private const int SampleCount = 1024; private const float SampleIntervalSeconds = 0.25f; private const float SmoothingTimeSeconds = 0.8f; private const float QuietMixDecibels = -50f; private const float LoudMixDecibels = -20f; private const float QuietPlaybackVolume = 0.7f; private const float LoudPlaybackVolume = 1f; private const float ClipTailSeconds = 0.25f; private const float FallbackPlaybackVolume = 0.85f; private static readonly Il2CppStructArray<float> outputSamples = new Il2CppStructArray<float>(1024L); private static float nextSampleTime; private static float ignoreSamplesUntil; private static float lastSampleTime; private static float smoothedRms; private static bool hasSample; private static bool meterUnavailable; public static void Update() { float unscaledTime = Time.unscaledTime; if (meterUnavailable || unscaledTime < nextSampleTime || unscaledTime < ignoreSamplesUntil) { return; } nextSampleTime = unscaledTime + 0.25f; try { AudioListener.GetOutputData(outputSamples, 0); double num = 0.0; for (int i = 0; i < ((Il2CppArrayBase<float>)(object)outputSamples).Length; i++) { float num2 = ((Il2CppArrayBase<float>)(object)outputSamples)[i]; num += (double)(num2 * num2); } float num3 = Mathf.Sqrt((float)(num / (double)((Il2CppArrayBase<float>)(object)outputSamples).Length)); if (!float.IsNaN(num3) && !float.IsInfinity(num3)) { if (!hasSample) { smoothedRms = num3; hasSample = true; } else { float num4 = Mathf.Max(0f, unscaledTime - lastSampleTime); float num5 = 1f - Mathf.Exp((0f - num4) / 0.8f); smoothedRms = Mathf.Lerp(smoothedRms, num3, num5); } lastSampleTime = unscaledTime; } } catch (Exception) { meterUnavailable = true; } } public static float GetPlaybackVolume() { if (!hasSample || meterUnavailable) { return 0.85f; } float num = Mathf.Clamp01((20f * Mathf.Log10(Mathf.Max(smoothedRms, 1E-05f)) - -50f) / 30f); return Mathf.Lerp(0.7f, 1f, num); } public static void IgnoreMixWhileClipPlays(AudioClip clip) { if (!((Object)(object)clip == (Object)null)) { ignoreSamplesUntil = Mathf.Max(ignoreSamplesUntil, Time.unscaledTime + clip.length + 0.25f); } } } internal static class SchizophreniaAudio { private sealed class FadeTarget { public AudioSource Source; public float StartVolume; } private const float DefaultFadeDurationSeconds = 0.75f; private const float MinimumDistanceMeters = 1f; private static readonly List<AudioSource> activeSources = new List<AudioSource>(); public static void Play2D(AudioClip clip, AudioMixerGroup mixerGroup, float volume, float pitch, string category = "General") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Play(clip, Vector3.zero, mixerGroup, volume, pitch, 0f, 1.1f, category); } public static void PlayAtPoint(AudioClip clip, Vector3 position, AudioMixerGroup mixerGroup, float volume, float pitch, float spatialBlend, float maximumDistanceMeters, string category = "General") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Play(clip, position, mixerGroup, volume, pitch, spatialBlend, maximumDistanceMeters, category); } private static void Play(AudioClip clip, Vector3 position, AudioMixerGroup mixerGroup, float volume, float pitch, float spatialBlend, float maximumDistanceMeters, string category) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)clip == (Object)null)) { string text = (string.IsNullOrEmpty(category) ? "General" : category); GameObject val = new GameObject("Schizophrenia Audio Playback [" + text + "]") { hideFlags = (HideFlags)1 }; val.transform.position = position; AudioSource val2 = val.AddComponent<AudioSource>(); val2.playOnAwake = false; val2.loop = false; val2.ignoreListenerPause = true; val2.clip = clip; val2.outputAudioMixerGroup = mixerGroup; val2.volume = Mathf.Clamp01(volume); val2.pitch = Mathf.Clamp(pitch, 0.1f, 3f); val2.spatialBlend = Mathf.Clamp01(spatialBlend); val2.dopplerLevel = 0f; val2.rolloffMode = (AudioRolloffMode)1; val2.minDistance = 1f; val2.maxDistance = Mathf.Max(1.1f, maximumDistanceMeters); activeSources.Add(val2); val2.Play(); } } public static void Update() { for (int num = activeSources.Count - 1; num >= 0; num--) { AudioSource val = activeSources[num]; if ((Object)(object)val == (Object)null) { activeSources.RemoveAt(num); } else if (!AudioListener.pause && !val.isPlaying) { DestroySource(val); } } } public static void FadeOutCurrent(float fadeDurationSeconds = 0.75f) { FadeOutCategory(null, fadeDurationSeconds); } public static void FadeOutCategory(string category, float fadeDurationSeconds = 0.75f) { List<FadeTarget> list = new List<FadeTarget>(); for (int num = activeSources.Count - 1; num >= 0; num--) { AudioSource val = activeSources[num]; if ((Object)(object)val == (Object)null) { activeSources.RemoveAt(num); } else if (category == null || string.Equals(((Object)((Component)val).gameObject).name, "Schizophrenia Audio Playback [" + category + "]", StringComparison.Ordinal)) { if (val.isPlaying) { list.Add(new FadeTarget { Source = val, StartVolume = val.volume }); } else { DestroySource(val); } } } if (list.Count != 0) { MelonCoroutines.Start(FadeOutTargets(list, fadeDurationSeconds)); } } private static IEnumerator FadeOutTargets(List<FadeTarget> targets, float fadeDurationSeconds) { float duration = Mathf.Max(0f, fadeDurationSeconds); float elapsed = 0f; while (elapsed < duration) { elapsed += Time.unscaledDeltaTime; float num = 1f - Mathf.Clamp01(elapsed / duration); for (int i = 0; i < targets.Count; i++) { AudioSource source = targets[i].Source; if ((Object)(object)source != (Object)null) { source.volume = targets[i].StartVolume * num; } } yield return null; } for (int j = 0; j < targets.Count; j++) { AudioSource source2 = targets[j].Source; if ((Object)(object)source2 != (Object)null) { DestroySource(source2); } } } private static void DestroySource(AudioSource source) { if (!((Object)(object)source == (Object)null)) { activeSources.Remove(source); GameObject gameObject = ((Component)source).gameObject; if ((Object)(object)gameObject != (Object)null) { source.Stop(); Object.Destroy((Object)(object)gameObject); } } } } } namespace Schizophrenia.Severitys { public class severities1 { private const float MinimumAudioDistanceFeet = 5f; private const float MaximumAudioDistanceFeet = 15f; private const float FeetToMeters = 0.3048f; private const float MinimumSoundDelaySeconds = 20f; private const float MaximumSoundDelaySeconds = 60f; private const float MinimumPainSoundDelaySeconds = 10f; private const float MaximumPainSoundDelaySeconds = 20f; private const float PainPhaseDurationSeconds = 180f; private const float MissingClipRescanIntervalSeconds = 30f; private const float MinimumFordPainPitch = 0.65f; private const float MaximumFordPainPitch = 0.8f; private const string FordNpcGroup = "Ford"; private const string FordBigPainClipPrefix = "brett_pain_big"; private static readonly string[] NpcSoundKeywords = new string[19] { "npc", "voice", "dialog", "speech", "talk", "ford", "nullbody", "null_body", "null body", "saber", "bot", "agent", "human", "vocal", "vox", "grunt", "laugh", "breath", "pain" }; private static readonly string[] PainSoundKeywords = new string[11] { "pain", "hurt", "damag", "injur", "scream", "screech", "grunt", "agony", "wince", "groan", "yell" }; private readonly Dictionary<string, List<AudioClip>> npcVoiceClips = new Dictionary<string, List<AudioClip>>(); private readonly Dictionary<string, List<AudioClip>> npcPainClips = new Dictionary<string, List<AudioClip>>(); private bool running; private bool reportedMissingSources; private bool reportedMissingPainSounds; private int runVersion; private float painPhaseStartTime; private float nextMissingClipScanTime; public void Start(float severityDurationSeconds) { if (!running) { running = true; reportedMissingSources = false; reportedMissingPainSounds = false; int thisRunVersion = ++runVersion; painPhaseStartTime = Time.time + Mathf.Max(0f, severityDurationSeconds - 180f); RefreshNpcVoiceClips(); MelonCoroutines.Start(RandomNpcSounds(thisRunVersion)); } } public void Stop() { if (running) { running = false; runVersion++; SchizophreniaAudio.FadeOutCategory("Severity1NPC"); } } public void PlayRandomNpcSoundNow() { if (npcVoiceClips.Count == 0) { RefreshNpcVoiceClips(); } AudioClip val = SelectRandomNpcVoiceClip(); if (!((Object)(object)val == (Object)null)) { PlayNpcClip(val, painPhase: false); } } public void PlayFordBigPainNow() { if (!HasFinalPainClips()) { RefreshNpcVoiceClips(); } AudioClip val = SelectFinalPainClip(); if (!((Object)(object)val == (Object)null)) { PlayNpcClip(val, painPhase: true); } } public void AdjustSeverityDuration(float adjustmentSeconds) { if (running && adjustmentSeconds != 0f) { painPhaseStartTime += adjustmentSeconds; } } private IEnumerator RandomNpcSounds(int thisRunVersion) { while (IsCurrentRun(thisRunVersion)) { bool painPhase = IsInPainPhase(); float num = (painPhase ? Random.Range(10f, 20f) : Random.Range(20f, 60f)); float remaining = num; bool phaseChangedDuringWait = false; while (remaining > 0f && IsCurrentRun(thisRunVersion)) { float waitDuration = Mathf.Min(1f, remaining); yield return (object)new WaitForSeconds(waitDuration); remaining -= waitDuration; if (painPhase != IsInPainPhase()) { phaseChangedDuringWait = true; break; } } if (!IsCurrentRun(thisRunVersion)) { break; } if (phaseChangedDuringWait) { continue; } if (Time.time >= nextMissingClipScanTime && (npcVoiceClips.Count == 0 || (painPhase && !HasFinalPainClips()))) { RefreshNpcVoiceClips(); } AudioClip val = (painPhase ? SelectFinalPainClip() : SelectRandomNpcVoiceClip()); if ((Object)(object)val == (Object)null) { if (painPhase && !reportedMissingPainSounds) { reportedMissingPainSounds = true; } } else { _ = painPhase; PlayNpcClip(val, painPhase); } } } private void PlayNpcClip(AudioClip clip, bool painPhase) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) Camera main = Camera.main; if (!((Object)(object)clip == (Object)null) && !((Object)(object)main == (Object)null)) { Vector3 position = RandomPositionAround(main); float playbackVolume = audioplaceratio.GetPlaybackVolume(); audioplaceratio.IgnoreMixWhileClipPlays(clip); SchizophreniaAudio.PlayAtPoint(clip, position, Audio.NPCVocals, playbackVolume, painPhase ? Random.Range(0.65f, 0.8f) : Random.Range(0.9f, 1.1f), 1f, 9.144f, "Severity1NPC"); } } private bool IsCurrentRun(int thisRunVersion) { if (running) { return thisRunVersion == runVersion; } return false; } private bool IsInPainPhase() { return Time.time >= painPhaseStartTime; } private void RefreshNpcVoiceClips() { npcVoiceClips.Clear(); npcPainClips.Clear(); Il2CppArrayBase<AudioClip> val = Resources.FindObjectsOfTypeAll<AudioClip>(); if (val != null) { _ = val.Length; for (int i = 0; i < val.Length; i++) { AudioClip val2 = val[i]; if (!((Object)(object)val2 == (Object)null)) { if (IsNpcSound("", ((Object)val2).name)) { AddClipToNpcPool(npcVoiceClips, ((Object)val2).name, val2); } if (IsNpcPainSound("", ((Object)val2).name)) { AddClipToNpcPool(npcPainClips, ((Object)val2).name, val2); } } } } Il2CppArrayBase<AudioSource> val3 = Resources.FindObjectsOfTypeAll<AudioSource>(); if (val3 != null) { _ = val3.Length; for (int j = 0; j < val3.Length; j++) { AudioSource val4 = val3[j]; if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4.clip == (Object)null)) { string audioSourceIdentity = GetAudioSourceIdentity(val4); if (IsNpcSound(audioSourceIdentity, ((Object)val4.clip).name)) { AddClipToNpcPool(npcVoiceClips, audioSourceIdentity + "|" + ((Object)val4.clip).name, val4.clip); } if (IsNpcPainSound(audioSourceIdentity, ((Object)val4.clip).name)) { AddClipToNpcPool(npcPainClips, audioSourceIdentity + "|" + ((Object)val4.clip).name, val4.clip); } } } } nextMissingClipScanTime = Time.time + 30f; int num = CountClips(npcVoiceClips); CountClips(npcPainClips); if (num > 0) { LogNpcGroups("General", npcVoiceClips); LogNpcGroups("Pain", npcPainClips); reportedMissingSources = false; if (HasFinalPainClips()) { reportedMissingPainSounds = false; } } else if (!reportedMissingSources) { reportedMissingSources = true; } } private void AddClipToNpcPool(Dictionary<string, List<AudioClip>> pools, string identity, AudioClip clip) { if (!((Object)(object)clip == (Object)null)) { string npcGroup = GetNpcGroup(identity); if (!pools.TryGetValue(npcGroup, out var value)) { value = new List<AudioClip>(); pools.Add(npcGroup, value); } if (!value.Contains(clip)) { value.Add(clip); } } } private string GetNpcGroup(string identity) { string text = (identity ?? string.Empty).ToLowerInvariant(); if (text.Contains("nullbody") || text.Contains("null_body") || text.Contains("null body")) { return "NullBody"; } if (text.Contains("saberlake") || text.Contains("saber lake")) { return "Saberlake Bot"; } if (text.Contains("ford") || text.Contains("brett")) { return "Ford"; } if (text.Contains("crablet")) { return "Crablet"; } if (text.Contains("peasant")) { return "Peasant"; } if (text.Contains("turret")) { return "Turret"; } if (text.Contains("agent")) { return "Agent"; } if (text.Contains("bot")) { return "Bot"; } if (text.Contains("human")) { return "Human"; } return "Other NPC"; } private string GetAudioSourceIdentity(AudioSource audioSource) { if ((Object)(object)audioSource == (Object)null) { return string.Empty; } string text = ((Object)audioSource).name ?? string.Empty; Transform val = ((Component)audioSource).transform; int num = 0; while ((Object)(object)val != (Object)null && num < 8) { if ((Object)(object)((Component)val).gameObject != (Object)null) { text = ((Object)((Component)val).gameObject).name + "|" + text; } val = val.parent; num++; } return text; } private bool IsNpcSound(string sourceName, string clipName) { string text = NormalizeNames(sourceName, clipName); for (int i = 0; i < NpcSoundKeywords.Length; i++) { if (text.Contains(NpcSoundKeywords[i])) { return true; } } return false; } private bool IsNpcPainSound(string sourceName, string clipName) { string text = NormalizeNames(sourceName, clipName); if (!IsNpcSound(sourceName, clipName)) { return false; } for (int i = 0; i < PainSoundKeywords.Length; i++) { if (text.Contains(PainSoundKeywords[i])) { return true; } } return false; } private string NormalizeNames(string sourceName, string clipName) { return ((sourceName ?? string.Empty) + "|" + (clipName ?? string.Empty)).ToLowerInvariant(); } private AudioClip SelectRandomNpcVoiceClip() { return SelectRandomClipFromGroup(npcVoiceClips); } private bool HasFinalPainClips() { return GetFordIntensePainClips().Count > 0; } private AudioClip SelectFinalPainClip() { List<AudioClip> fordIntensePainClips = GetFordIntensePainClips(); if (fordIntensePainClips.Count == 0) { return null; } return fordIntensePainClips[Random.Range(0, fordIntensePainClips.Count)]; } private List<AudioClip> GetFordIntensePainClips() { List<AudioClip> list = new List<AudioClip>(); if (!npcPainClips.TryGetValue("Ford", out var value)) { return list; } for (int i = 0; i < value.Count; i++) { AudioClip val = value[i]; if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Object)val).name) && ((Object)val).name.IndexOf("brett_pain_big", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(val); } } return list; } private AudioClip SelectRandomClipFromGroup(Dictionary<string, List<AudioClip>> pools) { if (pools.Count == 0) { return null; } List<string> list = new List<string>(pools.Keys); string key = list[Random.Range(0, list.Count)]; List<AudioClip> list2 = pools[key]; if (list2.Count == 0) { return null; } return list2[Random.Range(0, list2.Count)]; } private int CountClips(Dictionary<string, List<AudioClip>> pools) { int num = 0; foreach (KeyValuePair<string, List<AudioClip>> pool in pools) { num += pool.Value.Count; } return num; } private void LogNpcGroups(string category, Dictionary<string, List<AudioClip>> pools) { List<string> list = new List<string>(pools.Keys); list.Sort(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < list.Count; i++) { _ = pools[list[i]]; } } private Vector3 RandomPositionAround(Camera playerCamera) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) float num = Random.Range(0f, (float)Math.PI * 2f); float num2 = Random.Range(5f, 15f) * 0.3048f; Vector3 val = new Vector3(Mathf.Cos(num), Random.Range(-0.12f, 0.12f), Mathf.Sin(num)); Vector3 normalized = ((Vector3)(ref val)).normalized; return ((Component)playerCamera).transform.position + normalized * num2; } } public class severities2 { private sealed class ClipboardTextSnapshot { public string Title; public string Body; public Color BodyColor; public bool HasBodyColor; } private sealed class RadialTextSnapshot { public string Text; public Color Color; } private const float TransitionDurationSeconds = 5f; private const float Severity2Contrast = 50f; private const float Severity2Saturation = -25f; private const string VolumeObjectName = "Schizophrenia Severity 2 Color Volume"; private const float MinimumSpatialAudioDelaySeconds = 10f; private const float MaximumSpatialAudioDelaySeconds = 30f; private const float MinimumHeadAudioDelaySeconds = 10f; private const float MaximumHeadAudioDelaySeconds = 20f; private const float MinimumEntitySpawnDelaySeconds = 30f; private const float MaximumEntitySpawnDelaySeconds = 60f; private const float EntityDistanceFeet = 30f; private const float MinimumEntityDistanceFeet = 5f; private const float MaximumEntityDistanceFeet = 50f; private const float EntityGeometryClearanceMeters = 1.5f; private const int EntityPositionAttempts = 24; private const float EntityLookDurationSeconds = 0.25f; private const float EntityCenterHorizontalTolerance = 0.08f; private const float EntityCenterVerticalTolerance = 0.08f; private const float ClipboardRefreshIntervalSeconds = 1f; private const float ClipboardObjectScanIntervalSeconds = 5f; private const float RadialMenuRefreshIntervalSeconds = 0.5f; private const float RadialMenuObjectScanIntervalSeconds = 5f; private const string ClipboardMessage = "NO ESCAPE"; private const string RadialMenuCanvasName = "CANVAS_RADIALUI"; private const string Severity2RadialMenuLabel = "Error."; private const float RoseScreamingMinimumFeet = 20f; private const float RoseScreamingMaximumFeet = 50f; private const float GirlLaughingMinimumFeet = 1f; private const float GirlLaughingMaximumFeet = 3f; private const float MinimumSpatialAudioDistanceFeet = 5f; private const float MaximumSpatialAudioDistanceFeet = 15f; private const float FeetToMeters = 0.3048f; private const string RoseScreamingClipName = "rosescreaming"; private const string GirlLaughingClipName = "girllaugh"; private const string SpatialAudioFolderName = "Audio"; private const string HeadAudioFolderName = "Audio1"; private const string EntityAudioFolderName = "Audio2"; private const string MedicationAudioFolderName = "Audio4"; private const string EntityImageFolderName = "entities"; private Volume severity2Volume; private readonly List<AudioClip> severity2AudioClips = new List<AudioClip>(); private readonly List<AudioClip> headAudioClips = new List<AudioClip>(); private readonly List<AudioClip> entityAudioClips = new List<AudioClip>(); private readonly List<AudioClip> medicationAudioClips = new List<AudioClip>(); private readonly List<string> entityImagePaths = new List<string>(); private readonly HashSet<string> loadedAudioFilePaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<LoreClipboard, ClipboardTextSnapshot> clipboardTextSnapshots = new Dictionary<LoreClipboard, ClipboardTextSnapshot>(); private readonly List<LoreClipboard> cachedClipboards = new List<LoreClipboard>(); private readonly Dictionary<TMP_Text, RadialTextSnapshot> radialTmpTextSnapshots = new Dictionary<TMP_Text, RadialTextSnapshot>(); private readonly Dictionary<Text, RadialTextSnapshot> radialUiTextSnapshots = new Dictionary<Text, RadialTextSnapshot>(); private readonly List<TMP_Text> cachedRadialTmpLabels = new List<TMP_Text>(); private readonly List<Text> cachedRadialUiLabels = new List<Text>(); private bool running; private bool audioLoading; private bool visualsEnabled = true; private bool radialMenuErrorEnabled = true; private bool clipboardMessageEnabled = true; private bool spatialAudioEnabled = true; private bool headAudioEnabled = true; private bool entityImagesEnabled = true; private bool entityAudioEnabled = true; private int transitionVersion; private int spatialAudioLoopVersion; private int headAudioLoopVersion; private int entityImageLoopVersion; private int previousSpatialAudioClipIndex = -1; private int previousHeadAudioClipIndex = -1; private int previousEntityImageIndex = -1; private int previousMedicationAudioIndex = -1; private float nextClipboardRefreshTime; private float nextClipboardObjectScanTime; private float nextRadialMenuRefreshTime; private float nextRadialMenuObjectScanTime; private float entityCenterLookDuration; private GameObject activeEntityObject; private Texture2D activeEntityTexture; private Sprite activeEntitySprite; private bool loggedMissingEntityAudio; private bool loggedMissingMedicationAudio; private bool loggedClipboardReplacement; private bool loggedRadialMenuMessage; public event Action<AudioClip, bool> AudioClipLoaded; public event Action<AudioClip> EntityAudioClipLoaded; public event Action<AudioClip> MedicationAudioClipLoaded; public event Action<string, string> EntityImageLoaded; public void Start() { if (!running) { running = true; nextRadialMenuRefreshTime = 0f; nextRadialMenuObjectScanTime = 0f; if (radialMenuErrorEnabled) { UpdateRadialMenuErrorDisplay(); } if (visualsEnabled) { BeginVisuals(); } if (clipboardMessageEnabled) { nextClipboardObjectScanTime = 0f; ApplyClipboardMessage(); nextClipboardRefreshTime = Time.time + 1f; } StartAudioLoops(); if (entityImagesEnabled) { StartEntityImageLoop(); } LoadAudioFiles(); } } public void Stop() { if (running) { running = false; spatialAudioLoopVersion++; headAudioLoopVersion++; entityImageLoopVersion++; RestoreRadialMenuText(); DestroyActiveEntityImage(playSound: false); RestoreClipboardText(); SchizophreniaAudio.FadeOutCategory("Severity2Spatial"); SchizophreniaAudio.FadeOutCategory("Severity2Head"); SchizophreniaAudio.FadeOutCategory("Severity2Entity"); EndVisuals(); } } public void SetVisualsEnabled(bool enabled) { visualsEnabled = enabled; if (running) { if (enabled) { BeginVisuals(); } else { EndVisuals(); } } } public void SetRadialMenuErrorEnabled(bool enabled) { radialMenuErrorEnabled = enabled; if (running) { if (enabled) { nextRadialMenuRefreshTime = 0f; UpdateRadialMenuErrorDisplay(); } else { RestoreRadialMenuText(); } } } public void SetClipboardMessageEnabled(bool enabled) { clipboardMessageEnabled = enabled; if (running) { if (enabled) { nextClipboardObjectScanTime = 0f; ApplyClipboardMessage(); nextClipboardRefreshTime = Time.time + 1f; } else { RestoreClipboardText(); } } } public void SetSpatialAudioEnabled(bool enabled) { spatialAudioEnabled = enabled; spatialAudioLoopVersion++; if (enabled && running) { StartSpatialAudioLoop(); } else if (!enabled) { SchizophreniaAudio.FadeOutCategory("Severity2Spatial"); } } public void SetHeadAudioEnabled(bool enabled) { headAudioEnabled = enabled; headAudioLoopVersion++; if (enabled && running) { StartHeadAudioLoop(); } else if (!enabled) { SchizophreniaAudio.FadeOutCategory("Severity2Head"); } } public void SetEntityImagesEnabled(bool enabled) { entityImagesEnabled = enabled; entityImageLoopVersion++; if (enabled && running) { StartEntityImageLoop(); } else if (!enabled) { DestroyActiveEntityImage(playSound: false); SchizophreniaAudio.FadeOutCategory("Severity2Entity"); } } public void SetEntityAudioEnabled(bool enabled) { entityAudioEnabled = enabled; if (!enabled) { SchizophreniaAudio.FadeOutCategory("Severity2Entity"); } } private void BeginVisuals() { if (EnsureVolume()) { MelonCoroutines.Start(FadeVolumeWeight(1f, ++transitionVersion)); } } private void EndVisuals() { if (!((Object)(object)severity2Volume == (Object)null)) { MelonCoroutines.Start(FadeVolumeWeight(0f, ++transitionVersion)); } } private bool EnsureVolume() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if ((Object)(object)severity2Volume != (Object)null && (Object)(object)severity2Volume.profile != (Object)null) { return true; } GameObject val = new GameObject("Schizophrenia Severity 2 Color Volume"); Object.DontDestroyOnLoad((Object)(object)val); severity2Volume = val.AddComponent<Volume>(); severity2Volume.isGlobal = true; severity2Volume.priority = 9999f; severity2Volume.weight = 0f; VolumeProfile val2 = ScriptableObject.CreateInstance<VolumeProfile>(); ((Object)val2).name = "Schizophrenia Severity 2 Color Volume Profile"; severity2Volume.profile = val2; ColorAdjustments obj = val2.Add<ColorAdjustments>(true); ((VolumeParameter)obj.contrast).overrideState = true; ((VolumeParameter<float>)(object)obj.contrast).value = 50f; ((VolumeParameter)obj.saturation).overrideState = true; ((VolumeParameter<float>)(object)obj.saturation).value = -25f; return true; } private IEnumerator FadeVolumeWeight(float targetWeight, int thisTransition) { float startWeight = severity2Volume.weight; float elapsed = 0f; while (elapsed < 5f && thisTransition == transitionVersion) { elapsed += Time.unscaledDeltaTime; float num = Mathf.Clamp01(elapsed / 5f); severity2Volume.weight = Mathf.Lerp(startWeight, targetWeight, num); yield return null; } if (thisTransition == transitionVersion && (Object)(object)severity2Volume != (Object)null) { severity2Volume.weight = targetWeight; } } public void LoadAudioFiles() { if (!audioLoading) { audioLoading = true; MelonCoroutines.Start(LoadSeverity2Audio()); } } public void PlaySpecificSound(AudioClip clip, bool playInsideHead) { PlayAudioClip(clip, playInsideHead, developerInitiated: true); } public void PlayRandomSpatialSoundNow() { if (severity2AudioClips.Count != 0) { PlayAudioClip(severity2AudioClips[Random.Range(0, severity2AudioClips.Count)], playInsideHead: false, developerInitiated: true); } } public void PlayRandomHeadSoundNow() { if (headAudioClips.Count != 0) { PlayAudioClip(headAudioClips[Random.Range(0, headAudioClips.Count)], playInsideHead: true, developerInitiated: true); } } public void PlayRandomEntitySoundNow() { if (entityAudioClips.Count != 0) { PlaySpecificEntitySound(entityAudioClips[Random.Range(0, entityAudioClips.Count)]); } } public void ApplyClipboardMessageNow() { if (running) { ApplyClipboardMessage(); } } public void PlaySpecificEntitySound(AudioClip clip) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { Vector3 position = ((Component)main).transform.position + ((Component)main).transform.forward * 9.144f; PlayEntityAudioAt(clip, position, developerInitiated: true); } } public void PlayMedicationSound() { if (medicationAudioClips.Count == 0) { string audioDirectory = Path.Combine(ModAssetPaths.Root, "Audio4"); LoadAudioFolder(audioDirectory, playInsideHead: true, playForEntity: false, playForMedication: true); } if (medicationAudioClips.Count == 0) { if (!loggedMissingMedicationAudio) { loggedMissingMedicationAudio = true; } return; } int num = Random.Range(0, medicationAudioClips.Count); if (medicationAudioClips.Count > 1 && num == previousMedicationAudioIndex) { num = (num + 1) % medicationAudioClips.Count; } previousMedicationAudioIndex = num; AudioClip clip = medicationAudioClips[num]; PlayMedicationSound(clip, developerInitiated: false); } public void PlaySpecificMedicationSound(AudioClip clip) { PlayMedicationSound(clip, developerInitiated: true); } private void PlayMedicationSound(AudioClip clip, bool developerInitiated) { if (!((Object)(object)clip == (Object)null)) { PlayAudioClip(clip, playInsideHead: true, developerInitiated, "Medication"); } } public void SpawnEntityImageForDeveloper() { if ((Object)(object)activeEntityObject != (Object)null) { return; } RefreshEntityImagePaths(); if (entityImagePaths.Count == 0) { return; } Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { if (entityAudioClips.Count == 0 && !audioLoading) { LoadAudioFiles(); } SpawnRandomEntityImage(main); } } public void DismissEntityForMedication() { if (!((Object)(object)activeEntityObject == (Object)null)) { DestroyActiveEntityImage(playSound: false); } } public void LoadEntityImageOptions() { RefreshEntityImagePaths(); for (int i = 0; i < entityImagePaths.Count; i++) { string text = entityImagePaths[i]; this.EntityImageLoaded?.Invoke(Path.GetFileNameWithoutExtension(text), text); } } public void SpawnSpecificEntityImageForDeveloper(string imagePath) { if ((Object)(object)activeEntityObject != (Object)null) { return; } RefreshEntityImagePaths(); string text = null; for (int i = 0; i < entityImagePaths.Count; i++) { if (string.Equals(entityImagePaths[i], imagePath, StringComparison.OrdinalIgnoreCase)) { text = entityImagePaths[i]; break; } } if (text == null) { return; } Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { if (entityAudioClips.Count == 0 && !audioLoading) { LoadAudioFiles(); } SpawnEntityImage(main, text); } } private void RefreshClipboardCache() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) cachedClipboards.Clear(); try { Il2CppArrayBase<LoreClipboard> val = Resources.FindObjectsOfTypeAll<LoreClipboard>(); if (val == null) { return; } for (int i = 0; i < val.Length; i++) { LoreClipboard val2 = val[i]; if ((Object)(object)val2 != (Object)null) { Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { cachedClipboards.Add(val2); } } } } catch (Exception) { } } private void ApplyClipboardMessage() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) try { if (Time.time >= nextClipboardObjectScanTime) { RefreshClipboardCache(); nextClipboardObjectScanTime = Time.time + 5f; } int num = 0; for (int i = 0; i < cachedClipboards.Count; i++) { LoreClipboard val = cachedClipboards[i]; if ((Object)(object)val == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } if (!clipboardTextSnapshots.ContainsKey(val)) { clipboardTextSnapshots.Add(val, new ClipboardTextSnapshot { Title = (val.title ?? string.Empty), Body = (val.body ?? string.Empty), BodyColor = (((Object)(object)val.tmp_body != (Object)null) ? ((Graphic)val.tmp_body).color : Color.white), HasBodyColor = ((Object)(object)val.tmp_body != (Object)null) }); } ClipboardTextSnapshot clipboardTextSnapshot = clipboardTextSnapshots[val]; if (!string.IsNullOrEmpty(val.title)) { val.title = string.Empty; } if (val.body != "NO ESCAPE") { val.body = "NO ESCAPE"; } if ((Object)(object)val.tmp_title != (Object)null && ((TMP_Text)val.tmp_title).text.Length != 0) { ((TMP_Text)val.tmp_title).text = string.Empty; } if ((Object)(object)val.tmp_body != (Object)null) { if (!clipboardTextSnapshot.HasBodyColor) { clipboardTextSnapshot.BodyColor = ((Graphic)val.tmp_body).color; clipboardTextSnapshot.HasBodyColor = true; } if (((TMP_Text)val.tmp_body).text != "NO ESCAPE") { ((TMP_Text)val.tmp_body).text = "NO ESCAPE"; } if (((Graphic)val.tmp_body).color != Color.red) { ((Graphic)val.tmp_body).color = Color.red; } } num++; } if (num > 0 && !loggedClipboardReplacement) { loggedClipboardReplacement = true; } } catch (Exception) { } } private void RestoreClipboardText() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<LoreClipboard, ClipboardTextSnapshot> clipboardTextSnapshot in clipboardTextSnapshots) { LoreClipboard key = clipboardTextSnapshot.Key; if ((Object)(object)key == (Object)null) { continue; } try { key.title = clipboardTextSnapshot.Value.Title; key.body = clipboardTextSnapshot.Value.Body; if ((Object)(object)key.tmp_title != (Object)null) { ((TMP_Text)key.tmp_title).text = clipboardTextSnapshot.Value.Title; } if ((Object)(object)key.tmp_body != (Object)null) { ((TMP_Text)key.tmp_body).text = clipboardTextSnapshot.Value.Body; if (clipboardTextSnapshot.Value.HasBodyColor) { ((Graphic)key.tmp_body).color = clipboardTextSnapshot.Value.BodyColor; } } } catch (Exception) { } } _ = clipboardTextSnapshots.Count; _ = 0; clipboardTextSnapshots.Clear(); cachedClipboards.Clear(); nextClipboardObjectScanTime = 0f; loggedClipboardReplacement = false; } public void Update() { UpdateEntityLookDetection(); if (running) { if (radialMenuErrorEnabled && Time.unscaledTime >= nextRadialMenuRefreshTime) { UpdateRadialMenuErrorDisplay(); nextRadialMenuRefreshTime = Time.unscaledTime + 0.5f; } if (clipboardMessageEnabled && Time.time >= nextClipboardRefreshTime) { ApplyClipboardMessage(); nextClipboardRefreshTime = Time.time + 1f; } } } public void DisplaySeverity3MenuWord(string word) { if (!string.IsNullOrEmpty(word)) { ApplyRadialMenuMessage(word, "Severity 3"); } } private void UpdateRadialMenuErrorDisplay() { ApplyRadialMenuMessage("Error.", "Severity 2"); } private void ApplyRadialMenuMessage(string message, string severityName) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) try { if (Time.unscaledTime >= nextRadialMenuObjectScanTime) { RefreshRadialMenuLabelCache(); nextRadialMenuObjectScanTime = Time.unscaledTime + 5f; } int num = 0; for (int i = 0; i < cachedRadialTmpLabels.Count; i++) { TMP_Text val = cachedRadialTmpLabels[i]; if (!((Object)(object)val == (Object)null)) { if (!radialTmpTextSnapshots.ContainsKey(val)) { radialTmpTextSnapshots.Add(val, new RadialTextSnapshot { Text = val.text, Color = ((Graphic)val).color }); } if (val.text != message || ((Graphic)val).color != Color.red) { val.text = message; ((Graphic)val).color = Color.red; num++; } } } for (int j = 0; j < cachedRadialUiLabels.Count; j++) { Text val2 = cachedRadialUiLabels[j]; if (!((Object)(object)val2 == (Object)null)) { if (!radialUiTextSnapshots.ContainsKey(val2)) { radialUiTextSnapshots.Add(val2, new RadialTextSnapshot { Text = val2.text, Color = ((Graphic)val2).color }); } if (val2.text != message || ((Graphic)val2).color != Color.red) { val2.text = message; ((Graphic)val2).color = Color.red; num++; } } } if (num > 0 && !loggedRadialMenuMessage) { loggedRadialMenuMessage = true; } } catch (Exception) { if (!loggedRadialMenuMessage) { loggedRadialMenuMessage = true; } } } private void RefreshRadialMenuLabelCache() { cachedRadialTmpLabels.Clear(); cachedRadialUiLabels.Clear(); try { Il2CppArrayBase<GameObject> val = Object.FindObjectsOfType<GameObject>(true); if (val == null) { return; } for (int i = 0; i < val.Length; i++) { GameObject val2 = val[i]; if ((Object)(object)val2 == (Object)null || ((Object)val2).name.IndexOf("CANVAS_RADIALUI", StringComparison.OrdinalIgnoreCase) < 0) { continue; } Il2CppArrayBase<TMP_Text> componentsInChildren = val2.GetComponentsInChildren<TMP_Text>(true); if (componentsInChildren != null) { for (int j = 0; j < componentsInChildren.Length; j++) { TMP_Text val3 = componentsInChildren[j]; if ((Object)(object)val3 != (Object)null && !cachedRadialTmpLabels.Contains(val3)) { cachedRadialTmpLabels.Add(val3); } } } Il2CppArrayBase<Text> componentsInChildren2 = val2.GetComponentsInChildren<Text>(true); if (componentsInChildren2 == null) { continue; } for (int k = 0; k < componentsInChildren2.Length; k++) { Text val4 = componentsInChildren2[k]; if ((Object)(object)val4 != (Object)null && !cachedRadialUiLabels.Contains(val4)) { cachedRadialUiLabels.Add(val4); } } } } catch (Exception) { if (!loggedRadialMenuMessage) { loggedRadialMenuMessage = true; } } } public void RestoreRadialMenuText() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<TMP_Text, RadialTextSnapshot> radialTmpTextSnapshot in radialTmpTextSnapshots) { if (!((Object)(object)radialTmpTextSnapshot.Key == (Object)null)) { radialTmpTextSnapshot.Key.text = radialTmpTextSnapshot.Value.Text; ((Graphic)radialTmpTextSnapshot.Key).color = radialTmpTextSnapshot.Value.Color; } } radialTmpTextSnapshots.Clear(); cachedRadialTmpLabels.Clear(); foreach (KeyValuePair<Text, RadialTextSnapshot> radialUiTextSnapshot in radialUiTextSnapshots) { if (!((Object)(object)radialUiTextSnapshot.Key == (Object)null)) { radialUiTextSnapshot.Key.text = radialUiTextSnapshot.Value.Text; ((Graphic)radialUiTextSnapshot.Key).color = radialUiTextSnapshot.Value.Color; } } radialUiTextSnapshots.Clear(); cachedRadialUiLabels.Clear(); nextRadialMenuObjectScanTime = 0f; loggedRadialMenuMessage = false; } private IEnumerator LoadSeverity2Audio() { string modAudioDirectory = ModAssetPaths.Root; bool loadedAnyAudio = false; loadedAnyAudio |= LoadAudioFolder(Path.Combine(modAudioDirectory, "Audio"), playInsideHead: false, playForEntity: false, playForMedication: false); yield return null; loadedAnyAudio |= LoadAudioFolder(Path.Combine(modAudioDirectory, "Audio1"), playInsideHead: true, playForEntity: false, playForMedication: false); yield return null; loadedAnyAudio |= LoadAudioFolder(Path.Combine(modAudioDirectory, "Audio2"), playInsideHead: false, playForEntity: true, playForMedication: false); yield return null; loadedAnyAudio |= LoadAudioFolder(Path.Combine(modAudioDirectory, "Audio4"), playInsideHead: true, playForEntity: false, playForMedication: true); audioLoading = false; if (running && loadedAnyAudio) { StartAudioLoops(); } } private bool LoadAudioFolder(string audioDirectory, bool playInsideHead, bool playForEntity, bool playForMedication) { bool result = false; string[] array = new string[0]; if (playForEntity || !playForMedication) { } try { Directory.CreateDirectory(audioDirectory); array = Directory.GetFiles(audioDirectory); Array.Sort(array, (IComparer<string>?)StringComparer.OrdinalIgnoreCase); } catch (Exception) { return false; } for (int i = 0; i < array.Length; i++) { string text = Path.GetExtension(array[i]).ToLowerInvariant(); if ((text != ".wav" && text != ".mp3") || loadedAudioFilePaths.Contains(array[i])) { continue; } try { AudioClip val = API.LoadAudioClip(array[i], true); if (!((Object)(object)val == (Object)null)) { ((Object)val).name = Path.GetFileNameWithoutExtension(array[i]); loadedAudioFilePaths.Add(array[i]); if (playForEntity) { entityAudioClips.Add(val); } else if (playForMedication) { medicationAudioClips.Add(val); } else if (playInsideHead) { headAudioClips.Add(val); } else { severity2AudioClips.Add(val); } result = true; if (playForEntity) { this.EntityAudioClipLoaded?.Invoke(val); } else if (playForMedication) { this.MedicationAudioClipLoaded?.Invoke(val); } else { this.AudioClipLoaded?.Invoke(val, playInsideHead); } } } catch (Exception) { } } return result; } private void StartAudioLoops() { StartSpatialAudioLoop(); StartHeadAudioLoop(); } private void StartSpatialAudioLoop() { if (running && spatialAudioEnabled && severity2AudioClips.Count != 0) { int thisLoop = ++spatialAudioLoopVersion; MelonCoroutines.Start(PlayRandomAudio(severity2AudioClips, playInsideHead: false, thisLoop)); } } private void StartHeadAudioLoop() { if (running && headAudioEnabled && headAudioClips.Count != 0) { int thisLoop = ++headAudioLoopVersion; MelonCoroutines.Start(PlayRandomAudio(headAudioClips, playInsideHead: true, thisLoop)); } } private void StartEntityImageLoop() { if (running && entityImagesEnabled) { RefreshEntityImagePaths(); MelonCoroutines.Start(SpawnEntityImages(++entityImageLoopVersion)); } } private IEnumerator SpawnEntityImages(int thisLoop) { while (running && thisLoop == entityImageLoopVersion) { yield return (object)new WaitForSeconds(Random.Range(30f, 60f)); if (!running || thisLoop != entityImageLoopVersion) { break; } RefreshEntityImagePaths(); if (entityImagePaths.Count != 0 && !((Object)(object)activeEntityObject != (Object)null)) { Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { SpawnRandomEntityImage(main); } } } } private void RefreshEntityImagePaths() { entityImagePaths.Clear(); string path = Path.Combine(ModAssetPaths.Root, "entities"); try { Directory.CreateDirectory(path); string[] files = Directory.GetFiles(path); Array.Sort(files, (IComparer<string>?)StringComparer.OrdinalIgnoreCase); for (int i = 0; i < files.Length; i++) { if (string.Equals(Path.GetExtension(files[i]), ".png", StringComparison.OrdinalIgnoreCase)) { entityImagePaths.Add(files[i]); } } } catch (Exception) { } } private void SpawnRandomEntityImage(Camera playerCamera) { int num = Random.Range(0, entityImagePaths.Count); if (entityImagePaths.Count > 1 && num == previousEntityImageIndex) { num = (num + 1) % entityImagePaths.Count; } previousEntityImageIndex = num; string imagePath = entityImagePaths[num]; SpawnEntityImage(playerCamera, imagePath); } private void SpawnEntityImage(Camera playerCamera, string imagePath) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) Texture2D val = null; Sprite val2 = null; GameObject val3 = null; try { val = new Texture2D(2, 2, (TextureFormat)4, false); Il2CppStructArray<byte> val4 = new Il2CppStructArray<byte>(File.ReadAllBytes(imagePath)); if (!ImageConversion.LoadImage(val, val4)) { Object.Destroy((Object)(object)val); return; } ((Object)val).name = Path.GetFileNameWithoutExtension(imagePath); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; float num = Mathf.Max(1f, (float)Mathf.Max(((Texture)val).width, ((Texture)val).height) / 2f); val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), num); ((Object)val2).name = ((Object)val).name; if (!TryChooseEntityPosition(playerCamera, out var position, out var _)) { Object.Destroy((Object)(object)val2); Object.Destroy((Object)(object)val); return; } val3 = new GameObject("Schizophrenia Severity 2 Entity"); val3.transform.position = position; val3.transform.rotation = Quaternion.LookRotation(((Component)playerCamera).transform.position - position, Vector3.up); SpriteRenderer obj = val3.AddComponent<SpriteRenderer>(); obj.sprite = val2; ((Renderer)obj).sortingOrder = 32767; activeEntityObject = val3; activeEntityTexture = val; activeEntitySprite = val2; entityCenterLookDuration = 0f; } catch (Exception) { if ((Object)(object)val3 != (Object)null) { Object.Destroy((Object)(object)val3); } if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } private bool TryChooseEntityPosition(Camera playerCamera, out Vector3 position, out float distanceFeet) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; distanceFeet = 0f; Vector3 val = Vector3.ProjectOnPlane(((Component)playerCamera).transform.forward, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = ((Component)playerCamera).transform.forward; } ((Vector3)(ref val)).Normalize(); float num = 1.524f; float num2 = 15.24f; Vector3 position2 = ((Component)playerCamera).transform.position; for (int i = 0; i < 24; i++) { Vector3 val2 = Quaternion.AngleAxis(Random.Range(-90f, 90f), Vector3.up) * -val; Vector3 val3 = Vector3.ProjectOnPlane(val2, Vector3.up); val2 = ((Vector3)(ref val3)).normalized; float num3 = Random.Range(num, num2); float num4 = num3; if (TryGetEntityObstructionDistance(playerCamera, val2, num3, out var obstructionDistance)) { num4 = obstructionDistance - 1.5f; } if (!(num4 < num) && !(num4 > num2)) { position = position2 + val2 * num4; distanceFeet = num4 / 0.3048f; return true; } } return false; } private bool TryGetEntityObstructionDistance(Camera playerCamera, Vector3 direction, float maximumDistance, out float obstructionDistance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) obstructionDistance = 0f; Vector3 val = ((Component)playerCamera).transform.position; float num = 0f; float num2 = maximumDistance; RaycastHit val2 = default(RaycastHit); for (int i = 0; i < 16; i++) { if (!(num2 > 0.01f)) { break; } if (!Physics.Raycast(val, direction, ref val2, num2, -5, (QueryTriggerInteraction)1)) { return false; } if (IsPlayerRigCollider(((RaycastHit)(ref val2)).transform, ((Component)playerCamera).transform)) { float num3 = ((RaycastHit)(ref val2)).distance + 0.03f; val += direction * num3; num += num3; num2 = maximumDistance - num; continue; } obstructionDistance = num + ((RaycastHit)(ref val2)).distance; return true; } return false; } private bool IsPlayerRigCollider(Transform hitTransform, Transform cameraTransform) { if ((Object)(object)hitTransform == (Object)null || (Object)(object)cameraTransform == (Object)null) { return false; } if (!((Object)(object)hitTransform == (Object)(object)cameraTransform) && !hitTransform.IsChildOf(cameraTransform) && !cameraTransform.IsChildOf(hitTransform)) { return (Object)(object)hitTransform.root == (Object)(object)cameraTransform.root; } return true; } private void UpdateEntityLookDetection() { //IL_003b: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)activeEntityObject == (Object)null) { return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { entityCenterLookDuration = 0f; return; } activeEntityObject.transform.rotation = Quaternion.LookRotation(((Component)main).transform.position - activeEntityObject.transform.position, Vector3.up); Vector3 val = main.WorldToViewportPoint(activeEntityObject.transform.position); bool num = val.z > 0f && Mathf.Abs(val.x - 0.5f) <= 0.08f && Mathf.Abs(val.y - 0.5f) <= 0.08f; Vector3 val2 = activeEntityObject.transform.position - ((Component)main).transform.position; float magnitude = ((Vector3)(ref val2)).magnitude; float obstructionDistance; bool flag = magnitude > 0.01f && TryGetEntityObstructionDistance(main, val2 / magnitude, magnitude, out obstructionDistance); if (!num || flag) { entityCenterLookDuration = 0f; return; } entityCenterLookDuration += Time.unscaledDeltaTime; if (entityCenterLookDuration >= 0.25f) { DestroyActiveEntityImage(playSound: true); } } private void DestroyActiveEntityImage(bool playSound) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)activeEntityObject == (Object)null) { return; } Vector3 position = activeEntityObject.transform.position; Object.Destroy((Object)(object)activeEntityObject); activeEntityObject = null; if ((Object)(object)activeEntitySprite != (Object)null) { Object.Destroy((Object)(object)activeEntitySprite); } if ((Object)(object)activeEntityTexture != (Object)null) { Object.Destroy((Object)(object)activeEntityTexture); } activeEntitySprite = null; activeEntityTexture = null; entityCenterLookDuration = 0f; if (!playSound || !entityAudioEnabled) { return; } if (entityAudioClips.Count == 0) { if (!loggedMissingEntityAudio) { loggedMissingEntityAudio = true; } } else { int index = Random.Range(0, entityAudioClips.Count); AudioClip clip = entityAudioClips[index]; PlayEntityAudioAt(clip, position, developerInitiated: false); } } private void PlayEntityAudioAt(AudioClip clip, Vector3 position, bool developerInitiated) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)clip == (Object)null)) { float playbackVolume = audioplaceratio.GetPlaybackVolume(); float pitch = Random.Range(0.9f, 1.1f); audioplaceratio.IgnoreMixWhileClipPlays(clip); SchizophreniaAudio.PlayAtPoint(clip, position, Audio.NPCVocals, playbackVolume, pitch, 1f, 30.48f, "Severity2Entity"); } } private IEnumerator PlayRandomAudio(List<AudioClip> clips, bool playInsideHead, int thisLoop) { while (running && IsCurrentAudioLoop(thisLoop, playInsideHead)) { float num = (playInsideHead ? 10f : 10f); float num2 = (playInsideHead ? 20f : 30f); yield return (object)new WaitForSeconds(Random.Range(num, num2)); if (!running || !IsCurrentAudioLoop(thisLoop, playInsideHead)) { break; } if (clips.Count != 0) { int num3 = Random.Range(0, clips.Count); int num4 = (playInsideHead ? previousHeadAudioClipIndex : previousSpatialAudioClipIndex); if (clips.Count > 1 && num3 == num4) { num3 = (num3 + 1) % clips.Count; } if (playInsideHead) { previousHeadAudioClipIndex = num3; } else { previousSpatialAudioClipIndex = num3; } float num5 = PlayAudioClip(clips[num3], playInsideHead, developerInitiated: false); if (playInsideHead && num5 > 0f) { yield return (object)new WaitForSeconds(num5); } } } } private bool IsCurrentAudioLoop(int loopVersion, bool playInsideHead) { return loopVersion == (playInsideHead ? headAudioLoopVersion : spatialAudioLoopVersion); } private float PlayAudioClip(AudioClip clip, bool playInsideHead, bool developerInitiated, string audioCategory = null) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null) { return 0f; } float playbackVolume = audioplaceratio.GetPlaybackVolume(); float num = Random.Range(0.9f, 1.1f); if (playInsideHead) { SchizophreniaAudio.Play2D(clip, Audio.InHead, playbackVolume, num, audioCategory ?? "Severity2Head"); audioplaceratio.IgnoreMixWhileClipPlays(clip); } else { Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return 0f; } audioplaceratio.IgnoreMixWhileClipPlays(clip); SchizophreniaAudio.PlayAtPoint(clip, RandomPositionAround(main, clip), Audio.NPCVocals, playbackVolume, num, 1f, GetSpatialAudioMaximumDistance(clip), audioCategory ?? "Severity2Spatial"); } return clip.length / num; } private float GetSpatialAudioMaximumDistance(AudioClip clip) { if ((Object)(object)clip != (Object)null && ((Object)clip).name.IndexOf("rosescreaming", StringComparison.OrdinalIgnoreCase) >= 0) { return 18.288f; } if ((Object)(object)clip != (Object)null && ((Object)clip).name.IndexOf("girllaugh", StringComparison.OrdinalIgnoreCase) >= 0) { return 1.8288f; } return 9.144f; } private Vector3 RandomPositionAround(Camera playerCamera, AudioClip clip) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) float num = Random.Range(0f, (float)Math.PI * 2f); Vector3 val; if ((Object)(object)clip != (Object)null && ((Object)clip).name.IndexOf("rosescreaming", StringComparison.OrdinalIgnoreCase) >= 0) { float num2 = Random.Range(20f, 50f) * 0.3048f; val = new Vector3(Mathf.Cos(num), Random.Range(-0.12f, 0.12f), Mathf.Sin(num)); Vector3 normalized = ((Vector3)(ref val)).normalized; return ((Component)playerCamera).transform.position + normalized * num2; } int num3; float num4; if ((Object)(object)clip != (Object)null) { num3 = ((((Object)clip).name.IndexOf("girllaugh", StringComparison.OrdinalIgnoreCase) >= 0) ? 1 : 0); if (num3 != 0) { num4 = 1f; goto IL_00bb; } } else { num3 = 0; } num4 = 5f; goto IL_00bb; IL_00bb: float num5 = num4; float num6 = ((num3 != 0) ? 3f : 15f); float num7 = Random.Range(num5, num6) * 0.3048f; val = new Vector3(Mathf.Cos(num), Random.Range(-0.12f, 0.12f), Mathf.Sin(num)); Vector3 normalized2 = ((Vector3)(ref val)).normalized; return ((Component)playerCamera).transform.position + normalized2 * num7; } } public class severities3 { private sealed class Severity3EntityImage { public GameObject GameObject; public Texture2D Texture; public Sprite Sprite; } private sealed class Severity3ScreenImage { public string Path; public Texture2D Texture; public Sprite Sprite; } private const float TransitionDurationSeconds = 5f; private const float Severity3Contrast = 50f; private const float Severity3Saturation = -25f; private const float RadialMenuWordIntervalSeconds = 0.5f; private const flo