using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; 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; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CullFactory.Behaviours.API; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.Rendering.RendererUtils; using UnityEngine.SceneManagement; using com.github.zehsteam.ImmersiveEntrance.Dependencies.CullFactoryMod; using com.github.zehsteam.ImmersiveEntrance.Dependencies.LethalConfigMod; using com.github.zehsteam.ImmersiveEntrance.Extensions; using com.github.zehsteam.ImmersiveEntrance.Helpers; using com.github.zehsteam.ImmersiveEntrance.Helpers.IL; using com.github.zehsteam.ImmersiveEntrance.Managers; using com.github.zehsteam.ImmersiveEntrance.MonoBehaviours; using com.github.zehsteam.ImmersiveEntrance.Objects; using com.github.zehsteam.ImmersiveEntrance.Objects.PortalSettingTypes; using com.github.zehsteam.ImmersiveEntrance.Patches; using com.github.zehsteam.ImmersiveEntrance.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyDescription("See the other side through the main entrance doors.")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+374a5d67af37c811643542e8ec33ad14fedc93a6")] [assembly: AssemblyProduct("ImmersiveEntrance")] [assembly: AssemblyTitle("com.github.zehsteam.ImmersiveEntrance")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [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 com.github.zehsteam.ImmersiveEntrance { internal static class Assets { public static readonly string AssetBundleFileName = "immersiveentrance_assets"; public static AssetBundle AssetBundle { get; private set; } public static bool IsLoaded { get; private set; } public static GameObject DoorPortalPrefab { get; private set; } public static Shader PosterizeShader { get; private set; } public static EntranceDoorReplacement MansionEntranceDoorReplacement { get; private set; } public static void Load() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, AssetBundleFileName); if (!File.Exists(text)) { Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text + "\". Make sure the \"" + AssetBundleFileName + "\" file is in the same folder as the mod's DLL file."); } else { AssetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)AssetBundle == (Object)null) { Logger.LogFatal("Failed to load assets. AssetBundle is null."); return; } OnAssetBundleLoaded(AssetBundle); IsLoaded = true; } } private static void OnAssetBundleLoaded(AssetBundle assetBundle) { DoorPortalPrefab = LoadAsset("DoorPortal", assetBundle); PosterizeShader = LoadAsset("Posterize", assetBundle); MansionEntranceDoorReplacement = LoadAsset("MansionEntranceDoorReplacement", assetBundle); } private static T LoadAsset(string name, AssetBundle assetBundle) where T : Object { if (string.IsNullOrWhiteSpace(name)) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."); return default(T); } if ((Object)(object)assetBundle == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."); return default(T); } T val = assetBundle.LoadAsset(name); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."); return default(T); } return val; } private static bool TryLoadAsset(string name, AssetBundle assetBundle, out T asset) where T : Object { asset = LoadAsset(name, assetBundle); return (Object)(object)asset != (Object)null; } } internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static bool IsExtendedLoggingEnabled => ConfigManager.Misc_ExtendedLogging?.Value ?? false; public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogMessage(object data, bool extended = false) { Log((LogLevel)8, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } } [BepInPlugin("com.github.zehsteam.ImmersiveEntrance", "ImmersiveEntrance", "1.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.github.zehsteam.ImmersiveEntrance"); internal static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.ImmersiveEntrance")); Logger.LogInfo("ImmersiveEntrance has awoken!"); _harmony.PatchAll(typeof(StartOfRound_Patches)); _harmony.PatchAll(typeof(RoundManager_Patches)); _harmony.PatchAll(typeof(TimeOfDay_Patches)); _harmony.PatchAll(typeof(MatchLocalPlayerPosition_Patches)); _harmony.PatchAll(typeof(EntranceTeleport_Patches)); Assets.Load(); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.ImmersiveEntrance"; public const string PLUGIN_NAME = "ImmersiveEntrance"; public const string PLUGIN_VERSION = "1.1.2"; } } namespace com.github.zehsteam.ImmersiveEntrance.Rendering { public class PosterizationCustomPass : CustomPass { public static Material PosterizationMaterial; public static Shader PosterizationShader; public static RTHandle PosterizationRT; public static RTHandle ExclusionMaskRT; protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) PosterizationShader = Assets.PosterizeShader; PosterizationRT = RTHandles.Alloc(Vector2.one, TextureXR.slices, (DepthBits)0, (GraphicsFormat)74, (FilterMode)0, (TextureWrapMode)0, TextureXR.dimension, false, false, true, false, 1, 0f, (MSAASamples)1, false, true, (RenderTextureMemoryless)0, (VRTextureUsage)0, "Posterization Buffer"); PosterizationMaterial = CoreUtils.CreateEngineMaterial(PosterizationShader); ExclusionMaskRT = RTHandles.Alloc(Vector2.one, TextureXR.slices, (DepthBits)0, (GraphicsFormat)5, (FilterMode)0, (TextureWrapMode)0, TextureXR.dimension, false, false, true, false, 1, 0f, (MSAASamples)1, false, true, (RenderTextureMemoryless)0, (VRTextureUsage)0, "Exclusion Mask Buffer"); } protected override void Execute(CustomPassContext ctx) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) //IL_0039: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_01f5: Unknown result type (might be due to invalid IL or missing references) CoreUtils.SetRenderTarget(ctx.cmd, ExclusionMaskRT, ctx.cameraDepthBuffer, (ClearFlag)1, Color.white, 0, (CubemapFace)(-1), -1); RendererListDesc val = default(RendererListDesc); ((RendererListDesc)(ref val))..ctor((ShaderTagId[])(object)new ShaderTagId[1] { new ShaderTagId("PosterizeExclusion") }, ctx.cullingResults, ctx.hdCamera.camera); val.rendererConfiguration = (PerObjectData)0; val.renderQueueRange = RenderQueueRange.all; val.sortingCriteria = (SortingCriteria)0; RendererListDesc val2 = val; ScriptableRenderContext renderContext = ctx.renderContext; CommandBuffer cmd = ctx.cmd; ScriptableRenderContext renderContext2 = ctx.renderContext; CoreUtils.DrawRendererList(renderContext, cmd, ((ScriptableRenderContext)(ref renderContext2)).CreateRendererList(val2)); ctx.propertyBlock.SetFloat("_OutlineThickness", 0.001f); ctx.propertyBlock.SetFloat("_DepthThreshold", 0.4f); ctx.propertyBlock.SetFloat("_DepthCurve", 0.4f); ctx.propertyBlock.SetFloat("_DepthStrength", 6f); ctx.propertyBlock.SetFloat("_ColorThreshold", 0.47f); ctx.propertyBlock.SetFloat("_ColorCurve", 2.94f); ctx.propertyBlock.SetFloat("_ColorStrength", 0.65f); ctx.propertyBlock.SetTexture("_ExclusionMaskBuffer", RTHandle.op_Implicit(ExclusionMaskRT)); ctx.propertyBlock.SetFloat("_PlayerCameraNearClipPlane", 0.05f); ctx.propertyBlock.SetFloat("_PlayerCameraFarClipPlane", 400f); bool value = ConfigManager.Debug_UseSimulatedDeviceDepth.Value; ctx.propertyBlock.SetInt("_UseSimulatedDeviceDepth", value ? 1 : 0); CoreUtils.SetRenderTarget(ctx.cmd, PosterizationRT, (ClearFlag)7, 0, (CubemapFace)(-1), -1); CoreUtils.DrawFullScreen(ctx.cmd, PosterizationMaterial, ctx.propertyBlock, PosterizationMaterial.FindPass("ReadColor")); ctx.propertyBlock.SetTexture("_PosterizationBuffer", RTHandle.op_Implicit(PosterizationRT)); CoreUtils.SetRenderTarget(ctx.cmd, ctx.cameraColorBuffer, (ClearFlag)0, 0, (CubemapFace)(-1), -1); CoreUtils.DrawFullScreen(ctx.cmd, PosterizationMaterial, ctx.propertyBlock, PosterizationMaterial.FindPass("WriteColor")); } protected override void Cleanup() { CoreUtils.Destroy((Object)(object)PosterizationMaterial); PosterizationRT.Release(); ExclusionMaskRT.Release(); } } } namespace com.github.zehsteam.ImmersiveEntrance.Patches { [HarmonyPatch(typeof(EntranceTeleport))] internal static class EntranceTeleport_Patches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake_Patch(EntranceTeleport __instance) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (Logger.IsExtendedLoggingEnabled) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("| EntranceTeleport.Awake();"); stringBuilder.AppendLine("| "); stringBuilder.AppendLine("| " + __instance.GetLogInfo()); stringBuilder.AppendLine("| "); stringBuilder.AppendLine("| Moon: \"" + LevelHelper.GetCurrentMoonName() + "\""); stringBuilder.AppendLine("| Interior: \"" + InteriorHelper.GetCurrentInteriorName() + "\""); stringBuilder.AppendLine("| "); Scene scene = ((Component)__instance).gameObject.scene; stringBuilder.AppendLine("| Scene: \"" + ((Scene)(ref scene)).name + "\""); stringBuilder.AppendLine("| Hierarchy path: \"" + ((Component)__instance).transform.GetHierarchyPath() + "\""); Logger.LogInfo("\n\n" + stringBuilder.ToString().Trim() + "\n"); } EntranceManager.SpawnDoorPortal(__instance); } } [HarmonyPatch(typeof(MatchLocalPlayerPosition))] internal static class MatchLocalPlayerPosition_Patches { [HarmonyPatch("LateUpdate")] [HarmonyPrefix] private static bool LateUpdate_Patch(MatchLocalPlayerPosition __instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!PlayerUtils.IsLocalPlayerCameraInsideInterior()) { return true; } if (DoorPortal.TryGetRenderingInstance(out var doorPortal)) { ((Component)__instance).transform.position = ((Component)doorPortal.PortalCamera).transform.position; return false; } return false; } } [HarmonyPatch(typeof(RoundManager))] internal static class RoundManager_Patches { [HarmonyPatch("FinishGeneratingNewLevelClientRpc")] [HarmonyPostfix] private static void FinishGeneratingNewLevelClientRpc_Patch(RoundManager __instance) { if (NetworkUtils.IsExecutingRPCMethod((NetworkBehaviour)(object)__instance)) { Logger.LogInfo("Current moon is " + LevelHelper.GetCurrentMoonName()); Logger.LogInfo("Current interior is " + InteriorHelper.GetCurrentInteriorName()); EntranceManager.LinkMainEntrancePortals(); } } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRound_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] [HarmonyPriority(0)] private static void Start_Patch() { PortalSettingsManager.Initialize(); CustomPassHelper.ReplaceVanillaCustomPass(); } [HarmonyPatch("EndOfGame")] [HarmonyPostfix] private static void EndOfGame_Patch() { EntranceManager.Reset(); LevelHelper.Reset(); } [HarmonyPatch("OnLocalDisconnect")] [HarmonyPostfix] private static void OnLocalDisconnect_Patch() { EntranceManager.Reset(); LevelHelper.Reset(); } } [HarmonyPatch(typeof(TimeOfDay))] internal static class TimeOfDay_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch(TimeOfDay __instance) { ((Component)__instance).gameObject.AddComponent(); } [HarmonyPatch("SetInsideLightingDimness")] [HarmonyPostfix] private static void SetInsideLightingDimness_Patch(TimeOfDay __instance) { float lightDimmer = (PlayerUtils.IsLocalPlayerCameraInsideInterior() ? 0f : 1f); __instance.indirectLightData.lightDimmer = lightDimmer; } [HarmonyPatch("SetWeatherEffects")] [HarmonyPrefix] private static void SetWeatherEffects_Patch(TimeOfDay __instance) { if (ConfigManager.PortalGraphics_WeatherEffectsEnabled.Value && LevelHelper.IsForceWeatherEffectsEnabled) { __instance.SetCurrentLevelWeatherEnabled(value: true); } } [HarmonyPatch("SetWeatherEffects")] [HarmonyTranspiler] private static IEnumerable SetWeatherEffects_Transpiler(IEnumerable instructions) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown ILInjector iLInjector = new ILInjector(instructions); iLInjector.Find(ILMatcher.Call(typeof(StartOfRound).GetProperty("Instance").GetMethod, "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 52), ILMatcher.Ldfld(typeof(StartOfRound).GetField("spectateCamera"), "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 53), ILMatcher.Callvirt(typeof(Component).GetProperty("transform").GetMethod, "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 54), ILMatcher.Callvirt(typeof(Transform).GetProperty("position").GetMethod, "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 55), ILMatcher.Stloc().CaptureAs(out var variable)); if (iLInjector.IsValid) { iLInjector.ReplaceLastMatch(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelHelper), "GetPositionForWeatherEffects", (Type[])null, (Type[])null)), variable); iLInjector.Find(ILMatcher.Call(typeof(StartOfRound).GetProperty("Instance").GetMethod, "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 74), ILMatcher.Ldfld(typeof(StartOfRound).GetField("localPlayerController"), "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 75), ILMatcher.Callvirt(typeof(Component).GetProperty("transform").GetMethod, "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 76), ILMatcher.Callvirt(typeof(Transform).GetProperty("position").GetMethod, "SetWeatherEffects_Transpiler", "./Patches/TimeOfDay_Patches.cs", 77), ILMatcher.Stloc().CaptureAs(out var variable2)); if (iLInjector.IsValid) { iLInjector.ReplaceLastMatch(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelHelper), "GetPositionForWeatherEffects", (Type[])null, (Type[])null)), variable2); return iLInjector.ReleaseInstructions(); } Logger.LogError("[TimeOfDay_Patches] SetWeatherEffects_Transpiler: Failed to run! Could not match instructions."); return instructions; } Logger.LogError("[TimeOfDay_Patches] SetWeatherEffects_Transpiler: Failed to run! Could not match instructions."); return instructions; } } } namespace com.github.zehsteam.ImmersiveEntrance.Objects { [CreateAssetMenu(menuName = "ImmersiveEntrance/EntranceDoorReplacement", order = 0, fileName = "EntranceDoorReplacement")] public class EntranceDoorReplacement : ScriptableObject { [field: SerializeField] public GameObject DoorFrame { get; private set; } [field: SerializeField] public GameObject DoorLeft { get; private set; } [field: SerializeField] public GameObject DoorRight { get; private set; } } public class EntranceObjects { public bool IsOutside; public GameObject ViewBlocker; public GameObject DoorFrame; public GameObject DoorLeft; public GameObject DoorRight; public bool IsValid() { if ((Object)(object)ViewBlocker == (Object)null) { return false; } if (!IsOutside && (Object)(object)DoorFrame == (Object)null) { return false; } if ((Object)(object)DoorLeft == (Object)null) { return false; } if ((Object)(object)DoorRight == (Object)null) { return false; } return true; } public void SetViewBlockerEnabled(bool value) { GameObject viewBlocker = ViewBlocker; if (viewBlocker != null) { viewBlocker.SetActive(value); } } public void SetObjectsEnabled(bool value) { GameObject doorFrame = DoorFrame; if (doorFrame != null) { doorFrame.SetActive(value); } GameObject doorLeft = DoorLeft; if (doorLeft != null) { doorLeft.SetActive(value); } GameObject doorRight = DoorRight; if (doorRight != null) { doorRight.SetActive(value); } } public void LogMissingObjects() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Format("[{0}] (IsOutside: {1}) is missing these objects:", "EntranceObjects", IsOutside)); if ((Object)(object)ViewBlocker == (Object)null) { stringBuilder.AppendLine("- ViewBlocker"); } if ((Object)(object)DoorFrame == (Object)null) { stringBuilder.AppendLine("- DoorFrame"); } if ((Object)(object)DoorLeft == (Object)null) { stringBuilder.AppendLine("- DoorLeft"); } if ((Object)(object)DoorRight == (Object)null) { stringBuilder.AppendLine("- DoorRight"); } Logger.LogWarning(stringBuilder.ToString()); } } public enum InteriorType { Facility = 0, Mansion = 1, Mineshaft = 2, Unknown = 999 } public class MainEntranceData { public EntranceTeleport EntranceTeleport { get; set; } public DoorPortal DoorPortal { get; set; } public EntranceObjects EntranceObjects { get; set; } public bool IsOutside => EntranceTeleport.IsOutside(); public bool HasEntranceTeleport => (Object)(object)EntranceTeleport != (Object)null; public bool HasDoorPortal => (Object)(object)DoorPortal != (Object)null; public void Reset() { EntranceTeleport = null; if ((Object)(object)DoorPortal != (Object)null) { Object.Destroy((Object)(object)DoorPortal); } EntranceObjects = null; } } public enum NearClipPlaneMode { Default, ObliqueProjection } public struct Padding { public float Left { get; set; } public float Right { get; set; } public float Top { get; set; } public float Bottom { get; set; } public Padding(float left, float right, float top, float bottom) { Left = left; Right = right; Top = top; Bottom = bottom; } } public enum PixelResolutionType { PlayerCamera, Default, Performance, UltraPerformance, Retro } } namespace com.github.zehsteam.ImmersiveEntrance.Objects.PortalSettingTypes { public class InteriorPortalSettings : PortalSettings { public struct InteriorDefaultValues { public Func GetDoorReplacement { get; set; } public InteriorDefaultValues() { GetDoorReplacement = null; } public InteriorDefaultValues(Func getDoorReplacement = null) { GetDoorReplacement = getDoorReplacement; } } private InteriorDefaultValues _interiorDefaultValues; private bool _boundConfigs; public InteriorType InteriorType { get; private set; } = InteriorType.Unknown; public string DungeonFlowName { get; private set; } public bool HasDoorReplacement => GetDoorReplacement != null; public Func GetDoorReplacement => _interiorDefaultValues.GetDoorReplacement; public ConfigEntry ReplaceDoor { get; private set; } public override string ConfigSection => "Interior: " + GetInteriorName(); public InteriorPortalSettings(InteriorType interiorType, InteriorDefaultValues interiorDefaultValues, DefaultValues defaultValues) : base(defaultValues) { InteriorType = interiorType; _interiorDefaultValues = interiorDefaultValues; } public InteriorPortalSettings(string dungeonFlowName, InteriorDefaultValues interiorDefaultValues, DefaultValues defaultValues) : base(defaultValues) { InteriorType = InteriorType.Unknown; DungeonFlowName = dungeonFlowName; _interiorDefaultValues = interiorDefaultValues; } public override void BindConfigs() { if (!_boundConfigs) { _boundConfigs = true; base.BindConfigs(); if (HasDoorReplacement) { ReplaceDoor = ConfigHelper.Bind(ConfigSection, "ReplaceDoor", defaultValue: true, "If enabled, will replace the door model."); } } } public bool Matches(DungeonFlow dungeonFlow) { InteriorType interiorType = InteriorHelper.GetInteriorType(dungeonFlow); if (interiorType == InteriorType.Unknown) { return ((Object)dungeonFlow).name.Equals(DungeonFlowName, StringComparison.OrdinalIgnoreCase); } return interiorType == InteriorType; } public string GetInteriorName() { if (InteriorType != InteriorType.Unknown) { return InteriorType.ToString(); } return DungeonFlowName; } } public class MoonPortalSettings : PortalSettings { public string PlanetName { get; private set; } public override string ConfigSection => "Moon: " + PlanetName; public MoonPortalSettings(string planetName, DefaultValues defaultValues) : base(defaultValues) { PlanetName = planetName; } public bool Matches(SelectableLevel level) { return PlanetName.Equals(level.PlanetName, StringComparison.OrdinalIgnoreCase); } public string GetStrippedPlanetName() { if (!PlanetName.Contains(" ")) { return PlanetName; } return PlanetName.Substring(PlanetName.IndexOf(" ")); } } public abstract class PortalSettings { public struct DefaultValues { public bool Enabled { get; set; } public bool UseDynamicPivot { get; set; } public Vector3 PivotPositionOffset { get; set; } public Vector3 PivotRotationOffset { get; set; } public Padding ScreenCrop { get; set; } public bool UseViewDistance { get; set; } public float ViewDistance { get; set; } public DefaultValues() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) PivotPositionOffset = default(Vector3); PivotRotationOffset = default(Vector3); ScreenCrop = default(Padding); UseViewDistance = false; Enabled = true; UseDynamicPivot = true; ViewDistance = 50f; } public DefaultValues(bool enabled = true, bool useDynamicPivot = true, Vector3? pivotPositionOffset = null, Vector3? pivotRotationOffset = null, Padding? screenCrop = null, float? viewDistance = null) { //IL_0023: 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_0043: 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) Enabled = enabled; UseDynamicPivot = useDynamicPivot; PivotPositionOffset = (Vector3)(((??)pivotPositionOffset) ?? Vector3.zero); PivotRotationOffset = (Vector3)(((??)pivotRotationOffset) ?? Vector3.zero); ScreenCrop = screenCrop.GetValueOrDefault(); UseViewDistance = viewDistance.HasValue; ViewDistance = viewDistance.GetValueOrDefault(50f); } } protected DefaultValues _defaultValues; public ConfigEntry Enabled { get; private set; } public bool UseDynamicPivot => _defaultValues.UseDynamicPivot; public Vector3 PivotPositionOffset => _defaultValues.PivotPositionOffset; public Vector3 PivotRotationOffset => _defaultValues.PivotRotationOffset; public Padding ScreenCrop => _defaultValues.ScreenCrop; public ConfigEntry UseViewDistance { get; private set; } public ConfigEntry ViewDistance { get; private set; } public abstract string ConfigSection { get; } public PortalSettings(DefaultValues defaultValues) { _defaultValues = defaultValues; } public virtual void BindConfigs() { Enabled = ConfigHelper.Bind(ConfigSection, "Enabled", _defaultValues.Enabled, "Enable this portal. If disabled, will also disable the other portal."); UseViewDistance = ConfigHelper.Bind(ConfigSection, "UseViewDistance", _defaultValues.UseViewDistance, "If enabled, this portal will use the view distance in this config instead of the global view distance config."); ViewDistance = ConfigHelper.Bind(ConfigSection, "ViewDistance", _defaultValues.ViewDistance, "The distance you can see through this portal. Requires UseViewDistance to be enabled.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0.06f, 250f)); UseViewDistance.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; ViewDistance.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; } } public class PortalSettingsDatabase where T : PortalSettings { protected readonly List _entries = new List(); public IReadOnlyList Entries => _entries; public virtual bool AddEntry(T entry) { if (_entries.Contains(entry)) { return false; } _entries.Add(entry); return true; } public virtual bool RemoveEntry(T entry) { return _entries.Remove(entry); } public virtual bool ContainsEntry(T entry) { return _entries.Contains(entry); } } public class MoonPortalSettingsDatabase : PortalSettingsDatabase { public bool AddEntry(SelectableLevel level, PortalSettings.DefaultValues? defaultValues = null) { if (!level.planetHasTime) { return false; } if (ContainsEntry(level)) { return false; } return ((PortalSettingsDatabase)this).AddEntry(new MoonPortalSettings(level.PlanetName, defaultValues ?? new PortalSettings.DefaultValues())); } public void BindConfigs() { List list = _entries.OrderBy((MoonPortalSettings x) => x.GetStrippedPlanetName()).ToList(); foreach (MoonPortalSettings item in list) { item.BindConfigs(); } } public MoonPortalSettings GetEntry(SelectableLevel level) { return base.Entries.FirstOrDefault((MoonPortalSettings x) => x.Matches(level)); } public bool TryGetEntry(SelectableLevel level, out MoonPortalSettings settings) { settings = GetEntry(level); return settings != null; } public bool ContainsEntry(SelectableLevel level) { MoonPortalSettings settings; return TryGetEntry(level, out settings); } public MoonPortalSettings GetEntryForCurrentMoon() { return GetEntry(StartOfRound.Instance?.currentLevel); } public bool TryGetEntryForCurrentMoon(out MoonPortalSettings settings) { settings = GetEntryForCurrentMoon(); return settings != null; } } public class InteriorPortalSettingsDatabase : PortalSettingsDatabase { public bool AddEntry(InteriorType interiorType, InteriorPortalSettings.InteriorDefaultValues? interiorDefaultValues = null, PortalSettings.DefaultValues? defaultValues = null) { InteriorPortalSettings.InteriorDefaultValues valueOrDefault = interiorDefaultValues.GetValueOrDefault(); if (!interiorDefaultValues.HasValue) { valueOrDefault = new InteriorPortalSettings.InteriorDefaultValues(); interiorDefaultValues = valueOrDefault; } PortalSettings.DefaultValues valueOrDefault2 = defaultValues.GetValueOrDefault(); if (!defaultValues.HasValue) { valueOrDefault2 = new PortalSettings.DefaultValues(); defaultValues = valueOrDefault2; } return ((PortalSettingsDatabase)this).AddEntry(new InteriorPortalSettings(interiorType, interiorDefaultValues.Value, defaultValues.Value)); } public bool AddEntry(DungeonFlow dungeonFlow, InteriorPortalSettings.InteriorDefaultValues? interiorDefaultValues = null, PortalSettings.DefaultValues? defaultValues = null) { InteriorPortalSettings.InteriorDefaultValues valueOrDefault = interiorDefaultValues.GetValueOrDefault(); if (!interiorDefaultValues.HasValue) { valueOrDefault = new InteriorPortalSettings.InteriorDefaultValues(); interiorDefaultValues = valueOrDefault; } PortalSettings.DefaultValues valueOrDefault2 = defaultValues.GetValueOrDefault(); if (!defaultValues.HasValue) { valueOrDefault2 = new PortalSettings.DefaultValues(); defaultValues = valueOrDefault2; } InteriorType interiorType = InteriorHelper.GetInteriorType(dungeonFlow); if (interiorType == InteriorType.Unknown) { return ((PortalSettingsDatabase)this).AddEntry(new InteriorPortalSettings(((Object)dungeonFlow).name, interiorDefaultValues.Value, defaultValues.Value)); } return ((PortalSettingsDatabase)this).AddEntry(new InteriorPortalSettings(interiorType, interiorDefaultValues.Value, defaultValues.Value)); } public void BindConfigs() { List list = _entries.OrderBy((InteriorPortalSettings x) => x.GetInteriorName()).ToList(); foreach (InteriorPortalSettings item in list) { item.BindConfigs(); } } public InteriorPortalSettings GetEntry(DungeonFlow dungeonFlow) { return base.Entries.FirstOrDefault((InteriorPortalSettings x) => x.Matches(dungeonFlow)); } public bool TryGetEntry(DungeonFlow dungeonFlow, out InteriorPortalSettings settings) { settings = GetEntry(dungeonFlow); return settings != null; } public bool ContainsEntry(DungeonFlow dungeonFlow) { InteriorPortalSettings settings; return TryGetEntry(dungeonFlow, out settings); } public InteriorPortalSettings GetEntryForCurrentInterior() { return GetEntry(InteriorHelper.GetCurrentDungeonFlow()); } public bool TryGetEntryForCurrentInterior(out InteriorPortalSettings settings) { settings = GetEntryForCurrentInterior(); return settings != null; } } } namespace com.github.zehsteam.ImmersiveEntrance.MonoBehaviours { internal class CoroutineRunner : MonoBehaviour { public static CoroutineRunner Instance { get; private set; } public static CoroutineRunner Spawn() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null) { return Instance; } GameObject val = new GameObject("ImmersiveEntrance CoroutineRunner", new Type[1] { typeof(CoroutineRunner) }) { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)val); return val.GetComponent(); } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public static Coroutine Start(IEnumerator routine) { if ((Object)(object)Instance == (Object)null) { CoroutineRunner coroutineRunner = Spawn(); return ((coroutineRunner != null) ? ((MonoBehaviour)coroutineRunner).StartCoroutine(routine) : null) ?? null; } CoroutineRunner instance = Instance; return ((instance != null) ? ((MonoBehaviour)instance).StartCoroutine(routine) : null) ?? null; } public static void Stop(IEnumerator routine) { CoroutineRunner instance = Instance; if (instance != null) { ((MonoBehaviour)instance).StopCoroutine(routine); } } public static void Stop(Coroutine routine) { CoroutineRunner instance = Instance; if (instance != null) { ((MonoBehaviour)instance).StopCoroutine(routine); } } } public class DoorPortal : MonoBehaviour { private static readonly List _instances = new List(); [SerializeField] private Transform _pivot; [SerializeField] private MeshRenderer _screen; [SerializeField] private MeshRenderer _screenOccluder; [SerializeField] private GameObject _renderingContainer; [SerializeField] private Camera _portalCamera; [SerializeField] private Light _nightVision; [SerializeField] private GameObject _fogExclusionZone; private RenderTexture _viewTexture; private bool _isDrawing; private bool _isLocalPlayerInRange; private LayerMask _pivotRaycastMask; public Camera PortalCamera => _portalCamera; public bool IsOutside => MainEntrance.IsOutside; public MainEntranceData MainEntrance { get; private set; } public PortalSettings PortalSettings { get; private set; } public DoorPortal LinkedPortal { get; private set; } private void Awake() { ((Behaviour)_portalCamera).enabled = false; SetDrawing(value: false); SetRendering(value: false); } private void OnEnable() { if (!_instances.Contains(this)) { _instances.Add(this); } } private void OnDisable() { _instances.Remove(this); } private void Start() { if (CullFactoryProxy.IsInstalled) { CullFactoryProxy.DisableCullingForCamera(_portalCamera); } if (MainEntrance == null) { Logger.LogError("[DoorPortal] Start: MainEntranceData is null!"); return; } if (MainEntrance.IsOutside) { PortalSettings = PortalSettingsManager.MoonDatabase.GetEntryForCurrentMoon(); } else { PortalSettings = PortalSettingsManager.InteriorDatabase.GetEntryForCurrentInterior(); } if (PortalSettings == null) { Logger.LogError("[DoorPortal] Start: PortalSettings is null!"); return; } Utils.InvokeAfterDelay(InitializePivot, TimeSpan.FromSeconds(0.10000000149011612), (MonoBehaviour)(object)this); InitializeScreen(); InitializeCamera(); ApplyConfigSettings(); } private void Update() { if (!((Object)(object)LinkedPortal == (Object)null)) { UpdateScreenVisibility(); } } private void LateUpdate() { if (!((Object)(object)LinkedPortal == (Object)null)) { UpdatePortalCamera(); } } public void SetMainEntranceData(MainEntranceData mainEntrance) { MainEntrance = mainEntrance; } public void LinkPortal(DoorPortal other) { LinkedPortal = other; SetScreenRenderTexture(other._viewTexture); Logger.LogInfo("[DoorPortal] Linked portal " + MainEntrance.EntranceTeleport.GetLogInfo() + " -> " + other.MainEntrance.EntranceTeleport.GetLogInfo()); } public bool IsEnabled() { if (!ConfigManager.Portal_Enabled.Value) { return false; } if (PortalSettings == null || (Object)(object)LinkedPortal == (Object)null) { return false; } if (!PortalSettings.Enabled.Value) { return false; } if (!LinkedPortal.PortalSettings.Enabled.Value) { return false; } return true; } private void UpdateScreenVisibility() { if (!IsEnabled()) { _isLocalPlayerInRange = false; OnLocalPlayerExitRange(); return; } bool flag = IsLocalPlayerCameraInRange(); bool flag2 = CameraHelper.IsVisibleFromCamera((Renderer)(object)_screen, PlayerUtils.GetLocalPlayerCamera()); if (flag && flag2) { if (!_isLocalPlayerInRange) { _isLocalPlayerInRange = true; OnLocalPlayerEnterRange(); } } else if (_isLocalPlayerInRange) { _isLocalPlayerInRange = false; OnLocalPlayerExitRange(); } } private bool IsLocalPlayerCameraInRange() { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!PlayerUtils.TryGetLocalPlayerCamera(out var camera)) { return false; } float value = ConfigManager.Portal_ActivationRange.Value; Vector3 position = ((Component)camera).transform.position; float num = Vector3.Distance(position, _pivot.position); return num <= value; } private void OnLocalPlayerEnterRange() { SetDrawing(value: true); LinkedPortal.SetRendering(value: true); if (MainEntrance.IsOutside) { InteriorHelper.RenderInterior(); } else { LevelHelper.SetForceWeatherEffectsEnabled(value: true); } } private void OnLocalPlayerExitRange() { SetDrawing(value: false); LinkedPortal.SetRendering(value: false); if (!MainEntrance.IsOutside) { LevelHelper.SetForceWeatherEffectsEnabled(value: false); } } private void InitializePivot() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) InitializePivot(PortalSettings.UseDynamicPivot, PortalSettings.PivotPositionOffset, PortalSettings.PivotRotationOffset); } public void InitializePivot(bool useDynamicPivot, Vector3 positionOffset, Vector3 rotationOffset) { //IL_0006: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) _pivot.localPosition = Vector3.zero; _pivot.localRotation = Quaternion.identity; if (useDynamicPivot) { SetDynamicPivot(); } Transform pivot = _pivot; pivot.localPosition += positionOffset; Transform pivot2 = _pivot; Quaternion localRotation = _pivot.localRotation; pivot2.localRotation = Quaternion.Euler(((Quaternion)(ref localRotation)).eulerAngles + rotationOffset); } private void SetDynamicPivot() { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) _pivotRaycastMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[2] { "Room", "Colliders" })); if (TryGetDynamicPivotPosition(out var position)) { _pivot.position = position; } if (TryGetDynamicPivotRotation(out var rotation)) { _pivot.rotation = rotation; } } private bool TryGetDynamicPivotPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; Vector3 origin = _pivot.position + _pivot.forward * -0.25f; if (!TryRaycastForPivot(origin, _pivot.forward, out var hit)) { return false; } float num = -0.0015f; Vector3 val = ((RaycastHit)(ref hit)).point + _pivot.forward * num; if (TryRaycastForPivot(val, -_pivot.up, out var hit2, 5f)) { float num2 = ((Component)_screen).transform.lossyScale.y / 2f; float y = ((RaycastHit)(ref hit2)).point.y + num2; val.y = y; } position = val; return true; } private bool TryGetDynamicPivotRotation(out Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) rotation = Quaternion.identity; Vector3 val = _pivot.position + _pivot.forward * -0.25f; Vector3 forward = _pivot.forward; Vector3 origin = val + _pivot.right * -0.25f; if (!TryRaycastForPivot(origin, forward, out var hit)) { return false; } Vector3 origin2 = val + _pivot.right * 0.25f; if (!TryRaycastForPivot(origin2, forward, out var hit2)) { return false; } Vector3 val2 = ((RaycastHit)(ref hit)).normal + ((RaycastHit)(ref hit2)).normal; Vector3 normalized = ((Vector3)(ref val2)).normalized; val2 = ((RaycastHit)(ref hit2)).point - ((RaycastHit)(ref hit)).point; Vector3 normalized2 = ((Vector3)(ref val2)).normalized; Vector3 val3 = -normalized; val2 = Vector3.Cross(val3, normalized2); Vector3 normalized3 = ((Vector3)(ref val2)).normalized; rotation = Quaternion.LookRotation(val3, normalized3); return true; } private bool TryRaycastForPivot(Vector3 origin, Vector3 direction, out RaycastHit hit, float maxDistance = 1f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Physics.Raycast(origin, direction, ref hit, maxDistance, LayerMask.op_Implicit(_pivotRaycastMask), (QueryTriggerInteraction)1); } private void InitializeScreen() { ApplyScreenCrop(); } private void ApplyScreenCrop() { SetScreenCrop(PortalSettings.ScreenCrop); } public void SetScreenCrop(float left, float right, float top, float bottom) { SetScreenCrop(new Padding(left, right, top, bottom)); } public void SetScreenCrop(Padding padding, bool isUnityEditor = false) { //IL_009e: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) SetMaterialFloat("_CropLeft", padding.Left); SetMaterialFloat("_CropRight", padding.Right); SetMaterialFloat("_CropTop", padding.Top); SetMaterialFloat("_CropBottom", padding.Bottom); float num = 1f - padding.Left - padding.Right; float num2 = 1f - padding.Top - padding.Bottom; ((Component)_screenOccluder).transform.localScale = new Vector3(num, num2, 1f); float num3 = (padding.Left - padding.Right) * 0.5f; float num4 = (padding.Bottom - padding.Top) * 0.5f; Vector3 localPosition = ((Component)_screenOccluder).transform.localPosition; ((Component)_screenOccluder).transform.localPosition = new Vector3(num3, num4, localPosition.z); void SetMaterialFloat(string name, float value) { if (!isUnityEditor) { ((Renderer)_screen).material.SetFloat(name, value); } } } private void SetScreenRenderTexture(RenderTexture renderTexture) { ((Renderer)_screen).material.SetTexture("_MainTex", (Texture)(object)renderTexture); } private void SetDrawing(bool value) { _isDrawing = value; ((Component)_screen).gameObject.SetActive(value); UpdateDoor(); } private void InitializeCamera() { CreateViewTexture(); } private void ApplyCameraConfigSettings() { //IL_002f: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) bool value = ConfigManager.PortalGraphics_FogEnabled.Value; bool value2 = ConfigManager.PortalGraphics_CustomPassEnabled.Value; HDAdditionalCameraData component = ((Component)_portalCamera).GetComponent(); component.customRenderingSettings = true; FrameSettings renderingPathCustomFrameSettings = component.renderingPathCustomFrameSettings; ((FrameSettings)(ref renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)27, value); ((FrameSettings)(ref renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)6, value2); component.renderingPathCustomFrameSettings = renderingPathCustomFrameSettings; } private Size GetTargetViewTextureSize() { Size size; switch (ConfigManager.PortalGraphics_PixelResolution.Value) { case PixelResolutionType.PlayerCamera: return CameraHelper.GetCameraScreenSize(); case PixelResolutionType.Default: size = new Size(860, 520); break; case PixelResolutionType.Performance: size = new Size(620, 364); break; case PixelResolutionType.UltraPerformance: size = new Size(400, 260); break; case PixelResolutionType.Retro: size = new Size(186, 104); break; default: size = CameraHelper.GetCameraScreenSize(); break; } Size result = size; Size cameraScreenSize = CameraHelper.GetCameraScreenSize(); if (result.Width > cameraScreenSize.Width) { result.Width = cameraScreenSize.Width; } if (result.Height > cameraScreenSize.Height) { result.Height = cameraScreenSize.Height; } return result; } private void CreateViewTexture() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown Size targetSize = GetTargetViewTextureSize(); if (CanCreate()) { RenderTexture viewTexture = _viewTexture; if (viewTexture != null) { viewTexture.Release(); } RenderTextureDescriptor val = default(RenderTextureDescriptor); ((RenderTextureDescriptor)(ref val))..ctor(targetSize.Width, targetSize.Height); ((RenderTextureDescriptor)(ref val)).colorFormat = (RenderTextureFormat)0; ((RenderTextureDescriptor)(ref val)).depthStencilFormat = (GraphicsFormat)93; ((RenderTextureDescriptor)(ref val)).depthBufferBits = 32; ((RenderTextureDescriptor)(ref val)).msaaSamples = 1; ((RenderTextureDescriptor)(ref val)).mipCount = 0; ((RenderTextureDescriptor)(ref val)).useMipMap = false; ((RenderTextureDescriptor)(ref val)).autoGenerateMips = false; ((RenderTextureDescriptor)(ref val)).enableRandomWrite = false; ((RenderTextureDescriptor)(ref val)).useDynamicScale = false; ((RenderTextureDescriptor)(ref val)).sRGB = true; RenderTextureDescriptor val2 = val; _viewTexture = new RenderTexture(val2) { filterMode = (FilterMode)0 }; _viewTexture.Create(); Logger.LogInfo(string.Format("[{0}] {1}() width: {2}, height: {3}", "DoorPortal", "CreateViewTexture", targetSize.Width, targetSize.Height), extended: true); _portalCamera.targetTexture = _viewTexture; LinkedPortal?.SetScreenRenderTexture(_viewTexture); } bool CanCreate() { if ((Object)(object)_viewTexture == (Object)null) { return true; } if (((Texture)_viewTexture).width != targetSize.Width) { return true; } if (((Texture)_viewTexture).height != targetSize.Height) { return true; } return false; } } private bool IsRendering() { return _renderingContainer.activeSelf; } private void SetRendering(bool value) { _renderingContainer.SetActive(value); if (MainEntrance != null) { UpdateNightVision(); UpdateDoor(); } } private void UpdateNightVision() { if (MainEntrance != null && !MainEntrance.IsOutside) { ((Behaviour)_nightVision).enabled = IsRendering(); } } private void UpdatePortalCamera() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (IsRendering() && PlayerUtils.TryGetLocalPlayerCamera(out var camera)) { CreateViewTexture(); Transform transform = ((Component)LinkedPortal._screen).transform; Transform transform2 = ((Component)_screen).transform; Matrix4x4 val = transform.localToWorldMatrix * Matrix4x4.Rotate(Quaternion.Euler(0f, 180f, 0f)); Matrix4x4 val2 = transform2.localToWorldMatrix * Matrix4x4.Inverse(val); ((Component)_portalCamera).transform.SetPositionAndRotation(((Matrix4x4)(ref val2)).MultiplyPoint(((Component)camera).transform.position), ((Matrix4x4)(ref val2)).rotation * ((Component)camera).transform.rotation); _portalCamera.fieldOfView = camera.fieldOfView; SetFarClipPlane(); SetNearClipPlane(); LevelHelper.SetSunAndSkyEnabledThisFrame(MainEntrance.IsOutside); _portalCamera.Render(); LevelHelper.SetSunAndSkyEnabledThisFrame(!MainEntrance.IsOutside); } } private void SetFarClipPlane() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (MainEntrance != null) { float num = (PortalSettings.UseViewDistance.Value ? PortalSettings.ViewDistance.Value : ((!MainEntrance.IsOutside) ? ConfigManager.PortalGraphics_InsideViewDistance.Value : ConfigManager.PortalGraphics_OutsideViewDistance.Value)); float num2 = Vector3.Distance(((Component)_portalCamera).transform.position, ((Component)_screen).transform.position); _portalCamera.farClipPlane = num + num2; } } private void SetNearClipPlane() { NearClipPlaneMode value = ConfigManager.Debug_NearClipPlaneMode.Value; if (value == NearClipPlaneMode.ObliqueProjection) { SetObliqueNearClipPlane(); } else { SetDefaultNearClipPlane(); } } private void SetDefaultNearClipPlane() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)_screen).transform; Vector3 val = transform.InverseTransformPoint(((Component)_portalCamera).transform.position); MeshFilter component = ((Component)_screen).GetComponent(); Bounds? obj; if (component == null) { obj = null; } else { Mesh sharedMesh = component.sharedMesh; obj = ((sharedMesh != null) ? new Bounds?(sharedMesh.bounds) : null); } Bounds val2 = (Bounds)(((??)obj) ?? new Bounds(Vector3.zero, Vector3.one)); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Mathf.Clamp(val.x, ((Bounds)(ref val2)).min.x, ((Bounds)(ref val2)).max.x), Mathf.Clamp(val.y, ((Bounds)(ref val2)).min.y, ((Bounds)(ref val2)).max.y), 0f); Vector3 val4 = transform.TransformPoint(val3); Vector3 val5 = val4 - ((Component)_portalCamera).transform.position; float num = Vector3.Dot(val5, ((Component)_portalCamera).transform.forward); _portalCamera.ResetProjectionMatrix(); _portalCamera.nearClipPlane = Mathf.Max(0.01f, num); } private void SetObliqueNearClipPlane() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0028: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)_screen).transform; Plane val = default(Plane); ((Plane)(ref val))..ctor(-transform.forward, transform.position); Vector4 val2 = default(Vector4); ((Vector4)(ref val2))..ctor(((Plane)(ref val)).normal.x, ((Plane)(ref val)).normal.y, ((Plane)(ref val)).normal.z, ((Plane)(ref val)).distance); Vector4 val3 = Matrix4x4.Transpose(Matrix4x4.Inverse(_portalCamera.worldToCameraMatrix)) * val2; _portalCamera.nearClipPlane = 0.05f; _portalCamera.projectionMatrix = _portalCamera.CalculateObliqueMatrix(val3); } public static bool TryGetRenderingInstance(out DoorPortal doorPortal) { doorPortal = _instances.FirstOrDefault((DoorPortal x) => x.IsRendering()); return (Object)(object)doorPortal != (Object)null; } private void UpdateDoor() { if (MainEntrance != null) { if (IsRendering()) { MainEntrance.EntranceObjects.ViewBlocker.SetActive(false); } else { MainEntrance.EntranceObjects.ViewBlocker.SetActive(!_isDrawing); } if (ConfigManager.Debug_HideDoorObjects.Value) { MainEntrance.EntranceObjects.SetObjectsEnabled(value: false); } else { MainEntrance.EntranceObjects.SetObjectsEnabled(!IsRendering()); } } } private void ApplyConfigSettings() { ApplyCameraConfigSettings(); UpdateDoor(); bool value = ConfigManager.Debug_ExcludeFogBehindScreen.Value; GameObject fogExclusionZone = _fogExclusionZone; if (fogExclusionZone != null) { fogExclusionZone.SetActive(value); } } public static void OnConfigSettingsChanged() { foreach (DoorPortal instance in _instances) { instance.ApplyConfigSettings(); } } } public class WeatherAudioManager : MonoBehaviour { private readonly Dictionary> _weatherAudioSources = new Dictionary>(); public static WeatherAudioManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Update() { UpdateWeatherAudio(); } private void UpdateWeatherAudio() { if (!((Object)(object)TimeOfDay.Instance == (Object)null)) { WeatherEffect[] effects = TimeOfDay.Instance.effects; foreach (WeatherEffect weatherEffect in effects) { UpdateWeatherAudioSources(weatherEffect); } } } private void UpdateWeatherAudioSources(WeatherEffect weatherEffect) { if (weatherEffect == null) { return; } bool mute = PlayerUtils.IsLocalPlayerCameraInsideInterior(); foreach (AudioSource item in GetAudioSourcesForWeather(weatherEffect)) { item.mute = mute; } } private List GetAudioSourcesForWeather(WeatherEffect weatherEffect) { if (weatherEffect == null) { return new List(); } if (_weatherAudioSources.TryGetValue(weatherEffect, out var value)) { return value; } GameObject effectObject = weatherEffect.effectObject; if ((Object)(object)effectObject == (Object)null) { return new List(); } List list = effectObject.GetComponentsInChildren(true).ToList(); _weatherAudioSources[weatherEffect] = list; return list; } } } namespace com.github.zehsteam.ImmersiveEntrance.Managers { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry Misc_ExtendedLogging { get; private set; } public static ConfigEntry Portal_Enabled { get; private set; } public static ConfigEntry Portal_ActivationRange { get; private set; } public static ConfigEntry PortalGraphics_PixelResolution { get; private set; } public static ConfigEntry PortalGraphics_OutsideViewDistance { get; private set; } public static ConfigEntry PortalGraphics_InsideViewDistance { get; private set; } public static ConfigEntry PortalGraphics_FogEnabled { get; private set; } public static ConfigEntry PortalGraphics_WeatherEffectsEnabled { get; private set; } public static ConfigEntry PortalGraphics_CustomPassEnabled { get; private set; } public static ConfigEntry Debug_HideDoorObjects { get; private set; } public static ConfigEntry Debug_ExcludeFogBehindScreen { get; private set; } public static ConfigEntry Debug_NearClipPlaneMode { get; private set; } public static ConfigEntry Debug_UseSimulatedDeviceDepth { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { ConfigHelper.SkipAutoGen(); Misc_ExtendedLogging = ConfigHelper.Bind("Misc", "ExtendedLogging", defaultValue: false, "Enable extended logging."); Portal_Enabled = ConfigHelper.Bind("Portal", "Enabled", defaultValue: true, "Enable portals!"); Portal_ActivationRange = ConfigHelper.Bind("Portal", "ActivationRange", 10f, "The distance in meters the player needs to be within a portal for it to render.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(1f, 50f)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("The rendering pixel resolution of portals."); stringBuilder.AppendLine("PlayerCamera = Automatically adjusts to the player camera's rendering resolution."); stringBuilder.AppendLine("Default = 860x520."); stringBuilder.AppendLine("Performance = 620x364."); stringBuilder.AppendLine("UltraPerformance = 400x260."); stringBuilder.AppendLine("Retro = 186x104."); PortalGraphics_PixelResolution = ConfigHelper.Bind("Portal Graphics", "PixelResolution", PixelResolutionType.PlayerCamera, stringBuilder.ToString()); PortalGraphics_OutsideViewDistance = ConfigHelper.Bind("Portal Graphics", "OutsideViewDistance", 250f, "The distance you can see through an outside portal.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0.06f, 250f)); PortalGraphics_InsideViewDistance = ConfigHelper.Bind("Portal Graphics", "InsideViewDistance", 50f, "The distance you can see through an inside portal.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0.06f, 100f)); PortalGraphics_FogEnabled = ConfigHelper.Bind("Portal Graphics", "FogEnabled", defaultValue: true, "Enable the rendering of fog."); PortalGraphics_WeatherEffectsEnabled = ConfigHelper.Bind("Portal Graphics", "WeatherEffectsEnabled", defaultValue: true, "Enable the rendering of weather effects."); PortalGraphics_CustomPassEnabled = ConfigHelper.Bind("Portal Graphics", "CustomPassEnabled", defaultValue: true, "Enable custom passes to render. This applies the Lethal Company signature shading to everything being viewed."); PortalGraphics_OutsideViewDistance.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; PortalGraphics_InsideViewDistance.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; PortalGraphics_FogEnabled.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; PortalGraphics_CustomPassEnabled.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; Debug_HideDoorObjects = ConfigHelper.Bind("Debug", "HideDoorObjects", defaultValue: false, "If enabled, will hide all of the door meshes and only show the portal screen."); Debug_ExcludeFogBehindScreen = ConfigHelper.Bind("Debug", "ExcludeFogBehindScreen", defaultValue: false, "If enabled, will exclude fog that is behind the portal screen from rendering."); Debug_NearClipPlaneMode = ConfigHelper.Bind("Debug", "NearClipPlaneMode", NearClipPlaneMode.Default, "The method the portal cameras use for calculating their near clip plane."); Debug_UseSimulatedDeviceDepth = ConfigHelper.Bind("Debug", "UseSimulatedDeviceDepth", defaultValue: true, ""); Debug_HideDoorObjects.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; Debug_ExcludeFogBehindScreen.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; } } internal static class EntranceDoorReplacementManager { [CompilerGenerated] private sealed class <>c__DisplayClass3_0 { public float delay; public GameObject gameObject; } public static void ReplaceDoor(MainEntranceData mainEntrance) { if (mainEntrance != null && !mainEntrance.IsOutside && PortalSettingsManager.InteriorDatabase.TryGetEntryForCurrentInterior(out var settings) && settings.HasDoorReplacement && settings.ReplaceDoor.Value) { ReplaceDoor(mainEntrance, settings.GetDoorReplacement()); } } private static void ReplaceDoor(MainEntranceData mainEntrance, EntranceDoorReplacement replacement) { if (mainEntrance != null && !((Object)(object)replacement == (Object)null)) { GameObject doorLeft = mainEntrance.EntranceObjects.DoorLeft; Transform val = ((doorLeft != null) ? doorLeft.transform : null); GameObject doorRight = mainEntrance.EntranceObjects.DoorRight; Transform val2 = ((doorRight != null) ? doorRight.transform : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Logger.LogError("[EntranceDoorReplacementManager] Failed to replace main entrance door " + mainEntrance.EntranceTeleport.GetLogInfo() + " with " + ((Object)replacement).name + ". Could not find all of the original door objects."); } else { SpawnReplacementDoor(val, replacement.DoorLeft); SpawnReplacementDoor(val2, replacement.DoorRight); Logger.LogInfo("[EntranceDoorReplacementManager] Replaced main entrance door " + mainEntrance.EntranceTeleport.GetLogInfo() + " with " + ((Object)replacement).name, extended: true); } } } private static void SpawnReplacementDoor(Transform parent, GameObject prefab) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(prefab, parent); val.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); HideAfterDelay(((Component)parent).gameObject); } private static void HideAfterDelay(GameObject gameObject, float delay = 0.1f) { <>c__DisplayClass3_0 CS$<>8__locals0 = new <>c__DisplayClass3_0(); CS$<>8__locals0.delay = delay; CS$<>8__locals0.gameObject = gameObject; CoroutineRunner.Start(Coroutine()); [IteratorStateMachine(typeof(<>c__DisplayClass3_0.<g__Coroutine|0>d))] IEnumerator Coroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass3_0.<g__Coroutine|0>d(0) { <>4__this = CS$<>8__locals0 }; } } } internal static class EntranceManager { private static bool _linkedMainEntrancePortals; public static MainEntranceData OutsideMainEntrance { get; private set; } public static MainEntranceData InsideMainEntrance { get; private set; } public static void Reset() { OutsideMainEntrance?.Reset(); InsideMainEntrance?.Reset(); _linkedMainEntrancePortals = false; } public static void SpawnDoorPortal(EntranceTeleport entranceTeleport) { //IL_00db: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)entranceTeleport == (Object)null || !entranceTeleport.IsMainEntrance()) { return; } Logger.LogInfo("[EntranceManager] Attempting to spawn main entrance door portal! " + entranceTeleport.GetLogInfo()); MainEntranceData mainEntranceData; if (entranceTeleport.IsOutside()) { if (OutsideMainEntrance == null) { OutsideMainEntrance = new MainEntranceData(); } OutsideMainEntrance.Reset(); mainEntranceData = OutsideMainEntrance; } else { if (InsideMainEntrance == null) { InsideMainEntrance = new MainEntranceData(); } InsideMainEntrance.Reset(); mainEntranceData = InsideMainEntrance; } mainEntranceData.EntranceTeleport = entranceTeleport; mainEntranceData.EntranceObjects = EntranceObjectsHelper.GetEntranceObjects(entranceTeleport); if (!mainEntranceData.EntranceObjects.IsValid()) { Logger.LogWarning("[EntranceManager] Failed to spawn main entrance door portal. Could not find all entrance objects. " + entranceTeleport.GetLogInfo()); mainEntranceData.EntranceObjects.LogMissingObjects(); mainEntranceData?.Reset(); return; } GameObject val = Object.Instantiate(Assets.DoorPortalPrefab, ((Component)entranceTeleport).transform); val.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); Vector3 localScale = Assets.DoorPortalPrefab.transform.localScale; val.transform.SetLossyScale(localScale); DoorPortal doorPortal = (mainEntranceData.DoorPortal = val.GetComponent()); doorPortal.SetMainEntranceData(mainEntranceData); Logger.LogInfo("[EntranceManager] Successfully spawned main entrance door portal! " + entranceTeleport.GetLogInfo()); EntranceDoorReplacementManager.ReplaceDoor(mainEntranceData); } public static void LinkMainEntrancePortals() { if (_linkedMainEntrancePortals) { return; } _linkedMainEntrancePortals = true; Logger.LogInfo("[EntranceManager] Attempting to link main entrance portals."); if (OutsideMainEntrance == null) { Logger.LogError("[EntranceManager] Failed to link main entrance portals. OutsideMainEntrance is null."); return; } if (InsideMainEntrance == null) { Logger.LogError("[EntranceManager] Failed to link main entrance portals. InsideMainEntrance is null."); return; } bool flag = true; if (!OutsideMainEntrance.HasDoorPortal) { Logger.LogError("[EntranceManager] Failed to link main entrance portals. Outside door portal was not spawned."); flag = false; } if (!InsideMainEntrance.HasDoorPortal) { Logger.LogError("[EntranceManager] Failed to link main entrance portals. Inside door portal was not spawned."); flag = false; } if (!flag) { if (OutsideMainEntrance.HasDoorPortal) { Object.Destroy((Object)(object)((Component)OutsideMainEntrance.DoorPortal).gameObject); Logger.LogInfo("[EntranceManager] Despawned outside door portal."); } if (InsideMainEntrance.HasDoorPortal) { Object.Destroy((Object)(object)((Component)InsideMainEntrance.DoorPortal).gameObject); Logger.LogInfo("[EntranceManager] Despawned inside door portal."); } } else { OutsideMainEntrance.DoorPortal.LinkPortal(InsideMainEntrance.DoorPortal); InsideMainEntrance.DoorPortal.LinkPortal(OutsideMainEntrance.DoorPortal); Logger.LogInfo("[EntranceManager] Successfully linked main entrance portals!"); } } } internal static class PortalSettingsManager { private static readonly MoonPortalSettingsDatabase _predefinedMoonDatabase; private static readonly InteriorPortalSettingsDatabase _predefinedInteriorDatabase; private static bool _initialized; public static MoonPortalSettingsDatabase MoonDatabase { get; private set; } public static InteriorPortalSettingsDatabase InteriorDatabase { get; private set; } static PortalSettingsManager() { MoonDatabase = new MoonPortalSettingsDatabase(); InteriorDatabase = new InteriorPortalSettingsDatabase(); _predefinedMoonDatabase = new MoonPortalSettingsDatabase(); _predefinedInteriorDatabase = new InteriorPortalSettingsDatabase(); AddPredefinedEntries(); } private static void AddPredefinedEntries() { AddPredefinedMoonEntries(); AddPredefinedInteriorEntries(); AddMonesInteriorsSettings(); AddSlaughterhouseSettings(); } private static void AddPredefinedMoonEntries() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) ((PortalSettingsDatabase)_predefinedMoonDatabase).AddEntry(new MoonPortalSettings("41 Experimentation", new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: false, (Vector3?)new Vector3(0.02f, 0.03417349f, 0.203743f), (Vector3?)null, (Padding?)null, (float?)null))); ((PortalSettingsDatabase)_predefinedMoonDatabase).AddEntry(new MoonPortalSettings("56 Vow", new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, (Vector3?)new Vector3(0.04f, 0f, 0f), (Vector3?)null, (Padding?)null, (float?)null))); ((PortalSettingsDatabase)_predefinedMoonDatabase).AddEntry(new MoonPortalSettings("61 March", new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: false, (Vector3?)new Vector3(0.063f, 0.081f, 0.209f), (Vector3?)new Vector3(0f, -0.017f, 0f), (Padding?)new Padding(0f, 0f, 0.03f, 0f), (float?)null))); MoonPortalSettingsDatabase predefinedMoonDatabase = _predefinedMoonDatabase; float? viewDistance = 75f; ((PortalSettingsDatabase)predefinedMoonDatabase).AddEntry(new MoonPortalSettings("85 Rend", new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, null, null, null, viewDistance))); MoonPortalSettingsDatabase predefinedMoonDatabase2 = _predefinedMoonDatabase; Vector3? pivotPositionOffset = new Vector3(0.06f, 0f, 0f); Padding? screenCrop = new Padding(0f, 0f, 0.03f, 0f); ((PortalSettingsDatabase)predefinedMoonDatabase2).AddEntry(new MoonPortalSettings("7 Dine", new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, pivotPositionOffset, null, screenCrop))); } private static void AddPredefinedInteriorEntries() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) ((PortalSettingsDatabase)_predefinedInteriorDatabase).AddEntry(new InteriorPortalSettings(InteriorType.Facility, new InteriorPortalSettings.InteriorDefaultValues(), new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: false, (Vector3?)new Vector3(-0.1f, 0.03f, 0.067f), (Vector3?)null, (Padding?)null, (float?)null))); InteriorPortalSettingsDatabase predefinedInteriorDatabase = _predefinedInteriorDatabase; InteriorPortalSettings.InteriorDefaultValues interiorDefaultValues = new InteriorPortalSettings.InteriorDefaultValues(() => Assets.MansionEntranceDoorReplacement); Vector3? pivotPositionOffset = new Vector3(-0.011f, 0f, 0f); Padding? screenCrop = new Padding(0.05f, 0.05f, 0.025f, 0f); ((PortalSettingsDatabase)predefinedInteriorDatabase).AddEntry(new InteriorPortalSettings(InteriorType.Mansion, interiorDefaultValues, new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, pivotPositionOffset, null, screenCrop))); InteriorPortalSettingsDatabase predefinedInteriorDatabase2 = _predefinedInteriorDatabase; InteriorPortalSettings.InteriorDefaultValues interiorDefaultValues2 = new InteriorPortalSettings.InteriorDefaultValues(); Vector3? pivotPositionOffset2 = new Vector3(-0.09f, 0f, 0f); screenCrop = new Padding(0f, 0f, 0.04f, 0f); float? viewDistance = 30f; ((PortalSettingsDatabase)predefinedInteriorDatabase2).AddEntry(new InteriorPortalSettings(InteriorType.Mineshaft, interiorDefaultValues2, new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, pivotPositionOffset2, null, screenCrop, viewDistance))); } private static void AddMonesInteriorsSettings() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) InteriorPortalSettingsDatabase predefinedInteriorDatabase = _predefinedInteriorDatabase; InteriorPortalSettings.InteriorDefaultValues interiorDefaultValues = new InteriorPortalSettings.InteriorDefaultValues(); Vector3? pivotPositionOffset = new Vector3(-0.055f, 0f, 0f); Padding? screenCrop = new Padding(0.026f, 0.026f, 0.026f, 0f); ((PortalSettingsDatabase)predefinedInteriorDatabase).AddEntry(new InteriorPortalSettings("EndlessHallDunFlow", interiorDefaultValues, new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, pivotPositionOffset, null, screenCrop))); InteriorPortalSettingsDatabase predefinedInteriorDatabase2 = _predefinedInteriorDatabase; InteriorPortalSettings.InteriorDefaultValues interiorDefaultValues2 = new InteriorPortalSettings.InteriorDefaultValues(() => Assets.MansionEntranceDoorReplacement); Vector3? pivotPositionOffset2 = new Vector3(-0.011f, 0f, 0f); screenCrop = new Padding(0.05f, 0.05f, 0.025f, 0f); ((PortalSettingsDatabase)predefinedInteriorDatabase2).AddEntry(new InteriorPortalSettings("HauntedHotelDunFlow", interiorDefaultValues2, new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, pivotPositionOffset2, null, screenCrop))); } private static void AddSlaughterhouseSettings() { InteriorPortalSettingsDatabase predefinedInteriorDatabase = _predefinedInteriorDatabase; InteriorPortalSettings.InteriorDefaultValues interiorDefaultValues = new InteriorPortalSettings.InteriorDefaultValues(); float? viewDistance = 100f; ((PortalSettingsDatabase)predefinedInteriorDatabase).AddEntry(new InteriorPortalSettings("SlaughterhouseFlow", interiorDefaultValues, new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, null, null, null, viewDistance))); } public static void Initialize() { if (!_initialized) { _initialized = true; PopulateEntries(); BindConfigs(); } } private static void PopulateEntries() { PopulateMoonEntries(); PopulateInteriorEntries(); } private static void BindConfigs() { InteriorDatabase.BindConfigs(); MoonDatabase.BindConfigs(); } private static void PopulateMoonEntries() { if ((Object)(object)StartOfRound.Instance == (Object)null) { Logger.LogError("[PortalSettingsManager] Failed to populate moon entries. StartOfRound instance is null."); return; } SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel level in levels) { AddMoonEntry(level); } } private static void PopulateInteriorEntries() { if ((Object)(object)RoundManager.Instance == (Object)null) { Logger.LogError("[PortalSettingsManager] Failed to populate interior entries. RoundManager instance is null."); return; } IndoorMapType[] dungeonFlowTypes = RoundManager.Instance.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { AddInteriorEntry(val.dungeonFlow); } } private static bool AddMoonEntry(SelectableLevel level) { if (_predefinedMoonDatabase.TryGetEntry(level, out var settings)) { return ((PortalSettingsDatabase)MoonDatabase).AddEntry(settings); } return MoonDatabase.AddEntry(level); } private static bool AddInteriorEntry(DungeonFlow dungeonFlow) { if (_predefinedInteriorDatabase.TryGetEntry(dungeonFlow, out var settings)) { return ((PortalSettingsDatabase)InteriorDatabase).AddEntry(settings); } return InteriorDatabase.AddEntry(dungeonFlow); } } } namespace com.github.zehsteam.ImmersiveEntrance.Helpers { internal static class CameraHelper { public static bool IsVisibleFromCamera(Renderer renderer, Camera camera) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)renderer == (Object)null || (Object)(object)camera == (Object)null) { return false; } Plane[] array = GeometryUtility.CalculateFrustumPlanes(camera); return GeometryUtility.TestPlanesAABB(array, renderer.bounds); } public static Size GetCameraScreenSize() { IngamePlayerSettings instance = IngamePlayerSettings.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerGameplayScreenTex != (Object)null) { return new Size(((Texture)instance.playerGameplayScreenTex).width, ((Texture)instance.playerGameplayScreenTex).height); } return new Size(860, 520); } } internal static class ConfigHelper { public static void SkipAutoGen() { if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.SkipAutoGen(); } } public static void AddButton(string section, string name, string buttonText, string description, Action callback) { if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.AddButton(section, name, buttonText, description, callback); } } public static ConfigEntry Bind(string section, string key, T defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action settingChanged = null, ConfigFile configFile = null) { if (configFile == null) { configFile = ConfigManager.ConfigFile; } ConfigEntry configEntry = configFile.Bind(section, key, defaultValue, description, acceptableValues); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.AddConfig(configEntry, requiresRestart); } return configEntry; } } internal static class CustomPassHelper { public static GameObject OldVolume { get; private set; } public static GameObject NewVolume { get; private set; } public static CustomPass OldPass { get; private set; } public static CustomPass NewPass { get; private set; } public static void ReplaceVanillaCustomPass() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) OldVolume = GameObject.Find("CustomPass (1)"); Transform parent = OldVolume.transform.parent; CustomPassVolume component = OldVolume.GetComponent(); NewVolume = new GameObject("ImmersiveEntrance CustomPass"); NewVolume.transform.SetParent(parent); CustomPassVolume val = NewVolume.AddComponent(); val.injectionPoint = (CustomPassInjectionPoint)1; NewPass = (CustomPass)(object)new PosterizationCustomPass(); val.customPasses.Add(NewPass); foreach (CustomPass customPass in component.customPasses) { if (customPass.name == "LethalSponge") { OldPass = customPass; OldPass.enabled = false; break; } } } } internal static class EntranceObjectsHelper { private static TransformFindOptions _transformFindOptions; static EntranceObjectsHelper() { _transformFindOptions = new TransformFindOptions(onlyEnabled: true, null, new int[2] { LayerMask.NameToLayer("MapRadar"), LayerMask.NameToLayer("ScanNode") }); } public static EntranceObjects GetEntranceObjects(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport == (Object)null) { return new EntranceObjects(); } Transform visualDoorsContainer = GetVisualDoorsContainer(entranceTeleport); if ((Object)(object)visualDoorsContainer == (Object)null) { return new EntranceObjects { IsOutside = entranceTeleport.IsOutside() }; } return new EntranceObjects { IsOutside = entranceTeleport.IsOutside(), ViewBlocker = GetViewBlocker(entranceTeleport, visualDoorsContainer), DoorFrame = GetDoorFrame(entranceTeleport, visualDoorsContainer), DoorLeft = GetDoorLeft(entranceTeleport, visualDoorsContainer), DoorRight = GetDoorRight(entranceTeleport, visualDoorsContainer) }; } private static GameObject GetViewBlocker(EntranceTeleport entranceTeleport, Transform visualDoorsContainer) { if (TryGetViewBlockerFromParent(((Component)entranceTeleport).transform, out var result)) { return ((Component)result).gameObject; } if (TryGetViewBlockerFromParent(visualDoorsContainer, out result)) { return ((Component)result).gameObject; } if (entranceTeleport.IsOutside() && TryGetViewBlockerFromParent(((Component)entranceTeleport).transform.parent, out result)) { return ((Component)result).gameObject; } if (!entranceTeleport.IsOutside()) { return null; } if (!LevelHelper.TryGetEnvironment(out var result2)) { return null; } if (TryGetViewBlockerFromParent(result2.transform, out result)) { return ((Component)result).gameObject; } if (result2.transform.TryFind("MainFactory", out var result3) && TryGetViewBlockerFromParent(result3, out result)) { return ((Component)result).gameObject; } return null; } private static GameObject GetDoorFrame(EntranceTeleport entranceTeleport, Transform visualDoorsContainer) { if (TryGetDoorFrameFromParent(((Component)entranceTeleport).transform, out var result)) { return ((Component)result).gameObject; } if (TryGetDoorFrameFromParent(visualDoorsContainer, out result)) { return ((Component)result).gameObject; } if (!entranceTeleport.IsOutside()) { return null; } if (!LevelHelper.TryGetEnvironment(out var result2)) { return null; } if (TryGetDoorFrameFromParent(result2.transform, out result)) { return ((Component)result).gameObject; } if (result2.transform.TryFind("MainFactory", out var result3) && TryGetDoorFrameFromParent(result3, out result)) { return ((Component)result).gameObject; } return null; } private static GameObject GetDoorLeft(EntranceTeleport entranceTeleport, Transform visualDoorsContainer) { if (TryGetDoorLeftFromParent(visualDoorsContainer, out var result)) { return ((Component)result).gameObject; } return null; } private static GameObject GetDoorRight(EntranceTeleport entranceTeleport, Transform visualDoorsContainer) { if (TryGetDoorRightFromParent(visualDoorsContainer, out var result)) { return ((Component)result).gameObject; } return null; } private static bool TryGetViewBlockerFromParent(Transform parent, out Transform result) { if ((Object)(object)parent == (Object)null) { result = null; return false; } return parent.TryFindFirst(new <>z__ReadOnlyArray(new string[2] { "Plane", "LightBehindDoor" }), out result, _transformFindOptions); } private static bool TryGetDoorFrameFromParent(Transform parent, out Transform result) { if ((Object)(object)parent == (Object)null) { result = null; return false; } return parent.TryFindFirst(new <>z__ReadOnlyArray(new string[3] { "DoorFrame (1)", "DoorFrame", "WideDoorFrame (1)" }), out result, _transformFindOptions); } private static bool TryGetDoorLeftFromParent(Transform parent, out Transform result) { if ((Object)(object)parent == (Object)null) { result = null; return false; } return parent.TryFindFirst(new <>z__ReadOnlyArray(new string[2] { "SteelDoorFake", "DoorMesh (1)" }), out result, _transformFindOptions); } private static bool TryGetDoorRightFromParent(Transform parent, out Transform result) { if ((Object)(object)parent == (Object)null) { result = null; return false; } return parent.TryFindFirst(new <>z__ReadOnlyArray(new string[2] { "SteelDoorFake (1)", "DoorMesh" }), out result, _transformFindOptions); } public static Transform GetVisualDoorsContainer(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport.thisEntranceAnimator != (Object)null) { return ((Component)entranceTeleport.thisEntranceAnimator).transform; } GameObject gameObject; if (entranceTeleport.IsOutside()) { if (LevelHelper.TryGetEnvironment(out var result)) { Transform obj = result.transform.Find("OutsideEntranceVisualDoorsContainer"); if (obj == null) { return null; } return ((Component)obj).transform; } } else if (GameObjectHelper.TryFindWithTag("InsideEntranceDoor", out gameObject)) { return gameObject.transform; } List children = ((Component)entranceTeleport).transform.GetChildren(_transformFindOptions); foreach (Transform item in children) { string name = ((Object)((Component)item).gameObject).name; if (name.Contains("VisualDoorsContainer", StringComparison.OrdinalIgnoreCase)) { return item; } } return null; } } internal static class GameObjectHelper { public static bool TryFind(string name, out GameObject gameObject) { gameObject = GameObject.Find(name); return (Object)(object)gameObject != (Object)null; } public static bool TryFindWithTag(string tag, out GameObject gameObject) { gameObject = GameObject.FindWithTag(tag); return (Object)(object)gameObject != (Object)null; } } internal static class InteriorHelper { public static void RenderInterior() { if (!((Object)(object)StartOfRound.Instance == (Object)null)) { AdjacentRoomCullingModified occlusionCuller = StartOfRound.Instance.occlusionCuller; if (!((Object)(object)occlusionCuller == (Object)null) && ((Behaviour)occlusionCuller).enabled) { occlusionCuller.SetToStartTile(); } } } public static string GetCurrentInteriorName() { return GetInteriorName(GetCurrentDungeonFlow()); } public static string GetInteriorName(DungeonFlow dungeonFlow) { if ((Object)(object)dungeonFlow == (Object)null) { return "DungeonFlow is null"; } InteriorType interiorType = GetInteriorType(dungeonFlow); if (interiorType == InteriorType.Unknown) { return ((Object)dungeonFlow).name; } return interiorType.ToString(); } public static InteriorType GetCurrentInteriorType() { return GetInteriorType(GetCurrentDungeonFlow()); } public static InteriorType GetInteriorType(DungeonFlow dungeonFlow) { string name = ((Object)dungeonFlow).name; if (name.StartsWith("Level1Flow", StringComparison.OrdinalIgnoreCase)) { return InteriorType.Facility; } if (name.StartsWith("Level2Flow", StringComparison.OrdinalIgnoreCase)) { return InteriorType.Mansion; } if (name.StartsWith("Level3Flow", StringComparison.OrdinalIgnoreCase)) { return InteriorType.Mineshaft; } return InteriorType.Unknown; } public static DungeonFlow GetCurrentDungeonFlow() { if ((Object)(object)RoundManager.Instance == (Object)null) { return null; } int currentDungeonType = RoundManager.Instance.currentDungeonType; IndoorMapType[] dungeonFlowTypes = RoundManager.Instance.dungeonFlowTypes; if (currentDungeonType < 0 || currentDungeonType > dungeonFlowTypes.Length - 1) { return null; } return dungeonFlowTypes[currentDungeonType].dungeonFlow; } } internal static class LevelHelper { private static GameObject _environment; public static bool IsForceWeatherEffectsEnabled { get; private set; } public static void Reset() { IsForceWeatherEffectsEnabled = false; } public static void SetSunAndSkyEnabledThisFrame(bool value) { SetSunEnabledThisFrame(value); SetSkyEnabledThisFrame(value); } private static void SetSunEnabledThisFrame(bool value) { TimeOfDay instance = TimeOfDay.Instance; if (!((Object)(object)instance == (Object)null)) { Light sunDirect = instance.sunDirect; if (sunDirect != null) { ((Behaviour)sunDirect).enabled = value; } Light sunIndirect = instance.sunIndirect; if (sunIndirect != null) { ((Behaviour)sunIndirect).enabled = value; } HDAdditionalLightData indirectLightData = instance.indirectLightData; if (indirectLightData != null) { indirectLightData.lightDimmer = (value ? 1f : 0f); } } } private static void SetSkyEnabledThisFrame(bool value) { StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null)) { Volume blackSkyVolume = instance.blackSkyVolume; if (blackSkyVolume != null) { blackSkyVolume.weight = (value ? 0f : 1f); } } } public static void SetWeatherEffectsEnabled(bool value) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected I4, but got Unknown TimeOfDay instance = TimeOfDay.Instance; if (!((Object)(object)instance == (Object)null) && (int)instance.currentLevelWeather != -1) { int num = (int)TimeOfDay.Instance.currentLevelWeather; TimeOfDay.Instance.effects[num].effectEnabled = value; } } public static void SetForceWeatherEffectsEnabled(bool value) { IsForceWeatherEffectsEnabled = value; if (!value && PlayerUtils.IsLocalPlayerCameraInsideInterior()) { TimeOfDay instance = TimeOfDay.Instance; if (instance != null) { instance.DisableAllWeather(false); } } } public static Vector3 GetPositionForWeatherEffects() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) if (PlayerUtils.IsLocalPlayerCameraInsideInterior()) { if (DoorPortal.TryGetRenderingInstance(out var doorPortal)) { return ((Component)doorPortal).transform.position; } return Vector3.zero; } if (PlayerUtils.TryGetLocalPlayerCamera(out var camera)) { return ((Component)camera).transform.position; } return Vector3.zero; } public static string GetCurrentMoonName() { return StartOfRound.Instance?.currentLevel?.PlanetName; } public static bool TryGetEnvironment(out GameObject result) { if ((Object)(object)_environment != (Object)null) { result = _environment; return true; } _environment = GameObject.FindWithTag("OutsideLevelNavMesh"); result = _environment; return (Object)(object)result != (Object)null; } } internal static class NetworkUtils { private static readonly FieldInfo _rpcExecStageField = AccessTools.Field(typeof(NetworkBehaviour), "__rpc_exec_stage"); public static bool IsConnected { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsConnectedClient; } } public static bool IsServer { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsServer; } } public static ulong LocalClientId { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return 0uL; } return singleton.LocalClientId; } } public static int ConnectedPlayerCount => GameNetworkManager.Instance?.connectedPlayers ?? 0; public static bool IsLocalClientId(ulong clientId) { return clientId == LocalClientId; } public static bool HasClient(ulong clientId) { if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } return NetworkManager.Singleton.ConnectedClients.ContainsKey(clientId); } public static bool IsNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return false; } if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } IReadOnlyList prefabs = NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs; return prefabs.Any((NetworkPrefab x) => (Object)(object)x.Prefab == (Object)(object)prefab); } public static void NetcodePatcherAwake() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); IEnumerable loadableTypes = executingAssembly.GetLoadableTypes(); foreach (Type item in loadableTypes) { MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (TargetInvocationException ex) { Logger.LogWarning("[NetworkUtils] Failed to invoke method " + methodInfo.Name + ": " + ex.Message); } } } catch (Exception ex2) { Logger.LogWarning("[NetworkUtils] Error processing method " + methodInfo.Name + " in type " + item.Name + ": " + ex2.Message); } } } } catch (Exception ex3) { Logger.LogError("[NetworkUtils] Failed to run NetcodePatcherAwake: " + ex3.Message); } } public static bool IsExecutingRPCMethod(NetworkBehaviour networkBehaviour) { if ((Object)(object)networkBehaviour == (Object)null) { return false; } NetworkManager networkManager = networkBehaviour.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (_rpcExecStageField == null) { Logger.LogError("[NetworkUtils] IsExecutingRPCMethod: Failed to find \"__rpc_exec_stage\" field."); return false; } object value = _rpcExecStageField.GetValue(networkBehaviour); int num = (int)value; if (num != 0) { return num == 1; } return true; } } internal static class PlayerUtils { public static PlayerControllerB LocalPlayerScript => GameNetworkManager.Instance?.localPlayerController ?? null; public static PlayerControllerB[] AllPlayerScripts => StartOfRound.Instance?.allPlayerScripts ?? Array.Empty(); public static PlayerControllerB[] ConnectedPlayerScripts => AllPlayerScripts.Where(IsConnected).ToArray(); public static PlayerControllerB[] AlivePlayerScripts => ConnectedPlayerScripts.Where((PlayerControllerB x) => !x.isPlayerDead).ToArray(); public static PlayerControllerB[] DeadPlayerScripts => ConnectedPlayerScripts.Where((PlayerControllerB x) => x.isPlayerDead).ToArray(); public static bool TryGetLocalPlayerScript(out PlayerControllerB playerScript) { playerScript = LocalPlayerScript; return (Object)(object)playerScript != (Object)null; } public static bool IsLocalPlayer(PlayerControllerB playerScript) { if ((Object)(object)playerScript == (Object)null) { return false; } return (Object)(object)playerScript == (Object)(object)LocalPlayerScript; } public static bool IsConnected(PlayerControllerB playerScript) { if ((Object)(object)playerScript == (Object)null) { return false; } if (!playerScript.isPlayerControlled) { return playerScript.isPlayerDead; } return true; } public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId) { return ((IEnumerable)ConnectedPlayerScripts).FirstOrDefault((Func)((PlayerControllerB playerScript) => playerScript.actualClientId == clientId)); } public static bool TryGetPlayerScriptByClientId(ulong clientId, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByClientId(clientId); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetPlayerScriptByPlayerId(int playerId) { if (playerId < 0 || playerId > ConnectedPlayerScripts.Length - 1) { return null; } return ConnectedPlayerScripts[playerId]; } public static bool TryGetPlayerScriptByPlayerId(int playerId, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByPlayerId(playerId); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetPlayerScriptByUsername(string username) { PlayerControllerB[] source = ConnectedPlayerScripts.OrderBy((PlayerControllerB x) => x.playerUsername.Length).ToArray(); PlayerControllerB val = ((IEnumerable)source).FirstOrDefault((Func)((PlayerControllerB x) => x.playerUsername.Equals(username, StringComparison.OrdinalIgnoreCase))); if (val == null) { val = ((IEnumerable)source).FirstOrDefault((Func)((PlayerControllerB x) => x.playerUsername.StartsWith(username, StringComparison.OrdinalIgnoreCase))); } if (val == null) { val = ((IEnumerable)source).FirstOrDefault((Func)((PlayerControllerB x) => x.playerUsername.Contains(username, StringComparison.OrdinalIgnoreCase))); } return val; } public static bool TryGetPlayerScriptByUsername(string username, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByUsername(username); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetRandomPlayerScript(PlayerControllerB[] playerScripts, bool excludeLocal = false) { if (playerScripts == null || playerScripts.Length == 0) { return null; } PlayerControllerB[] array = playerScripts.Where((PlayerControllerB playerScript) => !excludeLocal || !IsLocalPlayer(playerScript)).ToArray(); if (array.Length == 0) { return null; } return array[Random.Range(0, array.Length)]; } public static bool TryGetRandomPlayerScript(PlayerControllerB[] playerScripts, out PlayerControllerB playerScript, bool excludeLocal = false) { playerScript = GetRandomPlayerScript(playerScripts, excludeLocal); return (Object)(object)playerScript != (Object)null; } public static Camera GetLocalPlayerCamera() { if ((Object)(object)LocalPlayerScript == (Object)null || LocalPlayerScript.isPlayerDead) { return StartOfRound.Instance.spectateCamera; } return LocalPlayerScript.gameplayCamera; } public static bool TryGetLocalPlayerCamera(out Camera camera) { camera = GetLocalPlayerCamera(); return (Object)(object)camera != (Object)null; } public static bool IsLocalPlayerCameraInsideInterior() { if (!TryGetLocalPlayerScript(out var playerScript)) { return false; } if (!playerScript.isPlayerDead) { return playerScript.isInsideFactory; } if ((Object)(object)playerScript.spectatedPlayerScript != (Object)null) { return playerScript.spectatedPlayerScript.isInsideFactory; } return false; } } internal static class Utils { [CompilerGenerated] private sealed class <>c__DisplayClass7_0 { public Action action; } [CompilerGenerated] private sealed class <>c__DisplayClass8_0 { public TimeSpan timeSpan; public Action action; } public static string GetPluginDirectoryPath() { return Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location); } public static string GetConfigDirectoryPath() { return Paths.ConfigPath; } public static string GetPluginPersistentDataPath() { return Path.Combine(Application.persistentDataPath, "ImmersiveEntrance"); } public static ConfigFile CreateConfigFile(BaseUnityPlugin plugin, string path, string name = null, bool saveOnInit = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown BepInPlugin metadata = MetadataHelper.GetMetadata((object)plugin); if (name == null) { name = metadata.GUID; } name += ".cfg"; return new ConfigFile(Path.Combine(path, name), saveOnInit, metadata); } public static ConfigFile CreateLocalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { return CreateConfigFile(plugin, GetConfigDirectoryPath(), name, saveOnInit); } public static ConfigFile CreateGlobalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { string pluginPersistentDataPath = GetPluginPersistentDataPath(); if (name == null) { name = "global"; } return CreateConfigFile(plugin, pluginPersistentDataPath, name, saveOnInit); } public static bool RollPercentChance(float percent) { if (percent <= 0f) { return false; } if (percent >= 100f) { return true; } return Random.value * 100f <= percent; } public static Coroutine InvokeNextFrame(Action action, MonoBehaviour monoBehaviour = null) { <>c__DisplayClass7_0 CS$<>8__locals0 = new <>c__DisplayClass7_0(); CS$<>8__locals0.action = action; if ((Object)(object)monoBehaviour != (Object)null) { return monoBehaviour.StartCoroutine(Coroutine()); } return CoroutineRunner.Start(Coroutine()); [IteratorStateMachine(typeof(<>c__DisplayClass7_0.<g__Coroutine|0>d))] IEnumerator Coroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass7_0.<g__Coroutine|0>d(0) { <>4__this = CS$<>8__locals0 }; } } public static Coroutine InvokeAfterDelay(Action action, TimeSpan timeSpan, MonoBehaviour monoBehaviour = null) { <>c__DisplayClass8_0 CS$<>8__locals0 = new <>c__DisplayClass8_0(); CS$<>8__locals0.timeSpan = timeSpan; CS$<>8__locals0.action = action; if ((Object)(object)monoBehaviour != (Object)null) { return monoBehaviour.StartCoroutine(Coroutine()); } return CoroutineRunner.Start(Coroutine()); [IteratorStateMachine(typeof(<>c__DisplayClass8_0.<g__Coroutine|0>d))] IEnumerator Coroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass8_0.<g__Coroutine|0>d(0) { <>4__this = CS$<>8__locals0 }; } } } } namespace com.github.zehsteam.ImmersiveEntrance.Helpers.IL { internal class ILInjector { [CompilerGenerated] private sealed class d__34 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; public ILInjector <>4__this; private int offset; public int <>3__offset; private int size; public int <>3__size; private int 5__2; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__34(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; ILInjector iLInjector = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < size) { <>2__current = iLInjector.instructions[iLInjector.index + offset + 5__2]; <>1__state = 1; return true; } 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(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__34 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__34(0) { <>4__this = <>4__this }; } d__.offset = <>3__offset; d__.size = <>3__size; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private const string INVALID = "Injector is invalid"; private List instructions = instructions.ToList(); private ILGenerator generator; private int index; private int matchEnd; public int Index { get { return index; } set { index = value; } } public bool IsValid { get { if (instructions != null) { return IsIndexValid(index); } return false; } } public CodeInstruction Instruction { get { if (!IsIndexInRange(index)) { return null; } return instructions[index]; } set { if (!IsIndexInRange(index)) { throw new InvalidOperationException($"Current index {index} is out of range of instruction count {instructions.Count}"); } instructions[index] = value; } } public CodeInstruction LastMatchedInstruction { get { int num = matchEnd - 1; if (!IsIndexInRange(num)) { return null; } return instructions[num]; } set { int num = matchEnd - 1; if (!IsIndexInRange(num)) { throw new InvalidOperationException($"Last matched index {index} is out of range of instruction count {instructions.Count}"); } instructions[num] = value; } } public ICollection Instructions => instructions.AsReadOnly(); public ILInjector(IEnumerable instructions, ILGenerator generator = null) { this.generator = generator; matchEnd = -1; base..ctor(); } public ILInjector GoToStart() { matchEnd = index; index = 0; return this; } public ILInjector GoToEnd() { matchEnd = index; index = instructions.Count; return this; } public ILInjector Forward(int offset) { if (!IsValid) { return this; } matchEnd = index; index = Math.Clamp(index + offset, -1, instructions.Count); return this; } public ILInjector Back(int offset) { return Forward(-offset); } private void MarkInvalid() { index = -1; matchEnd = -1; } private void Search(bool forward, ILMatcher[] predicates) { if (!IsValid) { return; } int num = 1; if (!forward) { num = -1; index--; } while (forward ? (index < instructions.Count) : (index >= 0)) { if (forward && index + predicates.Length > instructions.Count) { index = instructions.Count; break; } int i; for (i = 0; i < predicates.Length && predicates[i].Matches(instructions[index + i]); i++) { } if (i == predicates.Length) { matchEnd = index + i; return; } index += num; } MarkInvalid(); } public ILInjector Find(params ILMatcher[] predicates) { Search(forward: true, predicates); return this; } public ILInjector ReverseFind(params ILMatcher[] predicates) { Search(forward: false, predicates); return this; } public ILInjector GoToPush(int popIndex) { if (!IsValid) { return this; } matchEnd = index; index--; int num = 0; while (index >= 0) { CodeInstruction instruction = instructions[index]; num += instruction.PushCount(); num -= instruction.PopCount(); if (num >= popIndex) { return this; } index--; } return this; } public ILInjector SkipBranch() { if (Instruction == null) { return this; } if (!(Instruction.operand is Label label)) { throw new InvalidOperationException($"Current instruction is not a branch: {Instruction}"); } return FindLabel(label); } public ILInjector FindLabel(Label label) { if (label == default(Label)) { return this; } matchEnd = index; for (index = 0; index < instructions.Count; index++) { if (instructions[index].labels.Contains(label)) { return this; } } MarkInvalid(); return this; } public ILInjector GoToMatchEnd() { index = matchEnd; return this; } public ILInjector GoToLastMatchedInstruction() { if (!IsIndexValid(matchEnd)) { return this; } index = matchEnd - 1; return this; } private bool IsIndexValid(int index) { return index != -1; } private bool IsIndexInRange(int index) { if (index >= 0) { return index < instructions.Count; } return false; } public CodeInstruction GetRelativeInstruction(int offset) { if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } int num = index + offset; if (!IsIndexInRange(num)) { throw new IndexOutOfRangeException($"Offset {offset} would read out of bounds at index {num}"); } return instructions[num]; } public ILInjector SetRelativeInstruction(int offset, CodeInstruction instruction) { if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } int num = index + offset; if (!IsIndexInRange(num)) { throw new IndexOutOfRangeException($"Offset {offset} would write out of bounds at index {num}"); } instructions[num] = instruction; return this; } [IteratorStateMachine(typeof(d__34))] public IEnumerable GetRelativeInstructions(int offset, int size) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__34(-2) { <>4__this = this, <>3__offset = offset, <>3__size = size }; } public IEnumerable GetRelativeInstructions(int size) { return GetRelativeInstructions(0, size); } private void GetLastMatchRangeAbsolute(out int start, out int end) { start = index; end = matchEnd; if (start > end) { int num = end; int num2 = start; start = num; end = num2; } } private void GetLastMatchRange(out int start, out int size) { GetLastMatchRangeAbsolute(out start, out var end); if (start < 0 || start >= instructions.Count) { throw new InvalidOperationException($"Last match range starts at invalid index {start}"); } if (end < 0 || end > instructions.Count) { throw new InvalidOperationException($"Last match range ends at invalid index {end}"); } size = end - start; } public List GetLastMatch() { GetLastMatchRange(out var start, out var size); return instructions.GetRange(start, size); } public ILInjector DefineLabel(out Label label) { if (generator == null) { throw new InvalidOperationException("No ILGenerator was provided"); } label = generator.DefineLabel(); return this; } public ILInjector AddLabel(out Label label) { DefineLabel(out label); return AddLabel(label); } public ILInjector AddLabel(Label label) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Instruction = new CodeInstruction(Instruction); Instruction.labels.Add(label); return this; } public ILInjector InsertInPlace(ICollection instructions) { if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } this.instructions.InsertRange(index, instructions); if (matchEnd >= index) { matchEnd += instructions.Count; } return this; } public ILInjector Insert(ICollection instructions) { InsertInPlace(instructions); index += instructions.Count; return this; } public ILInjector InsertInPlaceAfterBranch(ICollection instructions) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } List