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.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 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.Rendering; using UnityEngine.Rendering.HighDefinition; using com.github.zehsteam.ImmersiveEntrance.Dependencies.LethalConfigMod; using com.github.zehsteam.ImmersiveEntrance.Extensions; using com.github.zehsteam.ImmersiveEntrance.Helpers; 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; [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.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+911fd64ffdf339a94c25a9e8d80bcfae667b8156")] [assembly: AssemblyProduct("ImmersiveEntrance")] [assembly: AssemblyTitle("com.github.zehsteam.ImmersiveEntrance")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace 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 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); 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.0.0")] [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.0.0"; } } namespace com.github.zehsteam.ImmersiveEntrance.Patches { [HarmonyPatch(typeof(EntranceTeleport))] internal static class EntranceTeleport_Patches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake_Patch(EntranceTeleport __instance) { EntranceDoorReplacementManager.ReplaceDoor(__instance); 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)) { EntranceManager.LinkMainEntrancePortals(); } } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRound_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] [HarmonyPriority(0)] private static void Start_Patch() { PortalSettingsManager.Initialize(); } [HarmonyPatch("EndOfGame")] [HarmonyPostfix] private static void EndOfGame_Patch() { EntranceManager.Reset(); } [HarmonyPatch("OnLocalDisconnect")] [HarmonyPostfix] private static void OnLocalDisconnect_Patch() { EntranceManager.Reset(); } } [HarmonyPatch(typeof(TimeOfDay))] internal static class TimeOfDay_Patches { [HarmonyPatch("SetInsideLightingDimness")] [HarmonyPostfix] private static void SetInsideLightingDimness_Patch(TimeOfDay __instance) { float lightDimmer = (PlayerUtils.IsLocalPlayerCameraInsideInterior() ? 0f : 1f); __instance.indirectLightData.lightDimmer = lightDimmer; } } } namespace com.github.zehsteam.ImmersiveEntrance.Objects { [CreateAssetMenu(menuName = "ImmersiveEntrance/EntranceDoorReplacement", order = 0, fileName = "EntranceDoorReplacement")] public class EntranceDoorReplacement : ScriptableObject { [field: SerializeField] public GameObject DoorLeft { get; private set; } [field: SerializeField] public GameObject DoorRight { get; private set; } } internal enum InteriorType { Facility = 0, Mansion = 1, Mineshaft = 2, Unknown = 999 } public class MainEntranceData { public EntranceTeleport EntranceTeleport { get; set; } public DoorPortal DoorPortal { get; set; } public GameObject DoorViewBlocker { get; set; } public List DoorObjects { get; set; } = new List(); public bool IsOutside => EntranceTeleport.IsOutside(); public bool HasEntranceTeleport => (Object)(object)EntranceTeleport != (Object)null; public bool HasDoorPortal => (Object)(object)DoorPortal != (Object)null; public bool HasDoorViewBlocker => (Object)(object)DoorViewBlocker != (Object)null; public bool HasDoorObjects { get { if (DoorObjects != null) { return DoorObjects.Count > 0; } return false; } } public void Reset() { EntranceTeleport = null; DoorViewBlocker = null; DoorObjects.Clear(); if ((Object)(object)DoorPortal != (Object)null) { Object.Destroy((Object)(object)DoorPortal); } } public void SetDoorObjectsEnabled(bool value) { if (DoorObjects == null || DoorObjects.Count == 0) { return; } foreach (GameObject doorObject in DoorObjects) { if (!((Object)(object)doorObject == (Object)null)) { doorObject.SetActive(value); } } } } internal 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; } } internal enum PixelResolutionType { PlayerCamera, Default, Performance, UltraPerformance, Retro } } namespace com.github.zehsteam.ImmersiveEntrance.Objects.PortalSettingTypes { internal 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; 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() { 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; } } internal 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(" ")); } } internal abstract class PortalSettings { public struct DefaultValues { public bool Enabled { get; set; } public bool UseDynamicPivot { get; set; } public Vector3 PivotPositionOffset { 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) PivotPositionOffset = default(Vector3); ScreenCrop = default(Padding); UseViewDistance = false; Enabled = true; UseDynamicPivot = true; ViewDistance = 50f; } public DefaultValues(bool enabled = true, bool useDynamicPivot = true, Vector3? pivotPositionOffset = 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) Enabled = enabled; UseDynamicPivot = useDynamicPivot; PivotPositionOffset = (Vector3)(((??)pivotPositionOffset) ?? Vector3.zero); ScreenCrop = screenCrop.GetValueOrDefault(); UseViewDistance = viewDistance.HasValue; ViewDistance = viewDistance.GetValueOrDefault(50f); } } private DefaultValues _defaultValues; public ConfigEntry Enabled { get; private set; } public bool UseDynamicPivot => _defaultValues.UseDynamicPivot; public Vector3 PivotPositionOffset => _defaultValues.PivotPositionOffset; 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(); }; } } } 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 Transform _volumeContainer; private MainEntranceData _mainEntrance; private PortalSettings _portalSettings; private DoorPortal _linkedPortal; private RenderTexture _viewTexture; private bool _isDrawing; private bool _isInRange; private LayerMask _pivotRaycastMask; public Camera PortalCamera => _portalCamera; private void Awake() { //IL_0014: 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) _pivotRaycastMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Room" })); ((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() { InitializeVolumes(); InitializePivot(); } 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; if (mainEntrance.IsOutside) { _portalSettings = PortalSettingsManager.GetCurrentMoonSettings(); } else { _portalSettings = PortalSettingsManager.GetCurrentInteriorSettings(); } InitializeScreen(); InitializeCamera(); } 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()) { _isInRange = false; OnLocalPlayerExitRange(); return; } bool flag = IsLocalPlayerCameraInRange(); bool flag2 = CameraHelper.IsVisibleFromCamera((Renderer)(object)_screen, PlayerUtils.GetLocalPlayerCamera()); if (flag && flag2) { if (!_isInRange) { _isInRange = true; OnLocalPlayerEnterRange(); } } else if (_isInRange) { _isInRange = 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, ((Component)this).transform.position); return num <= value; } private void OnLocalPlayerEnterRange() { SetDrawing(value: true); _linkedPortal.SetRendering(value: true); if (_mainEntrance.IsOutside) { InteriorHelper.RenderInterior(); } } private void OnLocalPlayerExitRange() { SetDrawing(value: false); _linkedPortal.SetRendering(value: false); _ = _mainEntrance.IsOutside; } private void InitializeVolumes() { CreateVolumesFromScene(); } private void CreateVolumesFromScene() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00d5: 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) foreach (Transform child in _volumeContainer.GetChildren()) { Object.Destroy((Object)(object)((Component)child).gameObject); } Volume[] array = (from x in Object.FindObjectsByType((FindObjectsSortMode)0) where x.isGlobal && ((Component)x).gameObject.layer == 0 select x).ToArray(); if (array.Length != 0) { LayerMask val = LayerMask.op_Implicit(LayerMask.NameToLayer("NavigationSurface")); Volume[] array2 = array; foreach (Volume val2 in array2) { GameObject val3 = Object.Instantiate(((Component)val2).gameObject, _volumeContainer); val3.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); val3.layer = LayerMask.op_Implicit(val); BoxCollider val4 = val3.AddComponent(); val4.size = Vector3.one * 0.1f; Volume component = val3.GetComponent(); component.isGlobal = false; } } } private void InitializePivot() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (_portalSettings.UseDynamicPivot) { SetDynamicPivot(); } Transform pivot = _pivot; pivot.localPosition += _portalSettings.PivotPositionOffset; } private void SetDynamicPivot() { //IL_0010: 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) 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.001f; Vector3 val = ((RaycastHit)(ref hit)).point + _pivot.forward * num; if (TryRaycastForPivot(origin, -_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); } private void SetScreenCrop(Padding padding) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0103: 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) ((Renderer)_screen).material.SetFloat("_CropLeft", padding.Left); ((Renderer)_screen).material.SetFloat("_CropRight", padding.Right); ((Renderer)_screen).material.SetFloat("_CropTop", padding.Top); ((Renderer)_screen).material.SetFloat("_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); } 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() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (_mainEntrance != null) { HDAdditionalCameraData component = ((Component)_portalCamera).GetComponent(); if (_mainEntrance.IsOutside) { component.clearColorMode = (ClearColorMode)0; } else { component.clearColorMode = (ClearColorMode)1; } CreateViewTexture(); } } private void ApplyCameraViewDistance() { if (_mainEntrance != null) { float farClipPlane = (_portalSettings.UseViewDistance.Value ? _portalSettings.ViewDistance.Value : ((!_mainEntrance.IsOutside) ? ConfigManager.Portal_InsideViewDistance.Value : ConfigManager.Portal_OutsideViewDistance.Value)); _portalCamera.farClipPlane = farClipPlane; } } private Size GetTargetScreenSize() { return ConfigManager.Portal_PixelResolution.Value switch { PixelResolutionType.PlayerCamera => CameraHelper.GetCameraScreenSize(), PixelResolutionType.Default => new Size(860, 520), PixelResolutionType.Performance => new Size(620, 364), PixelResolutionType.UltraPerformance => new Size(400, 260), PixelResolutionType.Retro => new Size(186, 104), _ => CameraHelper.GetCameraScreenSize(), }; } private void CreateViewTexture() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown Size targetScreenSize = GetTargetScreenSize(); if (CanCreate()) { RenderTexture viewTexture = _viewTexture; if (viewTexture != null) { viewTexture.Release(); } _viewTexture = new RenderTexture(targetScreenSize.Width, targetScreenSize.Height, 24, (RenderTextureFormat)9); Logger.LogInfo(string.Format("[{0}] {1}() width: {2}, height: {3}", "DoorPortal", "CreateViewTexture", targetScreenSize.Width, targetScreenSize.Height), extended: true); _portalCamera.targetTexture = _viewTexture; _linkedPortal?.SetScreenRenderTexture(_viewTexture); } bool CanCreate() { if ((Object)(object)_viewTexture == (Object)null) { return true; } if (((Texture)_viewTexture).width != targetScreenSize.Width) { return true; } if (((Texture)_viewTexture).height != targetScreenSize.Height) { return true; } return false; } } private bool IsRendering() { return _renderingContainer.activeSelf; } private void SetRendering(bool value) { _renderingContainer.SetActive(value); if (_mainEntrance != null) { if (value) { ApplyCameraViewDistance(); } 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); SetObliqueNearClipPlane(camera); OutsideHelper.SetSunEnabled(_mainEntrance.IsOutside); _portalCamera.Render(); OutsideHelper.SetSunEnabled(!_mainEntrance.IsOutside); } } private void SetObliqueNearClipPlane(Camera playerCamera) { //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_0079: 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) 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.projectionMatrix = playerCamera.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) { return; } if (_mainEntrance.HasDoorViewBlocker) { if (IsRendering()) { _mainEntrance.DoorViewBlocker.SetActive(false); } else { _mainEntrance.DoorViewBlocker.SetActive(!_isDrawing); } } if (ConfigManager.Debug_HideDoorObjects.Value) { _mainEntrance.SetDoorObjectsEnabled(value: false); } else { _mainEntrance.SetDoorObjectsEnabled(!IsRendering()); } } private void ApplyConfigSettings() { ApplyCameraViewDistance(); } public static void OnConfigSettingsChanged() { foreach (DoorPortal instance in _instances) { instance.ApplyConfigSettings(); } } } } 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_PixelResolution { get; private set; } public static ConfigEntry Portal_ActivationRange { get; private set; } public static ConfigEntry Portal_OutsideViewDistance { get; private set; } public static ConfigEntry Portal_InsideViewDistance { get; private set; } public static ConfigEntry Debug_HideDoorObjects { 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!"); 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."); Portal_PixelResolution = ConfigHelper.Bind("Portal", "PixelResolution", PixelResolutionType.PlayerCamera, stringBuilder.ToString()); 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)); Portal_OutsideViewDistance = ConfigHelper.Bind("Portal", "OutsideViewDistance", 250f, "The distance you can see through an outside portal.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0.06f, 250f)); Portal_InsideViewDistance = ConfigHelper.Bind("Portal", "InsideViewDistance", 50f, "The distance you can see through an inside portal.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0.06f, 100f)); Portal_OutsideViewDistance.SettingChanged += delegate { DoorPortal.OnConfigSettingsChanged(); }; Portal_InsideViewDistance.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."); } } internal static class EntranceDoorReplacementManager { [CompilerGenerated] private sealed class <>c__DisplayClass3_0 { public float delay; public GameObject gameObject; } public static void ReplaceDoor(EntranceTeleport entranceTeleport) { if (!((Object)(object)entranceTeleport == (Object)null) && entranceTeleport.IsMainEntrance() && !entranceTeleport.IsOutside()) { InteriorPortalSettings currentInteriorSettings = PortalSettingsManager.GetCurrentInteriorSettings(); if (currentInteriorSettings.HasDoorReplacement && currentInteriorSettings.ReplaceDoor.Value) { ReplaceDoor(entranceTeleport, currentInteriorSettings.GetDoorReplacement()); } } } private static void ReplaceDoor(EntranceTeleport entranceTeleport, EntranceDoorReplacement replacement) { if ((Object)(object)entranceTeleport == (Object)null || (Object)(object)replacement == (Object)null) { return; } if (!InteriorHelper.TryGetVisualDoorsContainer(entranceTeleport, out var transform)) { Logger.LogError("[EntranceDoorReplacementManager] Failed to replace main entrance door " + entranceTeleport.GetLogInfo() + " with " + ((Object)replacement).name + ". Could not find visual doors container."); return; } Transform val = transform.Find("DoorMesh (1)"); Transform val2 = transform.Find("DoorMesh"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Logger.LogError("[EntranceDoorReplacementManager] Failed to replace main entrance door " + 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 " + 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 readonly Dictionary _entranceToPortals = new Dictionary(); private static bool _linkedMainEntrancePortals; public static IReadOnlyDictionary EntranceToPortals => _entranceToPortals; public static MainEntranceData OutsideMainEntrance { get; private set; } public static MainEntranceData InsideMainEntrance { get; private set; } public static void Reset() { OutsideMainEntrance.Reset(); InsideMainEntrance.Reset(); _linkedMainEntrancePortals = false; foreach (KeyValuePair entranceToPortal in _entranceToPortals) { DoorPortal value = entranceToPortal.Value; if (!((Object)(object)value == (Object)null)) { Object.Destroy((Object)(object)((Component)value).gameObject); Logger.LogInfo("[EntranceManager] Reset() Destroyed DoorPortal " + entranceToPortal.Key?.GetLogInfo(), extended: true); } } _entranceToPortals.Clear(); } public static void SpawnDoorPortal(EntranceTeleport entranceTeleport) { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)entranceTeleport == (Object)null || !entranceTeleport.IsMainEntrance()) { return; } Logger.LogInfo("[EntranceManager] Attempting to spawn main entrance door portal! " + entranceTeleport.GetLogInfo()); if (_entranceToPortals.ContainsKey(entranceTeleport)) { Logger.LogWarning("[EntranceManager] Failed to spawn main entrance door portal. This EntranceTeleport is already in use!"); return; } if (_entranceToPortals.Count >= 2) { Logger.LogError(string.Format("[{0}] Failed to spawn main entrance door portal. There are already {1} entrance portals.", "EntranceManager", _entranceToPortals.Count)); return; } MainEntranceData mainEntranceData; if (entranceTeleport.IsOutside()) { if (OutsideMainEntrance == null) { OutsideMainEntrance = new MainEntranceData(); } OutsideMainEntrance.Reset(); mainEntranceData = OutsideMainEntrance; mainEntranceData.EntranceTeleport = entranceTeleport; mainEntranceData.DoorViewBlocker = OutsideHelper.GetDoorViewBlocker(entranceTeleport); mainEntranceData.DoorObjects = OutsideHelper.GetDoorObjects(entranceTeleport); } else { if (InsideMainEntrance == null) { InsideMainEntrance = new MainEntranceData(); } InsideMainEntrance.Reset(); mainEntranceData = InsideMainEntrance; mainEntranceData.EntranceTeleport = entranceTeleport; mainEntranceData.DoorViewBlocker = InteriorHelper.GetDoorViewBlocker(entranceTeleport); mainEntranceData.DoorObjects = InteriorHelper.GetDoorObjects(entranceTeleport); } if (mainEntranceData.HasDoorViewBlocker) { Logger.LogInfo("[EntranceManager] Successfully found main entrance door view blocker! " + entranceTeleport.GetLogInfo()); 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()); _entranceToPortals.Add(entranceTeleport, doorPortal); doorPortal.SetMainEntranceData(mainEntranceData); Logger.LogInfo("[EntranceManager] Successfully spawned main entrance door portal! " + entranceTeleport.GetLogInfo()); } else { Logger.LogWarning("[EntranceManager] Failed to spawn main entrance door portal. Could not find main entrance door view blocker. " + entranceTeleport.GetLogInfo()); mainEntranceData?.Reset(); } } public static void LinkMainEntrancePortals() { if (_linkedMainEntrancePortals) { return; } _linkedMainEntrancePortals = true; Logger.LogInfo("[EntranceManager] Attempting to link main entrance portals."); Logger.LogInfo(string.Format("[{0}] There are {1} entrance portals.", "EntranceManager", _entranceToPortals.Count), extended: true); bool flag = true; if (!OutsideMainEntrance.HasDoorPortal) { Logger.LogError("[EntranceManager] Failed to link main entrance portal. Outside door portal was not spawned."); flag = false; } if (!InsideMainEntrance.HasDoorPortal) { Logger.LogError("[EntranceManager] Failed to link main entrance portal. Inside door portal was not spawned."); flag = false; } if (!flag) { Logger.LogError("[EntranceManager] Failed to link main entrance portals."); 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); } } } internal static class PortalSettingsManager { private static readonly List _moonEntries; private static readonly List _predefinedMoonEntries; private static readonly List _interiorEntries; private static readonly List _predefinedInteriorEntries; private static bool _initialized; public static IReadOnlyList MoonEntries => _moonEntries; public static IReadOnlyList InteriorEntries => _interiorEntries; static PortalSettingsManager() { //IL_007e: 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_0131: Unknown result type (might be due to invalid IL or missing references) _moonEntries = new List(); _predefinedMoonEntries = new List(); _interiorEntries = new List(); _predefinedInteriorEntries = new List(); List predefinedMoonEntries = _predefinedMoonEntries; float? viewDistance = 75f; predefinedMoonEntries.Add(new MoonPortalSettings("85 Rend", new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, null, null, viewDistance))); _predefinedInteriorEntries.Add(new InteriorPortalSettings(InteriorType.Facility, new InteriorPortalSettings.InteriorDefaultValues(), new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: false, (Vector3?)new Vector3(0f, 0f, -0.133f), (Padding?)null, (float?)null))); _predefinedInteriorEntries.Add(new InteriorPortalSettings(InteriorType.Mansion, new InteriorPortalSettings.InteriorDefaultValues(() => Assets.MansionEntranceDoorReplacement), new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, (Vector3?)new Vector3(-0.038f, 0f, 0f), (Padding?)new Padding(0.05f, 0.05f, 0.025f, 0f), (float?)null))); List predefinedInteriorEntries = _predefinedInteriorEntries; InteriorPortalSettings.InteriorDefaultValues interiorDefaultValues = new InteriorPortalSettings.InteriorDefaultValues(); Vector3? pivotPositionOffset = new Vector3(-0.105f, 0f, 0f); viewDistance = 30f; predefinedInteriorEntries.Add(new InteriorPortalSettings(InteriorType.Mineshaft, interiorDefaultValues, new PortalSettings.DefaultValues(enabled: true, useDynamicPivot: true, pivotPositionOffset, null, viewDistance))); } public static void Initialize() { if (!_initialized) { _initialized = true; PopulateEntries(); BindConfigs(); } } private static void PopulateEntries() { PopulateMoonEntries(); PopulateInteriorEntries(); } 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 void AddMoonEntry(SelectableLevel level) { if (level.planetHasTime && !_moonEntries.Any((MoonPortalSettings x) => x.Matches(level))) { MoonPortalSettings moonPortalSettings = _predefinedMoonEntries.FirstOrDefault((MoonPortalSettings x) => x.Matches(level)); if (moonPortalSettings != null) { _moonEntries.Add(moonPortalSettings); } else { _moonEntries.Add(new MoonPortalSettings(level.PlanetName, new PortalSettings.DefaultValues())); } } } private static void AddInteriorEntry(DungeonFlow dungeonFlow) { if (_interiorEntries.Any((InteriorPortalSettings x) => x.Matches(dungeonFlow))) { return; } InteriorPortalSettings interiorPortalSettings = _predefinedInteriorEntries.FirstOrDefault((InteriorPortalSettings x) => x.Matches(dungeonFlow)); if (interiorPortalSettings != null) { _interiorEntries.Add(interiorPortalSettings); return; } InteriorPortalSettings.InteriorDefaultValues interiorDefaultValues = new InteriorPortalSettings.InteriorDefaultValues(); PortalSettings.DefaultValues defaultValues = new PortalSettings.DefaultValues(); InteriorType interiorType = InteriorHelper.GetInteriorType(dungeonFlow); if (interiorType == InteriorType.Unknown) { _interiorEntries.Add(new InteriorPortalSettings(((Object)dungeonFlow).name, interiorDefaultValues, defaultValues)); } else { _interiorEntries.Add(new InteriorPortalSettings(interiorType, interiorDefaultValues, defaultValues)); } } private static void BindConfigs() { BindInteriorConfigs(); BindMoonConfigs(); } private static void BindMoonConfigs() { List list = _moonEntries.OrderBy((MoonPortalSettings x) => x.GetStrippedPlanetName()).ToList(); foreach (MoonPortalSettings item in list) { item.BindConfigs(); } } private static void BindInteriorConfigs() { List list = _interiorEntries.OrderBy((InteriorPortalSettings x) => x.GetInteriorName()).ToList(); foreach (InteriorPortalSettings item in list) { item.BindConfigs(); } } public static MoonPortalSettings GetCurrentMoonSettings() { return GetMoonSettings(StartOfRound.Instance?.currentLevel); } public static InteriorPortalSettings GetCurrentInteriorSettings() { return GetInteriorSettings(InteriorHelper.GetCurrentDungeonFlow()); } public static MoonPortalSettings GetMoonSettings(SelectableLevel level) { return _moonEntries.FirstOrDefault((MoonPortalSettings x) => x.Matches(level)); } public static InteriorPortalSettings GetInteriorSettings(DungeonFlow dungeonFlow) { return _interiorEntries.FirstOrDefault((InteriorPortalSettings x) => x.Matches(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 GameObjectHelper { public static bool TryFind(string name, out GameObject gameObject) { gameObject = GameObject.Find(name); 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 GameObject GetDoorViewBlocker(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport == (Object)null) { return null; } if (!TryGetVisualDoorsContainer(entranceTeleport, out var transform)) { return null; } if (transform.TryFind("LightBehindDoor", out var result)) { return ((Component)result).gameObject; } return null; } public static List GetDoorObjects(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport == (Object)null) { return new List(); } if (!TryGetVisualDoorsContainer(entranceTeleport, out var transform)) { return new List(); } string[] source = new string[6] { "SteelDoorFake", "SteelDoorFake (1)", "DoorFrame", "DoorMesh", "DoorMesh (1)", "WideDoorFrame (1)" }; List list = new List(); foreach (Transform child in transform.GetChildren()) { if (source.Contains(((Object)child).name, StringComparer.OrdinalIgnoreCase)) { list.Add(((Component)child).gameObject); } } return list; } public static Transform GetVisualDoorsContainer(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport.thisEntranceAnimator != (Object)null) { return ((Component)entranceTeleport.thisEntranceAnimator).transform; } GameObject obj = GameObject.FindGameObjectWithTag("InsideEntranceDoor"); return ((obj != null) ? obj.transform : null) ?? null; } public static bool TryGetVisualDoorsContainer(EntranceTeleport entranceTeleport, out Transform transform) { transform = GetVisualDoorsContainer(entranceTeleport); return (Object)(object)transform != (Object)null; } 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() { return RoundManager.Instance.dungeonFlowTypes[RoundManager.Instance.currentDungeonType].dungeonFlow; } } 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 OutsideHelper { public static void SetSunEnabled(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); } } } public static GameObject GetDoorViewBlocker(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport == (Object)null) { return null; } if (TryGetVisualDoorsContainer(entranceTeleport, out var transform) && transform.TryFind("Plane", out var result)) { return ((Component)result).gameObject; } if (GameObjectHelper.TryFind("Environment/Plane", out var gameObject)) { return gameObject; } if (GameObjectHelper.TryFind("Environment/MainFactory/Plane", out gameObject)) { return gameObject; } return null; } public static List GetDoorObjects(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport == (Object)null) { return new List(); } if (!TryGetVisualDoorsContainer(entranceTeleport, out var transform)) { return new List(); } string[] source = new string[3] { "SteelDoorFake", "SteelDoorFake (1)", "DoorFrame" }; List list = new List(); foreach (Transform child in transform.GetChildren()) { if (source.Contains(((Object)child).name, StringComparer.OrdinalIgnoreCase)) { list.Add(((Component)child).gameObject); } } if (GameObjectHelper.TryFind("Environment/DoorFrame (1)", out var gameObject)) { list.Add(gameObject); } if (GameObjectHelper.TryFind("Environment/MainFactory/DoorFrame (1)", out gameObject)) { list.Add(gameObject); } return list; } private static Transform GetVisualDoorsContainer(EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport.thisEntranceAnimator != (Object)null) { return ((Component)entranceTeleport.thisEntranceAnimator).transform; } try { return GameObject.Find("Environment/OutsideEntranceVisualDoorsContainer").transform; } catch { } return null; } private static bool TryGetVisualDoorsContainer(EntranceTeleport entranceTeleport, out Transform transform) { transform = GetVisualDoorsContainer(entranceTeleport); return (Object)(object)transform != (Object)null; } } 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 { 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; } } } namespace com.github.zehsteam.ImmersiveEntrance.Extensions { internal static class AssemblyExtensions { public static IEnumerable GetLoadableTypes(this Assembly assembly) { if (assembly == null) { return Array.Empty(); } try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type type) => type != null); } } } internal static class ConfigFileExtensions { public static ConfigEntry Bind(this ConfigFile configFile, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (acceptableValues == null) { return configFile.Bind(section, key, defaultValue, description); } return configFile.Bind(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty())); } } internal static class EntranceTeleportExtensions { public static bool IsMainEntrance(this EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport == (Object)null) { return false; } return entranceTeleport.entranceId == 0; } public static bool IsOutside(this EntranceTeleport entranceTeleport) { return entranceTeleport.isEntranceToBuilding; } public static string GetLogInfo(this EntranceTeleport entranceTeleport) { if ((Object)(object)entranceTeleport == (Object)null) { return "(EntranceTeleport is null)"; } return $"(entranceId: {entranceTeleport.entranceId}, isEntranceToBuilding: {entranceTeleport.isEntranceToBuilding})"; } } internal static class StringExtensions { public static bool IsHexColor(this string value) { return Regex.IsMatch(value, "^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$"); } } internal static class TransformExtensions { public static bool TryFind(this Transform transform, string name, out Transform result) { if ((Object)(object)transform == (Object)null) { result = null; return false; } result = transform.Find(name); return (Object)(object)result != (Object)null; } public static List GetChildren(this Transform transform) { List list = new List(); for (int i = 0; i < transform.childCount; i++) { list.Add(transform.GetChild(i)); } return list; } public static void SetLossyScale(this Transform transform, Vector3 scale) { //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_002d: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0071: 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_008c: 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_0093: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)transform == (Object)null)) { if ((Object)(object)transform.parent == (Object)null) { transform.localScale = scale; return; } Vector3 lossyScale = transform.parent.lossyScale; transform.localScale = new Vector3((lossyScale.x != 0f) ? (scale.x / lossyScale.x) : scale.x, (lossyScale.y != 0f) ? (scale.y / lossyScale.y) : scale.y, (lossyScale.z != 0f) ? (scale.z / lossyScale.z) : scale.z); } } } } namespace com.github.zehsteam.ImmersiveEntrance.Dependencies.LethalConfigMod { internal static class LethalConfigProxy { public const string PLUGIN_GUID = "ainavt.lc.lethalconfig"; public static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static object AddConfig(ConfigEntry configEntry, bool requiresRestart = false) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown if (typeof(T).IsEnum) { MethodInfo methodInfo = AccessTools.Method(typeof(LethalConfigProxy), "AddEnumDropdown", (Type[])null, (Type[])null); MethodInfo methodInfo2 = methodInfo.MakeGenericMethod(typeof(T)); object? obj = methodInfo2.Invoke(null, new object[2] { configEntry, requiresRestart }); return (obj is BaseConfigItem) ? obj : null; } AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues; if (acceptableValues != null) { if (acceptableValues is AcceptableValueRange || acceptableValues is AcceptableValueRange) { return AddConfigSlider(configEntry, requiresRestart); } if (acceptableValues is AcceptableValueList) { return AddConfigDropdown(configEntry, requiresRestart); } } if (configEntry is ConfigEntry val && IsConfigEntryForHexColor(val)) { return AddConfigItem((BaseConfigItem)new HexColorInputFieldConfigItem(val, requiresRestart)); } if (!(configEntry is ConfigEntry val2)) { if (!(configEntry is ConfigEntry val3)) { if (!(configEntry is ConfigEntry val4)) { if (configEntry is ConfigEntry val5) { return AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val5, requiresRestart)); } throw new NotSupportedException($"Unsupported type: {typeof(T)}"); } return AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val4, requiresRestart)); } return AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart)); } return AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val2, requiresRestart)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static object AddButton(string section, string name, string buttonText, string description, Action callback) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown BaseConfigItem configItem = (BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); }); return AddConfigItem(configItem); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddConfigSlider(ConfigEntry configEntry, bool requiresRestart = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!(configEntry is ConfigEntry val)) { if (configEntry is ConfigEntry val2) { return AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart)); } throw new NotSupportedException($"Slider not supported for type: {typeof(T)}"); } return AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddConfigDropdown(ConfigEntry configEntry, bool requiresRestart = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (configEntry is ConfigEntry val) { return AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart)); } throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}"); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddEnumDropdown(ConfigEntry configEntry, bool requiresRestart = false) where T : Enum { return AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem(configEntry, requiresRestart)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static bool IsConfigEntryForHexColor(ConfigEntry configEntry) { if (!(((ConfigEntryBase)configEntry).DefaultValue is string value)) { return false; } return value.IsHexColor(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddConfigItem(BaseConfigItem configItem) { LethalConfigManager.AddConfigItem(configItem); return configItem; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }