using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using Gravity; using HarmonyLib; using Microsoft.CodeAnalysis; using PluginConfig.API; using PluginConfig.API.Decorators; using PluginConfig.API.Fields; using ULTRAKILL.Cheats; using ULTRAKILL.Portal; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceProviders; using UnityEngine.SceneManagement; using UnityEngine.UI; using allroadsleadtofraud.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("allroadsleadtofraud")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3")] [assembly: AssemblyProduct("All Roads Lead To Disintegration Loop")] [assembly: AssemblyTitle("allroadsleadtofraud")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace allroadsleadtofraud { public enum DoorStyle { Unknown, FirstRoom, Prelude, Limbo, Lust, Gluttony, Greed, Wrath, Heresy, Violence, Fraud, Treachery } public static class DoorStyleExt { public static string GetStyleName(this DoorStyle s) { switch (s) { case DoorStyle.FirstRoom: return "FirstRoom"; case DoorStyle.Prelude: return "PreludeStyle"; case DoorStyle.Limbo: return "LimboStyle"; case DoorStyle.Lust: return "LustStyle"; case DoorStyle.Gluttony: return "GluttonyStyle"; case DoorStyle.Greed: return "GreedStyle"; case DoorStyle.Wrath: return "WrathStyle"; case DoorStyle.Heresy: return "HeresyStyle"; case DoorStyle.Violence: return "ViolenceStyle"; case DoorStyle.Fraud: return "FraudStyle"; default: Plugin.Logger.LogError((object)$"{s} is not a valid doorstyle"); return "PreludeStyle"; } } public static DoorStyle DoorStyleFromString(this string s) { s = s.ToLower(); s = s.Trim(); switch (s) { case "unknownstyle": return DoorStyle.Unknown; case "firstroom": return DoorStyle.FirstRoom; case "preludestyle": return DoorStyle.Prelude; case "limbostyle": return DoorStyle.Limbo; case "luststyle": return DoorStyle.Lust; case "gluttonystyle": return DoorStyle.Gluttony; case "greedstyle": return DoorStyle.Greed; case "wrathstyle": return DoorStyle.Wrath; case "heresystyle": return DoorStyle.Heresy; case "violencestyle": return DoorStyle.Violence; case "fraudstyle": return DoorStyle.Fraud; default: Plugin.Logger.LogError((object)(s + " is not a valid doorstyle")); return DoorStyle.Unknown; } } } public static class LevelDatabaseChecker { public class LevelDoorData { public DoorStyle style { get; internal set; } public int subDoorId { get; internal set; } } private static Dictionary _doorPathToData = new Dictionary(); internal static void LoadDatabase() { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("allroadsleadtofraud.leveldatabase.txt"); if (stream == null) { Plugin.Logger.LogError((object)"Could not load LevelDataDoorDatabase due to missing stream!"); return; } using StreamReader streamReader = new StreamReader(stream); string[] array = streamReader.ReadToEnd().Split('\n'); _doorPathToData.Clear(); try { string[] array2 = array; foreach (string text in array2) { if (!string.IsNullOrWhiteSpace(text) && !text.StartsWith("//")) { string[] array3 = text.Split('Ω'); _doorPathToData.TryAdd(array3[0].TrimEnd(), new LevelDoorData { style = array3[1].DoorStyleFromString(), subDoorId = int.Parse(array3[2].Trim()) }); } } } catch (Exception ex) { Plugin.Logger.LogError((object)("Error while loading leveldoordatabase: " + ex.Message)); } } public static LevelDoorData? CheckDoor(GameObject door) { string key = SceneHelper.CurrentScene + "> " + Plugin.GetPath(door); return _doorPathToData.GetValueOrDefault(key); } } public class FogData { public bool UseFog; public Color FogColor; public float FogStart; public float FogEnd; public Material Skybox; public Color AmbientLight; public static FogData FromCurrent() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) return new FogData { UseFog = RenderSettings.fog, FogColor = RenderSettings.fogColor, FogStart = RenderSettings.fogStartDistance, FogEnd = RenderSettings.fogEndDistance, Skybox = RenderSettings.skybox, AmbientLight = RenderSettings.ambientLight }; } public void Apply() { //IL_000c: 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) RenderSettings.fog = UseFog; RenderSettings.fogColor = FogColor; RenderSettings.fogStartDistance = FogStart; RenderSettings.fogEndDistance = FogEnd; RenderSettings.skybox = Skybox; RenderSettings.ambientLight = AmbientLight; } public void ApplyEnter(Portal p) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) p.enableOverrideFog = true; p.useFogEnter = true; p.overrideFogStartEnter = FogStart; p.overrideFogEndEnter = FogEnd; p.overrideFogColorEnter = FogColor; p.overrideSkyboxEnter = Skybox; } public void ApplyExit(Portal p) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) p.enableOverrideFog = true; p.useFogExit = true; p.overrideFogStartExit = FogStart; p.overrideFogEndExit = FogEnd; p.overrideFogColorExit = FogColor; p.overrideSkyboxExit = Skybox; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.triggeredidiot.allroadsleadtofraud", "All Roads Lead To Disintegration Loop", "1.1.3")] public class Plugin : BaseUnityPlugin { private class stupidfuckingthingihatethisfunction : MonoBehaviour { } [CompilerGenerated] private sealed class d__100 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public IEnumerator action; public GameObject self; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__100(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = action; <>1__state = 2; return true; case 2: <>1__state = -1; Object.Destroy((Object)(object)self); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__99 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public Action action; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__99(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; action(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string DisintegrationLoopPath = "Assets/Mods/allroadsleadtofraud/disintegrationloop.unity"; public const string DisintegrationLoopMixerPath = "Assets/Mods/allroadsleadtofraud/MusicAudioFraud.mixer"; public const string DisintegrationLoopMusicCPath = "Assets/Music/8-3 Intro Clean.wav"; public const string DisintegrationLoopMusicBPath = "Assets/Music/8-3 Intro.wav"; internal static FogData _levelFogData = new FogData(); private static bool _levelHasFogUpdated = false; internal static readonly FogData DisintegrationLoopFogData = new FogData { UseFog = true, FogColor = new Color(0.282f, 0.549f, 0.898f, 1f), FogStart = 0f, FogEnd = 500f }; public static bool ReplaceFinal = true; public static bool ReplaceFirst = true; public static bool ReplacePrelude = true; public static bool ReplaceLimbo = true; public static bool ReplaceLust = true; public static bool ReplaceGluttony = true; public static bool ReplaceGreed = true; public static bool ReplaceWrath = true; public static bool ReplaceHeresy = true; public static bool ReplaceViolence = true; public static bool ReplaceFraud = true; public static bool ReplaceTreachery = false; public static bool ReplacePortalDoors = true; public static bool DisplayFakeLevelTitle = true; public static bool StopTimerInLoop = false; public static bool ReplaceSecretLevels = false; public static bool ReplaceSpecialLevels = false; public static bool ReplacePrimeLevels = true; public static bool ReplaceEncoreLevels = true; public static bool ReplaceCustomLevels = true; public static bool AllowCrossPatching = true; public static bool DisableFraudMusic = false; public static bool ModCompatabilityMode = false; public static float ReplaceChance = 5f; private Action yesthisisbadbutimtoolazy; internal static HashSet SkullDoors = new HashSet(); internal static PluginConfigurator config; internal static bool debugDoor = false; internal static ManualLogSource Logger { get; set; } = null; public static string AddressablesPath { get; private set; } = string.Empty; public static string AddressablesCatalogPath { get; private set; } = string.Empty; public static bool IsReady { get; private set; } = false; public static AudioMixer DisintegrationLoopMixer { get; private set; } public static AudioMixerGroup DisintegrationLoopMixerOut { get; private set; } public static AudioClip DisintegrationLoopMusicC { get; private set; } public static AudioClip DisintegrationLoopMusicB { get; private set; } public static SceneInstance? DisintegrationLoop { get; private set; } = null; public static bool HasLoadedDisintegrationLoop { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references) if (DisintegrationLoop.HasValue) { SceneInstance value = DisintegrationLoop.Value; Scene scene = ((SceneInstance)(ref value)).Scene; return ((Scene)(ref scene)).isLoaded; } return false; } } public static bool IsInDisintegrationLoop { get; internal set; } = false; public static FogData LevelFogData => _levelFogData; public static Queue RunAfterDisintegrationLoop { get; internal set; } = new Queue(); public static bool HasLimboSky { get; private set; } = false; internal static void UpdateFogState() { if (!_levelHasFogUpdated) { ForceUpdateFogState(); } } internal static void ForceUpdateFogState() { _levelHasFogUpdated = true; _levelFogData = FogData.FromCurrent(); if ((Object)(object)ApplyDisintegrationLoopPatch.portalEnter != (Object)null) { _levelFogData.ApplyExit(ApplyDisintegrationLoopPatch.portalEnter); } if ((Object)(object)ApplyDisintegrationLoopPatch.portalExit != (Object)null) { _levelFogData.ApplyEnter(ApplyDisintegrationLoopPatch.portalExit); } } public static bool IsReplacing() { string currentScene = SceneHelper.CurrentScene; if (currentScene == "Level 4-S") { return false; } if (!ReplaceSecretLevels && currentScene.EndsWith("-S")) { return false; } bool flag = !ReplaceSpecialLevels; if (flag) { bool flag2; switch (currentScene) { case "CreditsMuseum2": case "Endless": case "Tutorial": case "uk_construct": flag2 = true; break; default: flag2 = false; break; } flag = flag2; } if (flag) { return false; } if (!ReplaceEncoreLevels && currentScene.EndsWith("-E")) { return false; } if (!ReplacePrimeLevels && currentScene.StartsWith("Level P-")) { return false; } if (!ReplaceCustomLevels && SceneHelper.IsPlayingCustom) { return false; } return true; } public static bool IsReplacingStyle(DoorStyle style) { if (!IsReplacing()) { return false; } string currentScene = SceneHelper.CurrentScene; switch (style) { case DoorStyle.FirstRoom: return ReplaceFirst; case DoorStyle.Prelude: if (ReplacePrelude) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 0-"); } return false; case DoorStyle.Limbo: if (ReplaceLimbo) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 1-"); } return false; case DoorStyle.Lust: if (ReplaceLust) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 2-"); } return false; case DoorStyle.Gluttony: if (ReplaceGluttony) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 3-"); } return false; case DoorStyle.Greed: if (ReplaceGreed) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 4-"); } return false; case DoorStyle.Wrath: if (ReplaceWrath) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 5-"); } return false; case DoorStyle.Heresy: if (ReplaceHeresy) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 6-"); } return false; case DoorStyle.Violence: if (ReplaceViolence) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 7-"); } return false; case DoorStyle.Fraud: if (ReplaceFraud) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 8-"); } return false; case DoorStyle.Treachery: if (ReplaceTreachery) { if (AllowCrossPatching) { return true; } return currentScene.StartsWith("Level 9-"); } return false; default: return false; } } private void Update() { yesthisisbadbutimtoolazy(); } private void LateUpdate() { } private void Awake() { //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Expected O, but got Unknown //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Expected O, but got Unknown //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Expected O, but got Unknown //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Expected O, but got Unknown //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Expected O, but got Unknown //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Expected O, but got Unknown //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Expected O, but got Unknown //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Expected O, but got Unknown //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Expected O, but got Unknown //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Expected O, but got Unknown //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Expected O, but got Unknown //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Expected O, but got Unknown //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Expected O, but got Unknown //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Expected O, but got Unknown //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Expected O, but got Unknown //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Expected O, but got Unknown //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Expected O, but got Unknown //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Expected O, but got Unknown //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Expected O, but got Unknown //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Expected O, but got Unknown //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Expected O, but got Unknown //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Expected O, but got Unknown //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Expected O, but got Unknown //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Expected O, but got Unknown //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Expected O, but got Unknown //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Expected O, but got Unknown //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Expected O, but got Unknown //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Expected O, but got Unknown //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Expected O, but got Unknown //IL_064f: Expected O, but got Unknown //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Expected O, but got Unknown //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_0674: Expected O, but got Unknown //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)4; Logger.LogInfo((object)"Checking addressable files"); AddressablesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Path.Combine(Paths.PluginPath, "allroadsleadtofraud"), "Addressables"); AddressablesCatalogPath = Path.Combine(AddressablesPath, "catalog.json"); string path = Path.Combine(AddressablesPath, "version.txt"); bool flag = true; if (File.Exists(path)) { if (File.ReadAllText(path) == "1.1.3") { flag = false; } else { Logger.LogWarning((object)"Existing addressable files have mis-matching version!"); flag = true; } } else { flag = true; } if (!Directory.Exists(AddressablesPath)) { Directory.CreateDirectory(AddressablesPath); flag = true; } Assembly executingAssembly = Assembly.GetExecutingAssembly(); if (flag) { Logger.LogInfo((object)"Extracting addressable files"); using Stream stream = executingAssembly.GetManifestResourceStream("allroadsleadtofraud.Addressables.zip"); if (stream == null) { Logger.LogError((object)"Could not load Addressables.zip due to missing stream!"); return; } using ZipArchive zipArchive = new ZipArchive(stream, ZipArchiveMode.Read); foreach (ZipArchiveEntry entry in zipArchive.Entries) { string path2 = Path.Combine(AddressablesPath, entry.FullName); if (string.IsNullOrEmpty(entry.Name)) { continue; } using Stream stream2 = entry.Open(); using FileStream destination = File.Create(path2); stream2.CopyTo(destination); } Logger.LogInfo((object)"Storing addressable version as 1.1.3"); File.WriteAllText(path, "1.1.3"); } Logger.LogInfo((object)"Patching methods"); new Harmony("com.triggeredidiot.allroadsleadtofraud").PatchAll(); Logger.LogInfo((object)"Loading LevelDoorDatabase"); LevelDatabaseChecker.LoadDatabase(); Logger.LogInfo((object)"Setting up config"); config = PluginConfigurator.Create("All Roads Lead To Fraud", "com.triggeredidiot.allroadsleadtofraud"); using Stream stream3 = executingAssembly.GetManifestResourceStream("allroadsleadtofraud.thumb.png"); using (MemoryStream memoryStream = new MemoryStream()) { stream3?.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, memoryStream.ToArray()); config.icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero); } new ConfigHeader(config.rootPanel, "Checkout other options if you're having issues", 24); FloatSliderField jumpscareChance = new FloatSliderField(config.rootPanel, "Jumpscare Chance", "jumpscare_chance", new Tuple(0f, 100f), 5f); BoolField displayFakeLevelTitle = new BoolField(config.rootPanel, "Display Fake Level Title", "jumpscare_faketitle", DisplayFakeLevelTitle, true, true); BoolField pauseTimer = new BoolField(config.rootPanel, "Pause the timer in [8-3]", "jumpscare_pausetimer", StopTimerInLoop, true, true); ConfigPanel val2 = new ConfigPanel(config.rootPanel, "Other Options", "other_panel"); BoolField modCompat = new BoolField(val2, "Enable Mod Compatability Mode", "other_compat", ModCompatabilityMode, true, true); new ConfigHeader(val2, "Tip: Use compatability mode if mod assets duplicate or break when the jumpscare is activated.", 24); BoolField replaceMusic = new BoolField(val2, "Disable 8-3 music", "other_music", DisableFraudMusic, true, true); BoolField allowCross = new BoolField(val2, "Allow cross door patching", "other_cross", AllowCrossPatching, true, true); new ConfigHeader(val2, "(i.e if a prelude door appears in limbo)", 24); ConfigPanel val3 = new ConfigPanel(config.rootPanel, "Jumpscare Options", "jumpscare_panel"); ConfigHeader val4 = new ConfigHeader(val3, "Target Doors", 24); BoolField replaceSecret = new BoolField(((ConfigField)val4).parentPanel, "Allow jumpscares in secret levels", "jumpscare_secret", ReplaceSecretLevels, true, true); BoolField replaceSpecial = new BoolField(((ConfigField)val4).parentPanel, "Allow jumpscares in special levels", "jumpscare_special", ReplaceSpecialLevels, true, true); BoolField replacePrime = new BoolField(((ConfigField)val4).parentPanel, "Allow jumpscares in prime levels", "jumpscare_prime", ReplacePrimeLevels, true, true); BoolField replaceEncore = new BoolField(((ConfigField)val4).parentPanel, "Allow jumpscares in encore levels", "jumpscare_encore", ReplaceEncoreLevels, true, true); BoolField replaceCustom = new BoolField(((ConfigField)val4).parentPanel, "Allow jumpscares in custom levels", "jumpscare_custom", ReplaceCustomLevels, true, true); BoolField replaceFraud2 = new BoolField(((ConfigField)val4).parentPanel, "Jumpscare Portal Doors", "jumpscare_fraud_portal_doors", ReplacePortalDoors, true, true); new ConfigHeader(((ConfigField)val4).parentPanel, "Disable this if you are having issues with fraud doors", 24); BoolField replaceFirstRoom = new BoolField(((ConfigField)val4).parentPanel, "Jumpscare FirstRoom", "jumpscare_firstroom", ReplaceFirst, true, true); BoolField replaceFinalRoom = new BoolField(((ConfigField)val4).parentPanel, "Jumpscare FinalRoom", "jumpscare_finalroom", ReplaceFinal, true, true); ConfigHeader val5 = new ConfigHeader(val3, "Prelude", 24); BoolField replacePrelude = new BoolField(((ConfigField)val5).parentPanel, "Jumpscare Prelude", "jumpscare_prelude", ReplacePrelude, true, true); ConfigHeader val6 = new ConfigHeader(val3, "Act 1", 24); BoolField replaceLimbo = new BoolField(((ConfigField)val6).parentPanel, "Jumpscare Limbo", "jumpscare_limbo", ReplaceLimbo, true, true); BoolField replaceLust = new BoolField(((ConfigField)val6).parentPanel, "Jumpscare Lust", "jumpscare_lust", ReplaceLust, true, true); BoolField replaceGluttony = new BoolField(((ConfigField)val6).parentPanel, "Jumpscare Gluttony", "jumpscare_gluttony", ReplaceGluttony, true, true); ConfigHeader val7 = new ConfigHeader(val3, "Act 2", 24); BoolField replaceGreed = new BoolField(((ConfigField)val7).parentPanel, "Jumpscare Greed", "jumpscare_greed", ReplaceGreed, true, true); BoolField replaceWrath = new BoolField(((ConfigField)val7).parentPanel, "Jumpscare Wrath", "jumpscare_wrath", ReplaceWrath, true, true); BoolField replaceHeresy = new BoolField(((ConfigField)val7).parentPanel, "Jumpscare Heresy", "jumpscare_heresy", ReplaceHeresy, true, true); ConfigHeader val8 = new ConfigHeader(val3, "Act 3", 24); BoolField replaceViolence = new BoolField(((ConfigField)val8).parentPanel, "Jumpscare Violence", "jumpscare_violence", ReplaceViolence, true, true); BoolField replaceFraud = new BoolField(((ConfigField)val8).parentPanel, "Jumpscare Fraud", "jumpscare_fraud", ReplaceFraud, true, true); yesthisisbadbutimtoolazy = delegate { ModCompatabilityMode = modCompat.value; AllowCrossPatching = allowCross.value; DisableFraudMusic = replaceMusic.value; ReplaceSpecialLevels = replaceSpecial.value; ReplacePrimeLevels = replacePrime.value; ReplaceEncoreLevels = replaceEncore.value; ReplaceCustomLevels = replaceCustom.value; ReplaceSecretLevels = replaceSecret.value; ReplaceFirst = replaceFirstRoom.value; ReplaceFinal = replaceFinalRoom.value; ReplacePrelude = replacePrelude.value; ReplaceLimbo = replaceLimbo.value; ReplaceLust = replaceLust.value; ReplaceGluttony = replaceGluttony.value; ReplaceGreed = replaceGreed.value; ReplaceWrath = replaceWrath.value; ReplaceHeresy = replaceHeresy.value; ReplaceViolence = replaceViolence.value; ReplaceFraud = replaceFraud.value; ReplaceTreachery = false; StopTimerInLoop = pauseTimer.value; DisplayFakeLevelTitle = displayFakeLevelTitle.value; ReplacePortalDoors = replaceFraud2.value; ReplaceChance = jumpscareChance.value; }; Logger.LogInfo((object)"Hooking into SceneManager"); bool hasLoaded = false; SceneManager.sceneLoaded += delegate(Scene lcm, LoadSceneMode s) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if ((int)s != 1) { NoCheatingPatches.WasActive = false; _levelHasFogUpdated = false; IsInDisintegrationLoop = false; ApplyDisintegrationLoopPatch.HasPatchedFirstRoom = false; ApplyDisintegrationLoopPatch.HasDisintegrated = false; ApplyDisintegrationLoopPatch.LastDisintegrationTime = -1f; ApplyDisintegrationLoopPatch.WasPlayingMusic = false; ApplyDisintegrationLoopPatch.dontFuckingSwapDoorsGodIHateProgrammingThisFuckassMod = false; ApplyDisintegrationLoopPatch._alreadyOpenedDoors.Clear(); TimeOfDayPatch.doneChangers.Clear(); LevelNamePopupPatch.DidReplace = false; LevelNamePopupPatch.SafeToGrab = true; SkullDoors.Clear(); ItemPlaceZone[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (ItemPlaceZone val9 in array) { if (val9.doors != null) { SkullDoors.UnionWith(val9.doors); SkullDoors.UnionWith(val9.reverseDoors); } } HasLimboSky = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0).Length != 0; if (!(SceneHelper.CurrentScene == "Bootstrap")) { if (hasLoaded) { switch (SceneHelper.CurrentScene) { default: LoadDisintegrationLoop(); break; case "Intro": break; case "Level 4-S": break; } } else { hasLoaded = true; Logger.LogInfo((object)"Loading addressables catalog..."); AsyncOperationHandle val10 = Addressables.LoadContentCatalogAsync(AddressablesCatalogPath, (string)null); val10.Completed += delegate(AsyncOperationHandle handle) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) if ((int)handle.Status != 1) { Logger.LogError((object)$"Failed to load catalog at '{AddressablesCatalogPath}', got status '{handle.Status}'"); } else { Logger.LogInfo((object)("Loaded catalog at '" + AddressablesCatalogPath + "'")); IsReady = true; Logger.LogInfo((object)"Loading music..."); RunDelay(delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) DisintegrationLoopMixer = Addressables.LoadAssetAsync((object)"Assets/Mods/allroadsleadtofraud/MusicAudioFraud.mixer").WaitForCompletion(); DisintegrationLoopMixerOut = Addressables.LoadAssetAsync((object)"Assets/Mods/allroadsleadtofraud/IntroMusicIntro.prefab").WaitForCompletion().GetComponentInChildren(true) .outputAudioMixerGroup; DisintegrationLoopMusicC = Addressables.LoadAssetAsync((object)"Assets/Music/8-3 Intro Clean.wav").WaitForCompletion(); DisintegrationLoopMusicB = Addressables.LoadAssetAsync((object)"Assets/Music/8-3 Intro.wav").WaitForCompletion(); Logger.LogInfo((object)"Music loaded!"); }, 0f); } }; } } } }; Logger.LogInfo((object)"Plugin com.triggeredidiot.allroadsleadtofraud has awoken!"); } public static void LoadDisintegrationLoop(Action? successCallback = null) { //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) Action successCallback2 = successCallback; if (HasLoadedDisintegrationLoop) { Logger.LogWarning((object)"Tried to load disintegration loop but it is already loaded!"); return; } AsyncOperationHandle val = Addressables.LoadSceneAsync((object)"Assets/Mods/allroadsleadtofraud/disintegrationloop.unity", (LoadSceneMode)1, true, 100); val.Completed += delegate(AsyncOperationHandle handle) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((int)handle.Status != 1) { Logger.LogError((object)"Failed to load disintegration loop!"); } else { DisintegrationLoop = handle.Result; successCallback2?.Invoke(); } }; } public static void UnloadDisintegrationLoop(Action? successCallback = null) { //IL_0038: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Action successCallback2 = successCallback; if (!HasLoadedDisintegrationLoop) { Logger.LogWarning((object)"Tried to unload disintegration loop but it wasn't loaded to begin with!"); return; } IsInDisintegrationLoop = false; ApplyDisintegrationLoopPatch.HasDisintegrated = false; AsyncOperationHandle val = Addressables.UnloadSceneAsync(DisintegrationLoop.Value, (UnloadSceneOptions)0, true); val.CompletedTypeless += delegate(AsyncOperationHandle handle) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 DisintegrationLoop = null; if ((int)((AsyncOperationHandle)(ref handle)).Status != 1) { Logger.LogError((object)"Failed to unload disintegration loop!"); } else { successCallback2?.Invoke(); } }; } public static void ReloadDisintegrationLoop(Action? successCallback = null) { Action successCallback2 = successCallback; if (!HasLoadedDisintegrationLoop) { LoadDisintegrationLoop(successCallback2); return; } UnloadDisintegrationLoop(delegate { LoadDisintegrationLoop(successCallback2); }); } internal static void RunDelay(Action action, float delay) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown GameObject val = new GameObject("run-delay-instance"); ((MonoBehaviour)val.AddComponent()).StartCoroutine(RunDelayCoroutine(action, delay)); Object.Destroy((Object)val, delay + 0.1f); } internal static void RunCoro(IEnumerator action, float delay) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("run-delay-instance"); ((MonoBehaviour)val.AddComponent()).StartCoroutine(RunCoroutine(action, delay, val)); } [IteratorStateMachine(typeof(d__99))] private static IEnumerator RunDelayCoroutine(Action action, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__99(0) { action = action, delay = delay }; } [IteratorStateMachine(typeof(d__100))] private static IEnumerator RunCoroutine(IEnumerator action, float delay, GameObject self) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__100(0) { action = action, delay = delay, self = self }; } internal static void ForceDoorOpen(Door door) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)door == (Object)null)) { if (!door.open) { door.Open(false, false); } door.requests = 9999; door.locked = false; if ((Object)(object)door.noPass != (Object)null) { door.noPass.SetActive(false); } if (door.gotPos) { ((Component)door).transform.localPosition = door.openPosRelative; door.inPos = true; } } } internal static void ResetDoor(Door door, bool closeDoor = true) { if (!((Object)(object)door == (Object)null)) { door.requests = 0; door.locked = false; if ((Object)(object)door.noPass != (Object)null) { door.noPass.SetActive(false); } door.inPos = false; if (closeDoor) { door.Close(true); } else { door.Open(false, false); } } } internal static GameObject? FindObjectInDisintegrationLoop(string path) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) if (!HasLoadedDisintegrationLoop) { Logger.LogWarning((object)"Tried to access disintegration loop scene but its not loaded!"); return null; } SceneInstance? disintegrationLoop = DisintegrationLoop; object obj; if (!disintegrationLoop.HasValue) { obj = null; } else { SceneInstance valueOrDefault = disintegrationLoop.GetValueOrDefault(); Scene scene = ((SceneInstance)(ref valueOrDefault)).Scene; obj = ((Scene)(ref scene)).GetRootGameObjects(); } GameObject[] array = (GameObject[])obj; string[] array2 = path.Split('/'); if (array != null) { GameObject[] array3 = array; foreach (GameObject val in array3) { if (((Object)val).name == array2[0]) { GameObject val2 = FindRecursive(val, array2, 0); if ((Object)(object)val2 != (Object)null) { return val2; } } } } return null; } internal static GameObject? FindRecursive(GameObject current, string[] steps, int stepIndex) { if (stepIndex == steps.Length - 1) { return current; } string text = steps[stepIndex + 1]; for (int i = 0; i < current.transform.childCount; i++) { GameObject gameObject = ((Component)current.transform.GetChild(i)).gameObject; if (((Object)gameObject).name == text) { GameObject val = FindRecursive(gameObject, steps, stepIndex + 1); if ((Object)(object)val != (Object)null) { return val; } } } return null; } internal static string GetPath(GameObject obj) { if ((Object)(object)obj == (Object)null) { return ""; } string text = ((Object)obj).name; Transform val = obj.transform; while ((Object)(object)val.parent != (Object)null) { val = val.parent; text = ((Object)val).name + "/" + text; } return text; } internal static string GetPath(Component c) { if ((Object)(object)c == (Object)null) { return ""; } return GetPath(c.gameObject) + "<" + ((object)c).GetType().Name + ">"; } [Conditional("DEBUG")] internal static void Log(object msg) { } [Conditional("DEBUG")] internal static void LogWarn(object msg) { } [Conditional("DEBUG")] internal static void DebugRay(Vector3 from, Vector3 dir, Color c, float dur, bool dummy = false) { } } [HarmonyPatch] public static class NoCheatingPatches { internal static bool WasActive; private static int _previousKills; private static int _previousStyle; private static bool _lastState; [HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")] [HarmonyPrefix] private static bool Prefix_SubmitLevelScore() { if (WasActive) { return false; } return true; } [HarmonyPatch(typeof(StatsManager), "Start")] [HarmonyPostfix] private static void Postfix_Start() { _previousKills = MonoSingleton.Instance.kills; _previousStyle = MonoSingleton.Instance.stylePoints; } [HarmonyPatch(typeof(StatsManager), "Update")] [HarmonyPrefix] private static void Prefix_Update() { if (Plugin.IsInDisintegrationLoop) { MonoSingleton.Instance.kills = _previousKills; MonoSingleton.Instance.stylePoints = _previousStyle; MonoSingleton.Instance.timer = !Plugin.StopTimerInLoop; } else { _previousKills = MonoSingleton.Instance.kills; _previousStyle = MonoSingleton.Instance.stylePoints; } if (Plugin.IsInDisintegrationLoop != _lastState) { _lastState = Plugin.IsInDisintegrationLoop; if (_lastState) { MonoSingleton.Instance.timer = !Plugin.StopTimerInLoop; } else { MonoSingleton.Instance.timer = true; } } } } internal static class MyPluginInfo { public const string PLUGIN_GUID = "com.triggeredidiot.allroadsleadtofraud"; public const string PLUGIN_NAME = "All Roads Lead To Disintegration Loop"; public const string PLUGIN_VERSION = "1.1.3"; } } namespace allroadsleadtofraud.Patches { [HarmonyPatch(typeof(Door), "Open", new Type[] { typeof(bool), typeof(bool) })] internal static class ApplyDisintegrationLoopPatch { internal class DoorStateCopy : MonoBehaviour { internal DoorController _copy; internal DoorController _target; private void Update() { if ((Object)(object)_copy == (Object)null || (Object)(object)_target == (Object)null) { Object.Destroy((Object)(object)this); } else { _target.playerIn = _copy.playerIn; } } } internal class StupidScriptBecauseImLazy : MonoBehaviour { internal Door _check; internal Action _run; private void Update() { if (!_check.isFullyClosed) { _run?.Invoke(); Object.Destroy((Object)(object)this); } } } [HarmonyPatch(typeof(FinalPit), "OnTriggerEnter")] private class FinalPitPatch_OnTriggerEnter { private static void Prefix(FinalPit __instance, Collider other) { //IL_0015: 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_002a: Unknown result type (might be due to invalid IL or missing references) if (Plugin.DisintegrationLoop.HasValue) { Scene scene = ((Component)__instance).gameObject.scene; SceneInstance value = Plugin.DisintegrationLoop.Value; if (scene == ((SceneInstance)(ref value)).Scene) { return; } } if (Random.Range(0f, 100f) > Plugin.ReplaceChance || !((Object)(object)((Component)other).gameObject == (Object)(object)__instance.player) || !Object.op_Implicit((Object)(object)MonoSingleton.Instance) || MonoSingleton.Instance.hp <= 0 || !Plugin.ReplaceFinal || Plugin.IsInDisintegrationLoop || _finalPitPatchYay) { return; } FinalRoom componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return; } FinalPit[] componentsInChildren = ((Component)componentInParent).GetComponentsInChildren(); bool flag = false; FinalPit[] array = componentsInChildren; foreach (FinalPit val in array) { flag |= Object.op_Implicit((Object)(object)val) && val.fakeEnd; } if (!flag) { if (HasDisintegrated) { PatchFinalDoor(((Component)componentInParent).GetComponentInChildren()); } else { PatchFinalDoor(((Component)componentInParent).GetComponentInChildren()); } } } } public struct DoorPortalPositionInfo { public bool forward; public Vector3 doorLocalPositionEntrance; public Vector3 doorLocalPositionExit; public Quaternion doorLocalRotationEntrance; public Quaternion doorLocalRotationExit; public DoorController? enteredDoorController; public DoorController? exitedDoorController; public GameObject parent; public GameObject exitParent; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__19_0; public static Action <>9__25_0; public static Action <>9__25_1; public static Action <>9__25_2; public static UnityAction <>9__26_2; public static Action <>9__26_0; public static Action <>9__26_1; public static Func <>9__41_0; public static Func <>9__62_0; public static UnityAction <>9__62_2; public static UnityAction <>9__63_2; public static Action <>9__63_4; public static Action <>9__63_1; public static Action <>9__63_0; public static UnityAction <>9__64_0; public static UnityAction <>9__64_6; public static Action <>9__64_5; internal void b__19_0() { MonoSingleton.Instance.off = false; } internal void <_cleanupPortals>b__25_0() { doorPortalExit.SetActive(false); } internal void <_cleanupPortals>b__25_1() { doorPortalExitPortal.SetActive(false); } internal void <_cleanupPortals>b__25_2() { doorPortalEnter.SetActive(false); } internal void b__26_2() { _currentFirstFinalDoor.Open(); } internal void b__26_0() { DoorStateCopy doorStateCopy = default(DoorStateCopy); if (doorPortalExit.TryGetComponent(ref doorStateCopy)) { Object.Destroy((Object)(object)doorStateCopy); } portalExitDoorController.playerIn = true; } internal void b__26_1() { DoorStateCopy doorStateCopy = default(DoorStateCopy); if (doorPortalExit.TryGetComponent(ref doorStateCopy)) { Object.Destroy((Object)(object)doorStateCopy); } portalExitDoorController.playerIn = true; } internal bool b__41_0(Action s) { return (Delegate?)s != (Delegate?)_portalDoorFix; } internal Transform b__62_0(BigDoor door) { return ((Component)door).transform; } internal void b__62_2() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) portalEnter.passThroughNonTraversals = true; portalEnter.entryTravelFlags = (PortalTravellerFlags)0; portalEnter.exitTravelFlags = (PortalTravellerFlags)0; } internal void b__63_2() { firstRoomFirstFinalDoor.SetActive(true); ((Component)portalEnter).gameObject.SetActive(false); } internal void b__63_4() { _currentFirstFinalDoor.Open(); } internal void b__63_1() { enteredDoorController.playerIn = true; } internal void b__63_0() { if (DisableEnemySpawns.DisableArenaTriggers) { return; } Door[] doors = Plugin.FindObjectInDisintegrationLoop("Pre-Space/Rooms/1 - Escher Entrance/1 Stuff/Trigger/Activator").GetComponent().doors; foreach (Door val in doors) { if (Object.op_Implicit((Object)(object)val)) { val.Lock(); } } } internal void b__64_0() { } internal void b__64_6() { _currentFirstFinalDoor.Open(); } internal void b__64_5() { DoorStateCopy doorStateCopy = default(DoorStateCopy); if (doorPortalExit.TryGetComponent(ref doorStateCopy)) { Object.Destroy((Object)(object)doorStateCopy); } portalExitDoorController.playerIn = true; } } [CompilerGenerated] private sealed class d__19 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; GameObject val = Plugin.FindObjectInDisintegrationLoop("Musics"); GameObject val2 = Plugin.FindObjectInDisintegrationLoop("IntroMusicIntro"); if (Plugin.DisableFraudMusic) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } if (Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)val2); } return false; } bool flag = !Object.op_Implicit((Object)(object)MonoSingleton.Instance); if (Object.op_Implicit((Object)(object)MonoSingleton.Instance)) { Plugin.Logger.LogWarning((object)"Possible music corruption detected?"); Object.Destroy((Object)(object)((Component)MonoSingleton.Instance).gameObject); flag = true; } if (flag) { DisintegrationLoopMusicManager disintegrationLoopMusicManager = new GameObject("DisintegrationLoopMusicManager").AddComponent(); disintegrationLoopMusicManager.battleTheme.clip = Plugin.DisintegrationLoopMusicB; disintegrationLoopMusicManager.bossTheme.clip = Plugin.DisintegrationLoopMusicB; disintegrationLoopMusicManager.cleanTheme.clip = Plugin.DisintegrationLoopMusicC; } MonoSingleton.Instance.off = true; if (Object.op_Implicit((Object)(object)val)) { UnityEvent onActivate = val.GetComponentInChildren(true).events.onActivate; object obj = <>c.<>9__19_0; if (obj == null) { UnityAction val3 = delegate { MonoSingleton.Instance.off = false; }; <>c.<>9__19_0 = val3; obj = (object)val3; } onActivate.AddListener((UnityAction)obj); } AudioMixerControllerPatch.MusicVolumeOverride = MonoSingleton.Instance.optionsMusicVolume; break; } case 1: <>1__state = -1; break; } if (AudioMixerControllerPatch.MusicVolumeOverride > 0f) { AudioMixerControllerPatch.MusicVolumeOverride -= Time.deltaTime / 2f; <>2__current = null; <>1__state = 1; return true; } MonoSingleton.Instance.SetMusicVolume(MonoSingleton.Instance.musicVolume); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__21 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; } else { <>1__state = -1; if (Plugin.DisableFraudMusic && !Object.op_Implicit((Object)(object)MonoSingleton.Instance)) { return false; } if (_isFading) { return false; } _isFading = true; if (Object.op_Implicit((Object)(object)MonoSingleton.Instance)) { MonoSingleton.Instance.off = true; Object.Destroy((Object)(object)((Component)MonoSingleton.Instance).gameObject, 2.5f); } if (!Object.op_Implicit((Object)(object)MonoSingleton.Instance) || !(AudioMixerControllerPatch.MusicVolumeOverride > -1f)) { goto IL_00e5; } 5__2 = MonoSingleton.Instance.optionsMusicVolume; } if (AudioMixerControllerPatch.MusicVolumeOverride < 5__2) { AudioMixerControllerPatch.MusicVolumeOverride += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } AudioMixerControllerPatch.MusicVolumeOverride = -1f; MonoSingleton.Instance.SetMusicVolume(MonoSingleton.Instance.musicVolume); goto IL_00e5; IL_00e5: _isFading = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static bool _isOk; internal static AudioClip? _lastCalm; internal static AudioClip? _lastBattle; internal static AudioClip? _lastBoss; private static List> altMusicObjects = new List>(); private static bool _isFading = false; internal static bool HasPatchedFirstRoom = false; internal static HashSet _alreadyOpenedDoors = new HashSet(); private static bool _finalPitPatchYay = false; private static Action _portalDoorFix = null; internal static bool dontFuckingSwapDoorsGodIHateProgrammingThisFuckassMod = false; private static Door? _previousDoor = null; private static DoorStyle _previousDoorStyle = DoorStyle.Unknown; private static int _previousDoorId = 0; private static GameObject? _previousPortalEntrance = null; private static GameObject? _previousPortalExit = null; private static FinalDoor _currentFinalDoor = null; private static FinalDoor _currentFirstFinalDoor = null; private static UnityEventPortalTravel oldPortalEntryTravel; private static UnityEventPortalTravel oldPortalExitTravel; private static GameObject firstRoomFirstFinalDoor; private static GameObject firstRoomFinalDoorLeft; internal static Portal portalEnter; internal static Portal portalExit; private static GameObject doorPortalEnter; private static GameObject doorPortalExit; private static GameObject doorPortalExitPortal; private static DoorController portalEnterDoorController; private static DoorController portalExitDoorController; private static DoorController enteredDoorController; internal static bool InteruptedLevelNamePopup = false; public static bool HasDisintegrated { get; internal set; } public static float LastDisintegrationTime { get; internal set; } public static bool WasPlayingMusic { get; internal set; } [IteratorStateMachine(typeof(d__19))] private static IEnumerator MusicFadeToFraud() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__19(0); } [IteratorStateMachine(typeof(d__21))] private static IEnumerator MusicFadeToNormal() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__21(0); } private static void OnEnterDisintegrationLoop(IPortalTraveller t, PortalTravelDetails _) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)t.travellerType == 1) { Plugin.IsInDisintegrationLoop = true; dontFuckingSwapDoorsGodIHateProgrammingThisFuckassMod = true; } } private static void OnExitDisintegrationLoop(IPortalTraveller t, PortalTravelDetails _) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((int)t.travellerType == 1) { Plugin.IsInDisintegrationLoop = false; RenderSettings.ambientLight = Plugin.LevelFogData.AmbientLight; } } private static void OnExitDisintegrationLoopFinal(IPortalTraveller t, PortalTravelDetails _) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)t.travellerType == 1) { LeaveDisintegrationLoop(); } } private static void _cleanupPortals() { //IL_0017: 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_0041: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0135: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)doorPortalExit != (Object)null) { doorPortalExit.transform.position = Vector3.one * 8192f; doorPortalExit.transform.SetParent((Transform)null, true); SceneManager.MoveGameObjectToScene(doorPortalExit, SceneManager.GetActiveScene()); Plugin.RunDelay(delegate { doorPortalExit.SetActive(false); }, Time.deltaTime * 2f); } if ((Object)(object)doorPortalExitPortal != (Object)null) { doorPortalExitPortal.transform.position = Vector3.one * 8192f; doorPortalExitPortal.transform.SetParent((Transform)null, true); SceneManager.MoveGameObjectToScene(doorPortalExitPortal, SceneManager.GetActiveScene()); Plugin.RunDelay(delegate { doorPortalExitPortal.SetActive(false); }, Time.deltaTime * 2f); } if ((Object)(object)doorPortalEnter != (Object)null) { doorPortalEnter.transform.position = Vector3.one * 8192f; doorPortalEnter.transform.SetParent((Transform)null, true); SceneManager.MoveGameObjectToScene(doorPortalEnter, SceneManager.GetActiveScene()); Plugin.RunDelay(delegate { doorPortalEnter.SetActive(false); }, Time.deltaTime * 2f); } } internal static void LeaveDisintegrationLoop(bool cleanupPortals = false, bool allowReload = true, bool didntTravelThroughPortal = false) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) if (Plugin.DisplayFakeLevelTitle && InteruptedLevelNamePopup) { LevelNamePopupPatch.DisplayDefault(); InteruptedLevelNamePopup = false; } if (Object.op_Implicit((Object)(object)MonoSingleton.Instance) && ((Behaviour)MonoSingleton.Instance).enabled) { MonoSingleton.Instance.SetRechargeMode(0f); } if (didntTravelThroughPortal) { switch (_previousDoorStyle) { case DoorStyle.FirstRoom: { if (!((Object)(object)_currentFirstFinalDoor != (Object)null)) { break; } _currentFirstFinalDoor.Close(); object obj = <>c.<>9__26_2; if (obj == null) { UnityAction val = delegate { _currentFirstFinalDoor.Open(); }; <>c.<>9__26_2 = val; obj = (object)val; } UnityAction a1 = (UnityAction)obj; _previousDoor.onFullyClosed.AddListener(a1); _previousDoor.onFullyClosed.AddListener((UnityAction)delegate { _previousDoor.onFullyClosed.RemoveListener(a1); }); break; } default: Plugin.ResetDoor(_previousDoor); break; case DoorStyle.Violence: Plugin.RunDelay(delegate { DoorStateCopy doorStateCopy = default(DoorStateCopy); if (doorPortalExit.TryGetComponent(ref doorStateCopy)) { Object.Destroy((Object)(object)doorStateCopy); } portalExitDoorController.playerIn = true; }, 0.125f); break; case DoorStyle.Limbo: case DoorStyle.Wrath: case DoorStyle.Heresy: Plugin.RunDelay(delegate { DoorStateCopy doorStateCopy2 = default(DoorStateCopy); if (doorPortalExit.TryGetComponent(ref doorStateCopy2)) { Object.Destroy((Object)(object)doorStateCopy2); } portalExitDoorController.playerIn = true; }, 0.125f); break; } Plugin._levelFogData.Apply(); } if (cleanupPortals) { _cleanupPortals(); } _finalPitPatchYay = false; dontFuckingSwapDoorsGodIHateProgrammingThisFuckassMod = false; HasDisintegrated = false; _previousDoor = null; Plugin.IsInDisintegrationLoop = false; MusicManager instance = MonoSingleton.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(MusicFadeToNormal()); } LastDisintegrationTime = Time.timeSinceLevelLoad; GameObject val2 = Plugin.FindObjectInDisintegrationLoop("Pre-Space/Rooms/1 - Escher Entrance/1 Nonstuff/CeilingSegment/ThatFuckassMirrorThatIHate"); if ((Object)(object)val2 != (Object)null) { val2.transform.position = Vector3.one * 8192f; val2.transform.SetParent((Transform)null, true); SceneManager.MoveGameObjectToScene(val2, SceneManager.GetActiveScene()); val2.SetActive(false); } Action result; while (Plugin.RunAfterDisintegrationLoop.TryDequeue(out result)) { try { result(); } catch (Exception arg) { Plugin.Logger.LogError((object)$"Exception occured while executing RunAfterDisintegrationLoop:\n{arg}"); } } if (allowReload) { Plugin.ReloadDisintegrationLoop(); } } public static Tuple GetDoorStyle(Door door) { LevelDatabaseChecker.LevelDoorData levelDoorData = LevelDatabaseChecker.CheckDoor(((Component)door).gameObject); if (levelDoorData != null) { return new Tuple(levelDoorData.style, levelDoorData.subDoorId); } string text = ((Object)((Component)door).gameObject).name.ToLower(); if (text.Contains("door") && (text.Contains("with controllers") || text.Contains("(large)"))) { return new Tuple(DoorStyle.Prelude, 0); } if ((text.Contains("largedoor") || (text.Contains("limbo large door") && !text.Contains("smallest"))) && !text.Contains("largedoorsmaller")) { return new Tuple(DoorStyle.Limbo, 0); } if (text.Contains("doorlust")) { return new Tuple(DoorStyle.Lust, 0); } if (text.Contains("doormouth")) { return new Tuple(DoorStyle.Gluttony, 0); } if (text.Contains("doorgreed")) { return new Tuple(DoorStyle.Greed, 0); } if (text.Contains("ferrydoor")) { return new Tuple(DoorStyle.Wrath, 0); } if (text.Contains("gothicdoor")) { return new Tuple(DoorStyle.Heresy, 0); } if (text.Contains("violencehalldoor")) { return new Tuple(DoorStyle.Violence, 1); } if (text.Contains("doorfraud")) { return new Tuple(DoorStyle.Fraud, 0); } return new Tuple(DoorStyle.Unknown, 0); } public static Portal? FindDoorPortal(Door door) { Portal[] componentsInChildren = ((Component)door).GetComponentsInChildren(); foreach (Portal val in componentsInChildren) { if (!(((Object)((Component)val).gameObject).name == "Entrance") || !Object.op_Implicit((Object)(object)((Component)val).transform.parent) || !((Object)((Component)val).transform.parent).name.StartsWith("DoorPortal") || (!((Object)((Component)val).transform.parent).name.EndsWith("Entrance") && !((Object)((Component)val).transform.parent).name.EndsWith("Exit"))) { return val; } } return null; } private static void Prefix(Door __instance) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (__instance.open) { _alreadyOpenedDoors.Add(__instance); } else { if (GetDoorStyle(__instance).Item1 != DoorStyle.Fraud) { return; } BigDoor[] bdoors = __instance.bdoors; for (int i = 0; i < bdoors.Length; i++) { Quaternion localRotation = ((Component)bdoors[i]).transform.localRotation; float num = ((Quaternion)(ref localRotation)).eulerAngles.y % 90f; if (!(Mathf.Abs(num) < 1.5f) && !(Mathf.Abs(num - 90f) < 1.5f)) { _alreadyOpenedDoors.Add(__instance); } } } } private static void Postfix(Door __instance, bool enemy, bool skull) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) if (_alreadyOpenedDoors.Contains(__instance)) { _alreadyOpenedDoors.Remove(__instance); } else { if (enemy || !__instance.open || __instance.locked || !Plugin.HasLoadedDisintegrationLoop || Plugin.SkullDoors.Contains(__instance)) { return; } if (HasDisintegrated) { Tuple doorStyle = GetDoorStyle(__instance); if (dontFuckingSwapDoorsGodIHateProgrammingThisFuckassMod || Plugin.IsInDisintegrationLoop || !((Object)(object)_previousPortalEntrance != (Object)null) || !((Object)(object)_previousDoor != (Object)null) || doorStyle.Item1 == DoorStyle.Unknown || doorStyle.Item1 != _previousDoorStyle || (!_previousDoor.isFullyClosed && !((Object)(object)_previousDoor == (Object)(object)__instance) && _previousDoorStyle != DoorStyle.Violence) || !Plugin.DisintegrationLoop.HasValue) { return; } Scene scene = ((Component)__instance).gameObject.scene; SceneInstance value = Plugin.DisintegrationLoop.Value; if (!(scene != ((SceneInstance)(ref value)).Scene)) { return; } DoorPortalPositionInfo portalPositionInfo = _previousDoorStyle.GetPortalPositionInfo(__instance, _previousDoorId); bool forward = portalPositionInfo.forward; Vector3 doorLocalPositionEntrance = portalPositionInfo.doorLocalPositionEntrance; Vector3 doorLocalPositionExit = portalPositionInfo.doorLocalPositionExit; Quaternion doorLocalRotationEntrance = portalPositionInfo.doorLocalRotationEntrance; Quaternion doorLocalRotationExit = portalPositionInfo.doorLocalRotationExit; if (_previousDoorStyle == DoorStyle.Fraud) { Portal instancePortal = FindDoorPortal(__instance); if ((Object)(object)instancePortal != (Object)null && !Plugin.ReplacePortalDoors) { return; } string styleName = _previousDoorStyle.GetStyleName(); int item = doorStyle.Item2; string text = ((item > 0) ? $"{item}/" : string.Empty); GameObject val = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName + "/" + text + "DoorEnter"); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName + "/" + text + "DoorExit"); if ((Object)(object)val2 == (Object)null) { return; } Door componentInChildren = val.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { ((Component)componentInChildren).transform.localScale = new Vector3(1f, 1f, 1f); if (forward) { ((Component)componentInChildren).transform.localScale = new Vector3(-1f, 1f, 1f); } } componentInChildren = val2.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { ((Component)componentInChildren).transform.localScale = new Vector3(-1f, 1f, 1f); if (forward) { ((Component)componentInChildren).transform.localScale = new Vector3(1f, 1f, 1f); } } if ((Object)(object)instancePortal != (Object)null) { ((Behaviour)instancePortal).enabled = false; Plugin.RunAfterDisintegrationLoop = new Queue(Plugin.RunAfterDisintegrationLoop.Where((Action s) => (Delegate?)s != (Delegate?)_portalDoorFix)); _portalDoorFix = delegate { if (Object.op_Implicit((Object)(object)instancePortal)) { ((Behaviour)instancePortal).enabled = true; } }; Plugin.RunAfterDisintegrationLoop.Enqueue(_portalDoorFix); } } enteredDoorController = portalPositionInfo.enteredDoorController ?? enteredDoorController; GameObject parent = portalPositionInfo.parent; GameObject exitParent = portalPositionInfo.exitParent; _previousDoorStyle.GetPortalPositionInfo(_previousDoor, _previousDoorId); _previousPortalEntrance.transform.SetParent(parent.transform, false); _previousPortalEntrance.transform.localPosition = doorLocalPositionEntrance; _previousPortalEntrance.transform.localRotation = doorLocalRotationEntrance; _previousPortalExit.transform.SetParent(exitParent.transform, false); _previousPortalExit.transform.localPosition = doorLocalPositionExit; _previousPortalExit.transform.localRotation = doorLocalRotationExit; DoorStateCopy doorStateCopy = default(DoorStateCopy); if (_previousPortalEntrance.TryGetComponent(ref doorStateCopy)) { if ((Object)(object)enteredDoorController != (Object)null) { doorStateCopy._copy = enteredDoorController; } else { Object.Destroy((Object)(object)doorStateCopy); } } _previousDoor = __instance; _previousDoorStyle = doorStyle.Item1; _previousDoorId = doorStyle.Item2; } else { if (Time.timeSinceLevelLoad - LastDisintegrationTime < 0.5f || Random.Range(0f, 100f) > Plugin.ReplaceChance) { return; } if ((Plugin.ReplaceFinal || Plugin.ReplaceFirst) && (Object)(object)((Component)__instance).GetComponentInParent() != (Object)null) { FinalRoom componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { FirstRoomPrefab componentInParent2 = ((Component)__instance).GetComponentInParent(); if (Plugin.ReplaceFirst && (Object)(object)componentInParent2 != (Object)null && !HasPatchedFirstRoom && Plugin.IsReplacingStyle(DoorStyle.FirstRoom)) { HasPatchedFirstRoom = true; PatchNormalDoor(__instance, DoorStyle.FirstRoom); } } else if ((Object)(object)((Component)componentInParent).transform.parent != (Object)null) { _ = ((Object)((Component)componentInParent).transform.parent).name == "FinalRoomExit !! disloop"; } } else { Tuple doorStyle2 = GetDoorStyle(__instance); if (Plugin.IsReplacingStyle(doorStyle2.Item1)) { PatchNormalDoor(__instance, doorStyle2.Item1, doorStyle2.Item2); } } } } } private static GameObject? FindObjectOrFail(string path) { GameObject val = Plugin.FindObjectInDisintegrationLoop(path); if ((Object)(object)val == (Object)null) { Plugin.Logger.LogError((object)(path + " is null")); return null; } return val; } private static bool enableSceneObjects() { GameObject val = FindObjectOrFail("Pre-Space"); if ((Object)(object)val == (Object)null) { return false; } val.SetActive(true); GameObject val2 = FindObjectOrFail("Navigation"); if ((Object)(object)val2 == (Object)null) { return false; } val2.SetActive(true); return true; } private static void PatchFinalDoor(Door __instance) { //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Expected O, but got Unknown if ((Object)(object)_currentFinalDoor != (Object)null || !Plugin.IsReplacing()) { return; } _currentFinalDoor = ((Component)__instance).GetComponentInParent(); _previousDoor = null; Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor(0.0716f, -39.95f, 46.9981f); if (!enableSceneObjects()) { return; } GameObject val = FindObjectOrFail("Pre-Space/EntranceDoors"); if ((Object)(object)val == (Object)null) { return; } for (int i = 0; i < val.transform.childCount; i++) { ((Component)val.transform.GetChild(i)).gameObject.SetActive(false); } string text = "FinalRoom Pit Only"; GameObject val2 = FindObjectOrFail("Pre-Space/EntranceDoors/" + text); if ((Object)(object)val2 == (Object)null) { return; } val2.SetActive(true); GameObject val3 = FindObjectOrFail("Pre-Space/EntranceDoors/" + text + "/FakeFinalPitEnter"); if ((Object)(object)val3 == (Object)null) { return; } doorPortalEnter = val3; GameObject val4 = FindObjectOrFail("Pre-Space/EntranceDoors/" + text + "/FinalRoomExit !! disloop"); if ((Object)(object)val4 == (Object)null) { return; } GameObject val5 = FindObjectOrFail("Pre-Space/EntranceDoors/" + text + "/FinalRoomExit !! disloop/FinalRoom"); if ((Object)(object)val5 == (Object)null) { return; } NoCheatingPatches.WasActive = true; doorPortalEnter.transform.SetParent((Transform)null, false); SceneManager.MoveGameObjectToScene(doorPortalEnter.gameObject, ((Component)__instance).gameObject.scene); doorPortalEnter.transform.SetParent(((Component)__instance).transform.parent.parent, false); doorPortalEnter.transform.localPosition = localPosition; doorPortalEnter.transform.localRotation = Quaternion.Euler(0f, 0f, -90f); ((Component)__instance).transform.parent.parent.Find("Pit"); Portal componentInChildren = doorPortalEnter.GetComponentInChildren(); ((Component)componentInChildren).gameObject.SetActive(false); Plugin.DisintegrationLoopFogData.ApplyEnter(componentInChildren); Plugin.LevelFogData.ApplyExit(componentInChildren); FinalRoom componentInParent = ((Component)__instance).GetComponentInParent(); string text2 = ""; if ((Object)(object)componentInParent != (Object)null) { string text3 = ((Object)((Component)componentInParent).gameObject).name.ToLower(); if (text3.Contains("prime")) { text2 = "Prime"; } else if (text3.Contains("encore")) { text2 = "Encore"; } else if (text3.Contains("secret")) { text2 = "Secret"; } } GameObject val6 = Plugin.FindObjectInDisintegrationLoop("Pre-Space/EntranceDoors/" + text + "/FinalRoomExit !! disloop/FinalRoom" + text2); if ((Object)(object)val6 == (Object)null) { val6 = val5; } val6.SetActive(true); FinalPit[] componentsInChildren = ((Component)componentInParent).GetComponentsInChildren(); string targetLevelName = ""; FinalPit[] array = componentsInChildren; foreach (FinalPit val7 in array) { if (!((Object)(object)val7 == (Object)null)) { val7.fakeEnd = true; if (!string.IsNullOrWhiteSpace(val7.targetLevelName)) { targetLevelName = val7.targetLevelName; } bool activeSelf = ((Component)val7).gameObject.activeSelf; ((Component)val7).gameObject.SetActive(false); ObjectActivator obj = ((Component)val7).gameObject.AddComponent(); UltrakillEvent val8 = new UltrakillEvent(); val8.toActivateObjects = (GameObject[])(object)new GameObject[1] { ((Component)componentInChildren).gameObject }; obj.events = val8; ((Component)val7).gameObject.SetActive(activeSelf); } } array = val4.GetComponentsInChildren(true); for (int j = 0; j < array.Length; j++) { array[j].targetLevelName = targetLevelName; } HasDisintegrated = true; Plugin.IsInDisintegrationLoop = true; dontFuckingSwapDoorsGodIHateProgrammingThisFuckassMod = true; Plugin.UpdateFogState(); MusicManager instance = MonoSingleton.Instance; _lastCalm = ((instance != null) ? instance.cleanTheme.clip : null); MusicManager instance2 = MonoSingleton.Instance; _lastBattle = ((instance2 != null) ? instance2.battleTheme.clip : null); MusicManager instance3 = MonoSingleton.Instance; _lastBoss = ((instance3 != null) ? instance3.bossTheme.clip : null); MusicManager instance4 = MonoSingleton.Instance; if (instance4 != null) { ((MonoBehaviour)instance4).StartCoroutine(MusicFadeToFraud()); } if (Plugin.DisplayFakeLevelTitle) { LevelNamePopupPatch.DisplayName("FRAUD /// THIRD", "DISINTEGRATION LOOP"); } } public static DoorPortalPositionInfo GetPortalPositionInfo(this DoorStyle doorStyle, Door door, int subDoorId = 0) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: 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_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_0329: 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_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0305: 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_0442: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Unknown result type (might be due to invalid IL or missing references) //IL_070b: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_06b2: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_07cb: Unknown result type (might be due to invalid IL or missing references) //IL_07d5: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07e4: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_07f5: Unknown result type (might be due to invalid IL or missing references) //IL_07ff: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Unknown result type (might be due to invalid IL or missing references) //IL_080e: Unknown result type (might be due to invalid IL or missing references) //IL_0813: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_078b: Unknown result type (might be due to invalid IL or missing references) //IL_0790: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_0893: Unknown result type (might be due to invalid IL or missing references) //IL_0898: Unknown result type (might be due to invalid IL or missing references) //IL_089d: Unknown result type (might be due to invalid IL or missing references) //IL_08a1: Unknown result type (might be due to invalid IL or missing references) //IL_08ac: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027a: 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_097a: Unknown result type (might be due to invalid IL or missing references) //IL_097f: Unknown result type (might be due to invalid IL or missing references) //IL_0995: Unknown result type (might be due to invalid IL or missing references) //IL_099a: Unknown result type (might be due to invalid IL or missing references) //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_0912: Unknown result type (might be due to invalid IL or missing references) //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: 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_060a: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_072f: Unknown result type (might be due to invalid IL or missing references) //IL_0837: Unknown result type (might be due to invalid IL or missing references) //IL_083c: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_09b9: Unknown result type (might be due to invalid IL or missing references) //IL_09be: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_064c: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_074b: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_09dd: Unknown result type (might be due to invalid IL or missing references) //IL_09e2: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) DoorPortalPositionInfo result = default(DoorPortalPositionInfo); result.exitParent = null; GameObject val = ((Component)door).gameObject; DoorController[] componentsInChildren = ((Component)door).GetComponentsInChildren(!((Component)door).gameObject.activeInHierarchy); if ((Object)(object)((Component)door).transform.parent != (Object)null && doorStyle != DoorStyle.Wrath) { val = ((Component)((Component)door).transform.parent).gameObject; componentsInChildren = val.GetComponentsInChildren(!val.activeInHierarchy); } DoorController val2 = ((componentsInChildren.Length != 0) ? componentsInChildren[0] : null); DoorController exitedDoorController = ((componentsInChildren.Length != 0) ? componentsInChildren.Last() : null); DoorController[] array = componentsInChildren; foreach (DoorController val3 in array) { if (!((Object)(object)val3 == (Object)null)) { if (val3.playerIn) { val2 = val3; } else { exitedDoorController = val3; } } } float num = 1f; Vector3 val4; if ((Object)(object)MonoSingleton.Instance != (Object)null) { val4 = ((Component)MonoSingleton.Instance).transform.position - ((Component)door).transform.position; num = Vector3.Dot(((Vector3)(ref val4)).normalized, ((Component)door).transform.right); } bool flag = num > 0f; switch (doorStyle) { case DoorStyle.FirstRoom: result.doorLocalPositionEntrance = Vector3.up * 5f + Vector3.forward * 0.3f; result.doorLocalPositionExit = Vector3.up * 5f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); break; default: result.doorLocalPositionEntrance = Vector3.up * 3f; result.doorLocalPositionExit = Vector3.up * 3f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 180 : 0), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? (-180) : 0), 0f); break; case DoorStyle.Limbo: flag = val2?.reverseDirection ?? flag; result.doorLocalPositionEntrance = Vector3.up * 6f; result.doorLocalPositionExit = Vector3.up * 6f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? 90 : (-90)), 0f); break; case DoorStyle.Lust: num = 1f; if ((Object)(object)MonoSingleton.Instance != (Object)null) { val4 = ((Component)MonoSingleton.Instance).transform.position - ((Component)door).transform.position; num = Vector3.Dot(((Vector3)(ref val4)).normalized, ((Component)door).transform.forward); } flag = num > 0f; result.doorLocalPositionEntrance = Vector3.up * 4.5f + Vector3.forward * 0.45f * (flag ? (-0.1f) : 1f); result.doorLocalPositionExit = Vector3.up * 4.5f + Vector3.forward * 0.45f * 1f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); break; case DoorStyle.Gluttony: num = 1f; if ((Object)(object)MonoSingleton.Instance != (Object)null) { val4 = ((Component)MonoSingleton.Instance).transform.position - ((Component)door).transform.position; num = Vector3.Dot(((Vector3)(ref val4)).normalized, ((Component)door).transform.forward); } flag = num > 0f; result.doorLocalPositionEntrance = Vector3.up * 4f; result.doorLocalPositionExit = Vector3.up * 4f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); break; case DoorStyle.Greed: result.doorLocalPositionEntrance = Vector3.up * 4f + Vector3.right * -1f; result.doorLocalPositionExit = Vector3.up * 4f; if (!flag) { ref Vector3 doorLocalPositionExit = ref result.doorLocalPositionExit; doorLocalPositionExit -= Vector3.right * 0.6f; } result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 180 : 0), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? (-180) : 0), 0f); break; case DoorStyle.Wrath: num = 1f; if ((Object)(object)MonoSingleton.Instance != (Object)null) { val4 = ((Component)MonoSingleton.Instance).transform.position - ((Component)door).transform.position; num = Vector3.Dot(((Vector3)(ref val4)).normalized, ((Component)door).transform.forward); } flag = num > 0f; val = ((Component)((Component)door).transform).gameObject; result.doorLocalPositionEntrance = Vector3.up * 5f + Vector3.forward * (flag ? (-0.05f) : 0.05f); result.doorLocalPositionExit = Vector3.up * 5f + Vector3.forward * 0.05f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); break; case DoorStyle.Heresy: num = 1f; if ((Object)(object)MonoSingleton.Instance != (Object)null) { val4 = ((Component)MonoSingleton.Instance).transform.position - ((Component)door).transform.position; num = Vector3.Dot(((Vector3)(ref val4)).normalized, ((Component)door).transform.forward); } flag = num > 0f; val = ((Component)((Component)door).transform).gameObject; result.doorLocalPositionEntrance = Vector3.up * 6f; result.doorLocalPositionExit = Vector3.up * 6f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? 90 : (-90)), 0f); exitedDoorController = val2; break; case DoorStyle.Violence: num = 1f; if ((Object)(object)MonoSingleton.Instance != (Object)null) { val4 = ((Component)MonoSingleton.Instance).transform.position - ((Component)door).transform.position; num = Vector3.Dot(((Vector3)(ref val4)).normalized, ((Component)door).transform.forward); } flag = num > 0f; flag = !flag; val = ((Component)((Component)door).transform).gameObject; result.doorLocalPositionEntrance = Vector3.up * 6f + Vector3.forward * 0.1f; result.doorLocalPositionExit = Vector3.up * 7.6f + Vector3.forward * -0.1f; result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? (-90) : (-270)), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? (-90) : 90), 0f); exitedDoorController = val2; break; case DoorStyle.Fraud: num = 1f; if ((Object)(object)MonoSingleton.Instance != (Object)null) { val4 = ((Component)MonoSingleton.Instance).transform.position - ((Component)door).transform.position; num = Vector3.Dot(((Vector3)(ref val4)).normalized, ((Component)door).transform.forward); } flag = num > 0f; val = ((Component)((Component)door).transform).gameObject; if (Object.op_Implicit((Object)(object)((Component)door).GetComponent())) { Transform child = ((Component)door).transform.GetChild(0); Transform child2 = ((Component)door).transform.GetChild(1); Vector3 position = ((Component)MonoSingleton.Instance).transform.position; float num2 = Vector3.Distance(position, ((Component)child).transform.position); float num3 = Vector3.Distance(position, ((Component)child2).transform.position); val = ((num2 < num3) ? ((Component)child).gameObject : ((Component)child2).gameObject); GameObject exitParent = ((num2 > num3) ? ((Component)child).gameObject : ((Component)child2).gameObject); result.exitParent = exitParent; } result.doorLocalPositionEntrance = new Vector3(0f, 3.75f, 0.5f); result.doorLocalPositionExit = new Vector3(0f, 3.75f, 0.5f); result.doorLocalRotationEntrance = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); result.doorLocalRotationExit = Quaternion.Euler(0f, (float)(flag ? 90 : 270), 0f); break; } result.forward = flag; result.enteredDoorController = val2; result.exitedDoorController = exitedDoorController; result.parent = val; if (!Object.op_Implicit((Object)(object)result.exitParent)) { result.exitParent = val; } return result; } private static void PatchNormalDoor(Door __instance, DoorStyle doorStyle, int subDoorId = 0) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_062f: 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_0637: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_0883: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Expected O, but got Unknown //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_0783: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_094a: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_0978: Unknown result type (might be due to invalid IL or missing references) //IL_097f: Expected O, but got Unknown //IL_09c0: Unknown result type (might be due to invalid IL or missing references) //IL_09ca: Expected O, but got Unknown //IL_09d1: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Expected O, but got Unknown //IL_0a15: Unknown result type (might be due to invalid IL or missing references) //IL_0a1a: Unknown result type (might be due to invalid IL or missing references) //IL_0a20: Expected O, but got Unknown //IL_0ad2: Unknown result type (might be due to invalid IL or missing references) //IL_0adc: Expected O, but got Unknown InteruptedLevelNamePopup = false; DoorBlocker[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); List list = new List(1) { ((Component)__instance).transform }; list.AddRange(from door in ((Component)__instance).GetComponentsInChildren() select ((Component)door).transform); DoorBlocker[] array2 = array; foreach (DoorBlocker val in array2) { if (!((Behaviour)val).enabled) { continue; } foreach (Transform item in list) { if (Vector3.Distance(item.position, ((Component)val).transform.position) < 12f) { return; } } } Portal instancePortal = FindDoorPortal(__instance); if ((Object)(object)instancePortal != (Object)null && !Plugin.ReplacePortalDoors) { return; } if (doorStyle == DoorStyle.FirstRoom) { if ((Object)(object)_currentFirstFinalDoor != (Object)null) { return; } _currentFirstFinalDoor = ((Component)__instance).GetComponentInParent(); } if (!((Object)(object)__instance != (Object)null)) { return; } if (Plugin.debugDoor) { float num = 1f; if ((Object)(object)MonoSingleton.Instance != (Object)null) { Vector3 val2 = ((Component)MonoSingleton.Instance).transform.position - ((Component)__instance).transform.position; num = Vector3.Dot(((Vector3)(ref val2)).normalized, ((Component)__instance).transform.forward); } _ = (Object)(object)MonoSingleton.Instance != (Object)null; return; } NoCheatingPatches.WasActive = true; HasDisintegrated = true; Plugin.UpdateFogState(); MusicManager instance = MonoSingleton.Instance; _lastCalm = ((instance != null) ? instance.cleanTheme.clip : null); MusicManager instance2 = MonoSingleton.Instance; _lastBattle = ((instance2 != null) ? instance2.battleTheme.clip : null); MusicManager instance3 = MonoSingleton.Instance; _lastBoss = ((instance3 != null) ? instance3.bossTheme.clip : null); _isOk = false; MusicManager instance4 = MonoSingleton.Instance; if (instance4 != null) { ((MonoBehaviour)instance4).StartCoroutine(MusicFadeToFraud()); } if (!enableSceneObjects()) { return; } string styleName = doorStyle.GetStyleName(); string text = ((subDoorId > 0) ? $"{subDoorId}/" : string.Empty); GameObject val3 = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName); if ((Object)(object)val3 == (Object)null) { return; } GameObject val4 = null; if (subDoorId > 0) { val4 = FindObjectOrFail($"Pre-Space/EntranceDoors/{styleName}/{subDoorId}"); } GameObject val5 = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName + "/" + text + "DoorEnter"); if ((Object)(object)val5 == (Object)null) { return; } GameObject val6 = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName + "/" + text + "DoorEnter/DoorPortalEntrance"); if ((Object)(object)val6 == (Object)null) { return; } doorPortalEnter = val6; GameObject val7 = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName + "/" + text + "DoorExit"); if ((Object)(object)val7 == (Object)null) { return; } GameObject val8 = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName + "/" + text + "DoorExit/DoorPortalExit"); if ((Object)(object)val8 == (Object)null) { return; } GameObject val9 = FindObjectOrFail("Pre-Space/EntranceDoors/" + styleName + "/" + text + "DoorExit/DoorPortalEntrance"); if ((Object)(object)val9 == (Object)null) { return; } doorPortalExit = val8; doorPortalExitPortal = val9; GameObject val10 = FindObjectOrFail("Pre-Space/Rooms/1 - Escher Entrance/1 Stuff/Trigger"); if ((Object)(object)val10 == (Object)null) { return; } switch (doorStyle) { case DoorStyle.FirstRoom: { string text2 = ""; if ((Object)(object)_currentFirstFinalDoor != (Object)null) { FirstRoomPrefab componentInParent = ((Component)_currentFirstFinalDoor).GetComponentInParent(); if (((Object)componentInParent).name.ToLower().Contains("prime")) { text2 = "Prime"; } else if (((Object)componentInParent).name.ToLower().Contains("encore")) { text2 = "Encore"; } else if (((Object)componentInParent).name.ToLower().Contains("secret")) { text2 = "Secret"; } } GameObject val11 = FindObjectOrFail("Pre-Space/EntranceDoors/FirstRoom/DoorEnter/FinalDoorFake" + text2); if ((Object)(object)val11 == (Object)null) { return; } GameObject val12 = FindObjectOrFail("Pre-Space/EntranceDoors/FirstRoom/DoorExit/FinalDoorFake" + text2 + "/DoorLeft"); if ((Object)(object)val12 == (Object)null) { return; } firstRoomFirstFinalDoor = val11; firstRoomFinalDoorLeft = val12; ((Component)firstRoomFinalDoorLeft.transform.parent).gameObject.SetActive(true); break; } case DoorStyle.Fraud: if (!((Object)(object)instancePortal != (Object)null)) { break; } ((Behaviour)instancePortal).enabled = false; _portalDoorFix = delegate { if (Object.op_Implicit((Object)(object)instancePortal)) { ((Behaviour)instancePortal).enabled = true; } }; Plugin.RunAfterDisintegrationLoop.Enqueue(_portalDoorFix); break; } if ((Object)(object)instancePortal != (Object)null && doorStyle != DoorStyle.Fraud) { Plugin.Logger.LogWarning((object)"Portal door but it isn't from fruad...? This will break this mod probably!!"); } if ((Object)(object)val4 != (Object)null) { val4.SetActive(true); } _previousDoor = __instance; _previousDoorStyle = doorStyle; _previousDoorId = subDoorId; _previousPortalEntrance = doorPortalEnter; _previousPortalExit = doorPortalExit; portalEnterDoorController = val5.GetComponentInChildren(); Transform val13 = val5.transform.Find("UseMe"); if ((doorStyle == DoorStyle.Wrath || doorStyle == DoorStyle.Fraud) ? true : false) { val13 = val5.transform.GetChild(0).Find("UseMe"); } if ((Object)(object)val13 != (Object)null) { portalEnterDoorController = ((Component)val13).GetComponent(); } portalExitDoorController = val7.GetComponentInChildren(); val13 = val7.transform.Find("UseMe"); if ((doorStyle == DoorStyle.Wrath || doorStyle == DoorStyle.Fraud) ? true : false) { val13 = val7.transform.GetChild(0).Find("UseMe"); } if ((Object)(object)val13 != (Object)null) { portalExitDoorController = ((Component)val13).GetComponent(); } DoorPortalPositionInfo portalPositionInfo = doorStyle.GetPortalPositionInfo(__instance, subDoorId); bool forward = portalPositionInfo.forward; Vector3 doorLocalPositionEntrance = portalPositionInfo.doorLocalPositionEntrance; Vector3 doorLocalPositionExit = portalPositionInfo.doorLocalPositionExit; Quaternion doorLocalRotationEntrance = portalPositionInfo.doorLocalRotationEntrance; Quaternion doorLocalRotationExit = portalPositionInfo.doorLocalRotationExit; enteredDoorController = portalPositionInfo.enteredDoorController; GameObject parent = portalPositionInfo.parent; GameObject exitParent = portalPositionInfo.exitParent; switch (doorStyle) { case DoorStyle.Lust: if ((Object)(object)enteredDoorController != (Object)null) { enteredDoorController.playerIn = true; } break; case DoorStyle.Limbo: case DoorStyle.Wrath: case DoorStyle.Heresy: case DoorStyle.Violence: if ((Object)(object)enteredDoorController != (Object)null) { DoorStateCopy doorStateCopy2 = doorPortalEnter.AddComponent(); doorStateCopy2._copy = enteredDoorController; doorStateCopy2._target = portalEnterDoorController; } break; case DoorStyle.Fraud: { if ((Object)(object)enteredDoorController != (Object)null) { DoorStateCopy doorStateCopy = doorPortalEnter.AddComponent(); doorStateCopy._copy = enteredDoorController; doorStateCopy._target = portalEnterDoorController; } Door componentInChildren = val5.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { ((Component)componentInChildren).transform.localScale = new Vector3(1f, 1f, 1f); if (forward) { ((Component)componentInChildren).transform.localScale = new Vector3(-1f, 1f, 1f); } } componentInChildren = val7.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { ((Component)componentInChildren).transform.localScale = new Vector3(-1f, 1f, 1f); if (forward) { ((Component)componentInChildren).transform.localScale = new Vector3(1f, 1f, 1f); } } break; } } doorPortalEnter.transform.SetParent(parent.transform, false); doorPortalEnter.transform.localPosition = doorLocalPositionEntrance; doorPortalEnter.transform.localRotation = doorLocalRotationEntrance; portalEnter = doorPortalEnter.GetComponentInChildren(); if ((Object)(object)portalEnter == (Object)null) { Plugin.Logger.LogError((object)"door portal isnt a portal.."); return; } GravityVolume val14 = val3.AddComponent(); val14.resetOnExit = false; val14.updateContinuously = false; ((Component)val14).transform.up = Vector3.up; portalEnter.forceOrthogonalGravityOnEnter = true; portalEnter.enterGravityVolume = val14; if ((Object)(object)portalEnterDoorController != (Object)null) { portalEnterDoorController.playerIn = true; } oldPortalEntryTravel = portalEnter.onEntryTravel; portalEnter.onEntryTravel = new UnityEventPortalTravel(); ((UnityEvent)(object)portalEnter.onEntryTravel).AddListener((UnityAction)OnEnterDisintegrationLoop); ((UnityEvent)(object)portalEnter.onEntryTravel).AddListener((UnityAction)OnEnterDisintegrationLoop_Specific); ((UnityEvent)(object)portalEnter.onExitTravel).AddListener((UnityAction)OnExitDisintegrationLoop); Plugin.DisintegrationLoopFogData.ApplyEnter(portalEnter); Plugin.LevelFogData.ApplyExit(portalEnter); doorPortalExit.transform.SetParent(exitParent.transform, false); doorPortalExit.transform.localPosition = doorLocalPositionExit; doorPortalExit.transform.localRotation = doorLocalRotationExit; doorPortalExit.SetActive(false); ObjectActivator val15 = val10.AddComponent(); UltrakillEvent val16 = new UltrakillEvent(); val16.toActivateObjects = (GameObject[])(object)new GameObject[1] { doorPortalExit.gameObject }; val16.toDisActivateObjects = (GameObject[])(object)new GameObject[1] { doorPortalEnter.gameObject }; val15.events = val16; if (doorStyle == DoorStyle.FirstRoom) { val15.events = new UltrakillEvent(); val15.events.onActivate = new UnityEvent(); val15.events.toActivateObjects = (GameObject[])(object)new GameObject[1] { doorPortalExit }; UnityEvent onActivate = val15.events.onActivate; object obj = <>c.<>9__62_2; if (obj == null) { UnityAction val17 = delegate { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) portalEnter.passThroughNonTraversals = true; portalEnter.entryTravelFlags = (PortalTravellerFlags)0; portalEnter.exitTravelFlags = (PortalTravellerFlags)0; }; <>c.<>9__62_2 = val17; obj = (object)val17; } onActivate.AddListener((UnityAction)obj); } portalExit = doorPortalExitPortal.GetComponentInChildren(); if ((Object)(object)portalExit == (Object)null) { Plugin.Logger.LogError((object)"door portal isnt a portal.."); return; } Plugin.LevelFogData.ApplyEnter(portalExit); Plugin.DisintegrationLoopFogData.ApplyExit(portalExit); GravityVolume val18 = MonoSingleton.Instance.gravityVolumes.LastOrDefault(); if ((Object)(object)val18 != (Object)null && (Object)(object)instancePortal == (Object)null) { portalExit.enterGravityVolume = val18; } else { _ = (Object)(object)instancePortal != (Object)null; } portalExit.maxRecursions = 4; oldPortalExitTravel = portalExit.onEntryTravel; portalExit.onEntryTravel = new UnityEventPortalTravel(); ((UnityEvent)(object)portalExit.onEntryTravel).AddListener((UnityAction)OnEnterExitDisintegrationLoop_Specific); ((UnityEvent)(object)portalExit.onExitTravel).AddListener((UnityAction)OnEnterDisintegrationLoop); val3.SetActive(true); _isOk = true; if (Plugin.DisplayFakeLevelTitle) { InteruptedLevelNamePopup = LevelNamePopupPatch.Fade(); } if (Plugin.HasLimboSky && doorStyle == DoorStyle.FirstRoom) { portalEnter.updateLimboSkybox = true; portalExit.updateLimboSkybox = true; } } private static void OnEnterDisintegrationLoop_Specific(IPortalTraveller traveler, PortalTravelDetails details) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown if ((int)traveler.travellerType != 1) { return; } ((UnityEvent)(object)oldPortalEntryTravel).Invoke(traveler, details); if (Plugin.DisplayFakeLevelTitle) { LevelNamePopupPatch.DisplayName("FRAUD /// THIRD", "DISINTEGRATION LOOP"); } if (Object.op_Implicit((Object)(object)MonoSingleton.Instance) && ((Behaviour)MonoSingleton.Instance).enabled) { MonoSingleton.Instance.SetRechargeMode(1f); } switch (_previousDoorStyle) { case DoorStyle.FirstRoom: { if (!((Object)(object)_currentFirstFinalDoor != (Object)null)) { break; } _currentFirstFinalDoor.Close(); object obj = <>c.<>9__63_2; if (obj == null) { UnityAction val = delegate { firstRoomFirstFinalDoor.SetActive(true); ((Component)portalEnter).gameObject.SetActive(false); }; <>c.<>9__63_2 = val; obj = (object)val; } UnityAction a1 = (UnityAction)obj; if ((Object)(object)_previousDoor != (Object)null) { _previousDoor.onFullyClosed.AddListener(a1); _previousDoor.onFullyClosed.AddListener((UnityAction)delegate { _previousDoor.onFullyClosed.RemoveListener(a1); }); } Door componentInChildren = firstRoomFinalDoorLeft.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { Plugin.Logger.LogError((object)"No firstRoomFinalDoorLeft???"); break; } Action run = delegate { _currentFirstFinalDoor.Open(); }; StupidScriptBecauseImLazy stupidScriptBecauseImLazy = ((Component)componentInChildren).gameObject.AddComponent(); stupidScriptBecauseImLazy._check = componentInChildren; stupidScriptBecauseImLazy._run = run; break; } default: Plugin.ForceDoorOpen(_previousDoor); break; case DoorStyle.Limbo: case DoorStyle.Wrath: case DoorStyle.Heresy: case DoorStyle.Violence: case DoorStyle.Fraud: { DoorStateCopy doorStateCopy = default(DoorStateCopy); if (doorPortalEnter.TryGetComponent(ref doorStateCopy)) { Object.Destroy((Object)(object)doorStateCopy); } DoorStateCopy doorStateCopy2 = doorPortalExit.AddComponent(); doorStateCopy2._copy = portalExitDoorController; doorStateCopy2._target = enteredDoorController; portalEnterDoorController.playerIn = false; Plugin.RunDelay(delegate { enteredDoorController.playerIn = true; }, 0.125f); break; } } Plugin.RunDelay(delegate { if (!DisableEnemySpawns.DisableArenaTriggers) { Door[] doors = Plugin.FindObjectInDisintegrationLoop("Pre-Space/Rooms/1 - Escher Entrance/1 Stuff/Trigger/Activator").GetComponent().doors; foreach (Door val2 in doors) { if (Object.op_Implicit((Object)(object)val2)) { val2.Lock(); } } } }, 0.5f); } private static void OnEnterExitDisintegrationLoop_Specific(IPortalTraveller traveler, PortalTravelDetails details) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_006a: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //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_00e7: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown IPortalTraveller traveler2 = traveler; if ((int)traveler2.travellerType != 1) { return; } ((UnityEvent)(object)oldPortalExitTravel).Invoke(traveler2, details); OnExitDisintegrationLoop(traveler2, details); object obj = <>c.<>9__64_0; if (obj == null) { UnityAction val = delegate { }; <>c.<>9__64_0 = val; obj = (object)val; } UnityAction a = (UnityAction)obj; switch (_previousDoorStyle) { case DoorStyle.FirstRoom: { if (!((Object)(object)_currentFirstFinalDoor != (Object)null)) { break; } _currentFirstFinalDoor.Close(); object obj2 = <>c.<>9__64_6; if (obj2 == null) { UnityAction val2 = delegate { _currentFirstFinalDoor.Open(); }; <>c.<>9__64_6 = val2; obj2 = (object)val2; } UnityAction a2 = (UnityAction)obj2; _previousDoor.onFullyClosed.AddListener(a2); _previousDoor.onFullyClosed.AddListener((UnityAction)delegate { _previousDoor.onFullyClosed.RemoveListener(a2); }); break; } default: Plugin.ResetDoor(_previousDoor); break; case DoorStyle.Violence: Plugin.RunDelay(delegate { DoorStateCopy doorStateCopy = default(DoorStateCopy); if (doorPortalExit.TryGetComponent(ref doorStateCopy)) { Object.Destroy((Object)(object)doorStateCopy); } portalExitDoorController.playerIn = true; a.Invoke(); }, 0.125f); break; case DoorStyle.Limbo: case DoorStyle.Wrath: case DoorStyle.Heresy: case DoorStyle.Fraud: Plugin.RunDelay(delegate { DoorStateCopy doorStateCopy2 = default(DoorStateCopy); if (doorPortalExit.TryGetComponent(ref doorStateCopy2)) { Object.Destroy((Object)(object)doorStateCopy2); } portalExitDoorController.playerIn = true; }, 0.125f); break; } MusicManager instance = MonoSingleton.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(MusicFadeToNormal()); } bool hasA = false; a = (UnityAction)delegate { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!hasA) { hasA = true; OnExitDisintegrationLoopFinal(traveler2, details); _cleanupPortals(); } }; _previousDoor.onFullyClosed.AddListener(a); Door capturedPrevDoor = _previousDoor; _previousDoor.onFullyClosed.AddListener((UnityAction)delegate { if ((Object)(object)capturedPrevDoor != (Object)null) { capturedPrevDoor.onFullyClosed.RemoveListener(a); } }); Plugin.RunDelay(delegate { if (!hasA) { Plugin.Logger.LogWarning((object)"resorting to backup close"); a.Invoke(); if ((Object)(object)_previousDoor != (Object)null) { _previousDoor.onFullyClosed.RemoveListener(a); } } }, 10f); } } [HarmonyPatch(typeof(PauseMenu), "OnEnable")] internal static class CheckpointPatches { private static void Postfix(PauseMenu __instance) { if (Plugin.IsInDisintegrationLoop) { ((Selectable)__instance.checkpointButton).interactable = false; } } } [HarmonyPatch(typeof(PortalManagerV2), "Update")] public class PortalManagerV2_Update_Transpiler { private static void CallMyCode() { bool flag = false; foreach (Portal portalComponent in MonoSingleton.Instance.portalComponents) { if (Object.op_Implicit((Object)(object)portalComponent) && ((Behaviour)portalComponent).enabled && ((Component)portalComponent).gameObject.activeInHierarchy) { flag = true; break; } } if (!flag) { if (Plugin.DisintegrationLoop.HasValue) { MonoSingleton.Instance.portalComponents.RemoveAll(delegate(Portal comp) { //IL_0006: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Scene scene = ((Component)comp).gameObject.scene; SceneInstance value = Plugin.DisintegrationLoop.Value; return scene == ((SceneInstance)(ref value)).Scene; }); } } else { if (ApplyDisintegrationLoopPatch.HasDisintegrated) { MonoSingleton.Instance.SendHudMessage("Unfortunately, clash mode doesn't work with portals", "", "", 0, false, false, true); } MonoSingleton.Instance.ChangeToFPS(); MonoSingleton.Instance.DisableCheat("ultrakill.clash-mode"); } } private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown List list = new List(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(PlayerTracker), "ChangeToFPS", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(CheatsManager), "DisableCheat", new Type[1] { typeof(string) }, (Type[])null); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i - 1] = new CodeInstruction(OpCodes.Nop, (object)null); list[i] = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PortalManagerV2_Update_Transpiler), "CallMyCode", (Type[])null, (Type[])null)); } if (CodeInstructionExtensions.Calls(list[i], methodInfo2)) { list[i - 2] = new CodeInstruction(OpCodes.Nop, (object)null); list[i - 1] = new CodeInstruction(OpCodes.Nop, (object)null); list[i] = new CodeInstruction(OpCodes.Nop, (object)null); } } return list; } } [HarmonyPatch] internal static class CompatabilityPatches { [HarmonyPatch(typeof(SceneManager))] public static class ScenePatches { public static List ignoreAsm = new List(40) { "Assembly-CSharp", "PrivateAPIEditorBridge.", "[REGEX] ^System\\..*", "[REGEX] ^Unity\\..*", "[REGEX] ^UnityEngine\\..*", "[REGEX] ^NewBlood\\..*", "plog", "plog.unity", "pcon.core", "UnityUIExtensions", "Vertx.Debugging.Runtime", "Autodesk.Fbx", "Bcl.CollectionsMarshal", "Facepunch.Steamworks.Win64", "NavMeshComponents", "netstandard", "Naelstrof.JigglePhysics", "Mono.Security", "FbxBuildTestAssets", "0Harmony", "0Harmony20", "BepInEx", "BepInEx.Harmony", "BepInEx.Preloader", "HarmonyXInterop", "Mono.Cecil", "Mono.Cecil.Mdb", "Mono.Cecil.Pdb", "Mono.Cecil.Rocks", "MonoMod.RuntimeDetour", "MonoMod.Utils", "UnityExplorer.BIE5.Mono", "UniverseLib.Mono", "IntroSkip", "PluginConfigurator", "PluginConfiguratorComponents", "AngryLevelLoader", "allroadsleadtofraud", "ohpointwoinfinitevoid", "cheatsfix" }; [HarmonyPatch(typeof(SceneManager), "Internal_SceneLoaded")] [HarmonyPrefix] private static bool Prefix_Internal_SceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if ((int)mode != 1) { return true; } if (!Plugin.ModCompatabilityMode) { return true; } if (!((Scene)(ref scene)).GetRootGameObjects().Any(delegate(GameObject g) { string text = ((Object)g).name.ToLower(); return (text == "pre-space" || text == "intromusicintro") ? true : false; })) { return true; } if (!(typeof(SceneManager).GetField("sceneLoaded", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is UnityAction val)) { return true; } Delegate[] invocationList = ((Delegate)(object)val).GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { UnityAction val2 = (UnityAction)(object)invocationList[i]; if (ShouldReceiveEvent((Delegate)(object)val2)) { try { val2.Invoke(scene, mode); } catch (Exception ex) { Debug.LogException(ex); } } else { _ = ((Delegate)(object)val2).Target; } } return false; } private static bool ShouldReceiveEvent(Delegate action) { string name = (action.Target?.GetType() ?? action.Method.DeclaringType).Assembly.GetName().Name; if (Plugin.ModCompatabilityMode) { foreach (string item in ignoreAsm) { if (item.StartsWith("[REGEX] ")) { string pattern = item.Substring(8); if (Regex.IsMatch(name, pattern)) { return true; } } else if (name == item) { return true; } } return false; } return true; } } } [HarmonyPatch(typeof(NewMovement), "Respawn")] internal static class DeathPatch { private static void Postfix(NewMovement __instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (Plugin.IsInDisintegrationLoop) { ((Component)MonoSingleton.Instance).transform.position = new Vector3(-14.19f, 8138.42f, 449.25f); } } } [HarmonyPatch(typeof(TeleportCheat), "Teleport")] internal static class TeleportCheatPatche { private static void Postfix(TeleportCheat __instance) { if (Plugin.IsInDisintegrationLoop) { ApplyDisintegrationLoopPatch.LeaveDisintegrationLoop(cleanupPortals: true, allowReload: true, didntTravelThroughPortal: true); } } } [HarmonyPatch(typeof(OnLevelStart), "StartLevel")] internal static class OnLevelStartPatch { public static void Prefix(OnLevelStart __instance) { if (__instance.levelNameOnStart && ApplyDisintegrationLoopPatch.HasDisintegrated) { __instance.levelNameOnStart = false; ApplyDisintegrationLoopPatch.InteruptedLevelNamePopup = true; } } } [HarmonyPatch(typeof(LevelNamePopup))] internal static class LevelNamePopupPatch { [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator original; public LevelNamePopup instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_0119: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_0045; case 1: <>1__state = -1; goto IL_0045; case 2: { <>1__state = -1; break; } IL_0045: if (original.MoveNext()) { <>2__current = original.Current; <>1__state = 1; return true; } break; } if (instance.fadingOut) { <>2__current = null; <>1__state = 2; return true; } SafeToGrab = true; instance.activated = false; instance.layerString = _lastTitle; instance.nameString = _lastSubtitle; ((Graphic)instance.layerText).color = new Color(((Graphic)instance.layerText).color.r, ((Graphic)instance.layerText).color.g, ((Graphic)instance.layerText).color.b, 1f); ((Graphic)instance.nameText).color = ((Graphic)instance.layerText).color; instance.layerText.text = ""; instance.nameText.text = ""; instance.currentLetter = 0; instance.fadingOut = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static bool DidReplace = false; internal static bool SafeToGrab = true; private static string _lastTitle; private static string _lastSubtitle; public static bool Fade() { if ((Object)(object)MonoSingleton.Instance != (Object)null) { LevelNamePopup instance = MonoSingleton.Instance; bool fadingOut = instance.fadingOut; bool flag = instance.currentLetter >= instance.nameString.Length; instance.fadingOut = true; ((MonoBehaviour)instance).StopAllCoroutines(); instance.aud.Stop(); bool activated = instance.activated; instance.activated = true; if (!fadingOut && !flag && activated) { return SafeToGrab; } return false; } return false; } public static void DisplayDefault() { DisplayName(_lastTitle, _lastSubtitle, 0f); } public static void DisplayName(string title, string subtite, float delay = 1.5f) { string title2 = title; string subtite2 = subtite; if (SafeToGrab && Object.op_Implicit((Object)(object)MonoSingleton.Instance)) { _lastTitle = MonoSingleton.Instance.layerString; _lastSubtitle = MonoSingleton.Instance.nameString; } Plugin.RunDelay(delegate { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) SafeToGrab = false; DidReplace = true; LevelNamePopup instance = MonoSingleton.Instance; if (Object.op_Implicit((Object)(object)instance)) { instance.fadingOut = false; ((Graphic)instance.layerText).color = new Color(((Graphic)instance.layerText).color.r, ((Graphic)instance.layerText).color.g, ((Graphic)instance.layerText).color.b, 1f); ((Graphic)instance.nameText).color = ((Graphic)instance.layerText).color; instance.layerText.text = ""; instance.nameText.text = ""; instance.activated = false; instance.layerString = title2; instance.nameString = subtite2; ((MonoBehaviour)instance).StopAllCoroutines(); instance.NameAppear(); } }, delay); } [HarmonyPatch(typeof(LevelNameActivator), "GoTime")] [HarmonyPrefix] private static void Prefix_GoTime(LevelNameActivator __instance) { if (ApplyDisintegrationLoopPatch.HasDisintegrated) { ApplyDisintegrationLoopPatch.InteruptedLevelNamePopup = true; } } [HarmonyPatch(typeof(LevelNamePopup), "NameAppear")] [HarmonyPrefix] private static void Prefix_NameAppear(LevelNamePopup __instance) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_006f: Unknown result type (might be due to invalid IL or missing references) if (!SafeToGrab && __instance.fadingOut) { __instance.fadingOut = true; ((Graphic)__instance.layerText).color = new Color(((Graphic)__instance.layerText).color.r, ((Graphic)__instance.layerText).color.g, ((Graphic)__instance.layerText).color.b, 1f); ((Graphic)__instance.nameText).color = ((Graphic)__instance.layerText).color; __instance.layerText.text = ""; __instance.nameText.text = ""; __instance.activated = false; ((MonoBehaviour)__instance).StopAllCoroutines(); } if (SafeToGrab) { _lastTitle = MonoSingleton.Instance.layerString; _lastSubtitle = MonoSingleton.Instance.nameString; } } [HarmonyPatch(typeof(LevelNamePopup), "ShowNameText")] [HarmonyPostfix] private static void Postfix_ShowNameText(LevelNamePopup __instance, ref IEnumerator __result) { if (DidReplace) { DidReplace = false; __result = RunAfter(__result, __instance); } } [IteratorStateMachine(typeof(d__10))] private static IEnumerator RunAfter(IEnumerator original, LevelNamePopup instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { original = original, instance = instance }; } } [HarmonyPatch(typeof(AudioMixerController), "SetMusicVolume")] internal static class AudioMixerControllerPatch { private static float _musicVolumeOverride = -1f; internal static float MusicVolumeOverride { get { return _musicVolumeOverride; } set { _musicVolumeOverride = value; AudioMixerController instance = MonoSingleton.Instance; if (Object.op_Implicit((Object)(object)instance) && !(MusicVolumeOverride <= -0.5f) && !instance.forceOff) { instance.musicSound.SetFloat("allVolume", instance.CalculateVolume(MusicVolumeOverride)); } } } private static bool Prefix(AudioMixerController __instance, float volume) { if (MusicVolumeOverride <= -0.5f) { return true; } if (!__instance.forceOff) { __instance.musicSound.SetFloat("allVolume", __instance.CalculateVolume(MusicVolumeOverride)); } __instance.musicVolume = volume; return false; } } [HarmonyPatch(typeof(MusicManager))] [ConfigureSingleton(/*Could not decode attribute arguments.*/)] [DefaultExecutionOrder(600)] public class DisintegrationLoopMusicManager : MonoSingleton { [HarmonyPatch(typeof(FinalPit), "OnTriggerEnter")] private static class Patch_MusicOffLevelEnd { private static void Prefix(FinalPit __instance, Collider other) { if (Plugin.IsInDisintegrationLoop && Object.op_Implicit((Object)(object)MonoSingleton.Instance) && __instance.musicFadeOut && (Object)(object)((Component)other).gameObject == (Object)(object)__instance.player && Object.op_Implicit((Object)(object)MonoSingleton.Instance) && MonoSingleton.Instance.hp > 0) { MonoSingleton.Instance.off = true; } } } [HarmonyPatch(typeof(MusicManager), "FilterMusic")] private static class Patch_FilterMusic { private static void Prefix(MusicManager __instance) { if (Object.op_Implicit((Object)(object)MonoSingleton.Instance)) { MonoSingleton.Instance?.FilterMusic(); } } } [HarmonyPatch(typeof(MusicManager), "UnfilterMusic")] private static class Patch_UnfilterMusic { private static void Prefix(MusicManager __instance) { if (Object.op_Implicit((Object)(object)MonoSingleton.Instance)) { MonoSingleton.Instance?.UnfilterMusic(); } } } public bool off = true; public AudioSource battleTheme; public AudioSource cleanTheme; public AudioSource bossTheme; public AudioSource targetTheme; private AudioSource[] allThemes; public float volume = 1f; private float defaultVolume = 1f; public float fadeSpeed = 1f; private float fadeOutSpeed = 4f; private bool filtering; private bool _off; private void OnEnable() { //IL_0031: 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_00fb: Unknown result type (might be due to invalid IL or missing references) if ((double)fadeSpeed == 0.0) { fadeSpeed = 1f; } if ((Object)(object)battleTheme == (Object)null) { battleTheme = new GameObject("BattleTheme").AddComponent(); battleTheme.outputAudioMixerGroup = Plugin.DisintegrationLoopMixerOut; battleTheme.volume = 0f; ((Component)battleTheme).transform.parent = ((Component)this).transform; battleTheme.loop = true; } if ((Object)(object)cleanTheme == (Object)null) { cleanTheme = new GameObject("CleanTheme").AddComponent(); cleanTheme.outputAudioMixerGroup = Plugin.DisintegrationLoopMixerOut; cleanTheme.volume = 0f; ((Component)cleanTheme).transform.parent = ((Component)this).transform; cleanTheme.loop = true; } if ((Object)(object)bossTheme == (Object)null) { bossTheme = new GameObject("BossTheme").AddComponent(); bossTheme.outputAudioMixerGroup = Plugin.DisintegrationLoopMixerOut; bossTheme.volume = 0f; ((Component)bossTheme).transform.parent = ((Component)this).transform; bossTheme.loop = true; } allThemes = ((Component)this).GetComponentsInChildren(); defaultVolume = volume; if (!off) { AudioSource[] array = allThemes; for (int i = 0; i < array.Length; i++) { AudioSourceExtensions.Play(array[i], true); } cleanTheme.volume = volume; targetTheme = cleanTheme; } else { targetTheme = ((Component)this).GetComponent(); } UnfilterMusic(); } public void FilterMusic() { filtering = true; Plugin.DisintegrationLoopMixer.FindSnapshot("Paused").TransitionTo(0f); } public void UnfilterMusic() { filtering = false; Plugin.DisintegrationLoopMixer.FindSnapshot("Unpaused").TransitionTo(0.5f); } private void Update() { MusicManager instance = MonoSingleton.Instance; if (_off != off) { _off = off; if (!off) { AudioSource[] array = allThemes; for (int i = 0; i < array.Length; i++) { AudioSourceExtensions.Play(array[i], true); } cleanTheme.volume = volume; targetTheme = cleanTheme; } } AudioSource val = instance.targetTheme; if ((Object)(object)val == (Object)(object)instance.battleTheme) { targetTheme = battleTheme; } else if ((Object)(object)val == (Object)(object)instance.cleanTheme) { targetTheme = cleanTheme; } else if ((Object)(object)val == (Object)(object)instance.bossTheme) { targetTheme = bossTheme; } AudioMixerController instance2 = MonoSingleton.Instance; Plugin.DisintegrationLoopMixer.SetFloat("allVolume", instance2.CalculateVolume(instance2.optionsMusicVolume)); instance2.SetMusicVolume(MonoSingleton.Instance.musicVolume); if (!off && !Mathf.Approximately(targetTheme.volume, volume)) { AudioSource[] array = allThemes; foreach (AudioSource val2 in array) { if ((Object)(object)val2 == (Object)(object)targetTheme) { if ((double)val2.volume > (double)volume) { val2.volume = volume; } val2.volume = (((double)Time.timeScale != 0.0) ? Mathf.MoveTowards(val2.volume, volume, fadeSpeed * Time.deltaTime) : volume); } else { val2.volume = (((double)Time.timeScale != 0.0) ? Mathf.MoveTowards(val2.volume, 0f, fadeSpeed * Time.deltaTime) : 0f); } } if (Mathf.Approximately(targetTheme.volume, volume)) { array = allThemes; foreach (AudioSource val3 in array) { if ((Object)(object)val3 != (Object)(object)targetTheme) { val3.volume = 0f; } } } } if ((double)volume == 0.0 || off) { AudioSource[] array = allThemes; foreach (AudioSource obj in array) { obj.volume = Mathf.MoveTowards(obj.volume, 0f, Time.deltaTime / 5f * fadeSpeed * fadeOutSpeed); } } } } [HarmonyPatch(typeof(OnLevelStart), "StartLevel")] internal static class OLSFogPatch { private static void Postfix(OnLevelStart __instance) { if (!__instance.activated) { Plugin._levelFogData.UseFog |= __instance.hideFogUntilStart; } } } [HarmonyPatch(typeof(FogEnabler), "Activate")] internal static class FogPatch { private static bool canApply = true; private static bool skip = false; private static bool Prefix(FogEnabler __instance) { FogEnabler __instance2 = __instance; if (skip) { skip = false; return true; } if (Plugin.IsInDisintegrationLoop) { Plugin.RunAfterDisintegrationLoop.Enqueue(delegate { if (Object.op_Implicit((Object)(object)__instance2)) { skip = true; __instance2.Activate(); } }); canApply = false; return false; } return true; } private static void Postfix(FogEnabler __instance) { if (!canApply) { canApply = true; } else { Plugin.ForceUpdateFogState(); } } } [HarmonyPatch(typeof(TimeOfDayChanger))] internal static class TimeOfDayPatch { private static bool skip = false; internal static HashSet doneChangers = new HashSet(); [HarmonyPatch("Activate")] [HarmonyPrefix] private static bool Activate_Prefix(TimeOfDayChanger __instance) { TimeOfDayChanger __instance2 = __instance; if (skip) { return true; } if (Plugin.IsInDisintegrationLoop) { Plugin.RunAfterDisintegrationLoop.Enqueue(delegate { if (Object.op_Implicit((Object)(object)__instance2)) { skip = true; __instance2.Activate(); } }); return false; } return true; } [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update_Postfix(TimeOfDayChanger __instance) { if (__instance.allDone) { if (doneChangers.Add(__instance)) { Plugin.ForceUpdateFogState(); } } else if (doneChangers.Contains(__instance)) { doneChangers.Remove(__instance); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }