Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DynamicTeleportAreas v1.0.0
DynamicTeleportAreas.dll
Decompiled 3 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyMetadata("ValheimManagedFolder", "/home/runner/work/DynamicTeleportAreas/DynamicTeleportAreas/env_mock/valheim_Data/Managed")] [assembly: AssemblyMetadata("BepInExCoreFolder", "/home/runner/work/DynamicTeleportAreas/DynamicTeleportAreas/env_mock/BepInEx/core")] [assembly: AssemblyCompany("DynamicTeleportAreas")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Dynamic Loaded Area Adjuster for Portal Transitions")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f395d416442e28cd30daf196efa0c3b29a5a0331")] [assembly: AssemblyProduct("DynamicTeleportAreas")] [assembly: AssemblyTitle("DynamicTeleportAreas")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 DynamicTeleportAreas { [BepInPlugin("com.arifogel.dynamicteleportareas", "DynamicTeleportAreas", "1.0.0")] public class DynamicTeleportAreasPlugin : BaseUnityPlugin { private const string PluginGuid = "com.arifogel.dynamicteleportareas"; private const string PluginName = "DynamicTeleportAreas"; private const string PluginVersion = "1.0.0"; private static DynamicTeleportAreasPlugin s_instance; public static bool SuppressNotifications; internal static ConfigEntry<bool> Enabled; private static ConfigEntry<bool> s_enableMessageHudNotifications; private static ConfigEntry<int> s_normalLoadedArea; private static ConfigEntry<int> s_normalGeneratedArea; internal static ConfigEntry<int> TeleportLoadedArea; internal static ConfigEntry<int> TeleportGeneratedArea; private static ConfigEntry<int> s_frameDelayCount; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) s_instance = this; InitConfiguration(); new Harmony("com.arifogel.dynamicteleportareas").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"DynamicTeleportAreas initialized and configs bound."); } private void InitConfiguration() { Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Global Settings", "Enabled", true, "Whether mod should be enabled or disabled."); s_enableMessageHudNotifications = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Global Settings", "MessageHudNotifications", false, "When Enabled, on-screen notifications are shown at top-left when this mod changes Loaded/Generated areas during portal transitions."); s_normalLoadedArea = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Standard Gameplay Environment", "NormalLoadedArea", 4, "The 'Loaded zones' value restored after portal stabilization completes."); s_normalGeneratedArea = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Standard Gameplay Environment", "NormalGeneratedArea", 6, "The 'Generated zones' value restored after portal stabilization completes."); TeleportLoadedArea = ((BaseUnityPlugin)this).Config.Bind<int>("3 - Portal Transition Environment", "PortalLoadedArea", 2, "The temporary 'Loaded zones' value enforced during portal loading screens."); TeleportGeneratedArea = ((BaseUnityPlugin)this).Config.Bind<int>("3 - Portal Transition Environment", "PortalGeneratedArea", 4, "The temporary 'Generated zones' value enforced during portal loading screens."); s_frameDelayCount = ((BaseUnityPlugin)this).Config.Bind<int>("4 - Engine Timing Controls", "FrameDelayCount", 30, "The number of engine frames to wait after exiting a portal before restoring standard render limits. Higher values delay full world detail but prevent post-portal stutter. The optimal value is the lowest setting where your framerate fully stabilizes before the environment expands."); } public static void SetRenderLimits(int loaded, int generated) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown if (s_instance == null) { return; } if (!s_enableMessageHudNotifications.Value) { SuppressNotifications = true; } try { if ((Object)(object)Console.instance != (Object)null) { ((Terminal)Console.instance).TryRunCommand($"render_config loaded_zones {loaded}", false, false); ((Terminal)Console.instance).TryRunCommand($"render_config loaded_area {loaded}", false, false); ((Terminal)Console.instance).TryRunCommand($"render_config generated_zones {generated}", false, false); ((Terminal)Console.instance).TryRunCommand($"render_config generated_area {generated}", false, false); ((Terminal)Console.instance).TryRunCommand($"render_config distant_area {generated}", false, false); } } finally { SuppressNotifications = false; } if (Chainloader.PluginInfos.TryGetValue("valheim.jerekuusela.render_limits", out var value)) { IDictionary<ConfigDefinition, ConfigEntryBase> config = (IDictionary<ConfigDefinition, ConfigEntryBase>)value.Instance.Config; ConfigDefinition key = new ConfigDefinition("1. Zones", "Loaded zones"); ConfigDefinition key2 = new ConfigDefinition("General", "loaded_area"); ConfigDefinition key3 = new ConfigDefinition("1. Zones", "Generated zones"); ConfigDefinition key4 = new ConfigDefinition("General", "distant_area"); ConfigEntryBase value3; if (config.TryGetValue(key, out var value2)) { value2.BoxedValue = loaded; } else if (config.TryGetValue(key2, out value3)) { value3.BoxedValue = loaded; } ConfigEntryBase value5; if (config.TryGetValue(key3, out var value4)) { value4.BoxedValue = generated; } else if (config.TryGetValue(key4, out value5)) { value5.BoxedValue = generated; } } } public static void TriggerExpansion() { if ((Object)(object)s_instance != (Object)null) { ((MonoBehaviour)s_instance).StartCoroutine(StreamDelayedZonesRoutine()); } } private static IEnumerator StreamDelayedZonesRoutine() { int targetDelay = s_frameDelayCount.Value; for (int i = 0; i < targetDelay; i++) { yield return null; } SetRenderLimits(s_normalLoadedArea.Value, s_normalGeneratedArea.Value); } } [HarmonyPatch(typeof(Player), "TeleportTo")] internal static class PatchPortalEnter { internal static void Prefix() { if (DynamicTeleportAreasPlugin.Enabled.Value) { DynamicTeleportAreasPlugin.SetRenderLimits(DynamicTeleportAreasPlugin.TeleportLoadedArea.Value, DynamicTeleportAreasPlugin.TeleportGeneratedArea.Value); } } } [HarmonyPatch(typeof(Player), "UpdateTeleport")] internal static class PatchPortalExit { private static bool s_wasTeleporting; internal static void Postfix(Player __instance) { if (DynamicTeleportAreasPlugin.Enabled.Value) { if (((Character)__instance).IsTeleporting()) { s_wasTeleporting = true; } else if (s_wasTeleporting) { s_wasTeleporting = false; DynamicTeleportAreasPlugin.TriggerExpansion(); } } } } [HarmonyPatch(typeof(MessageHud), "ShowMessage")] internal static class PatchMessageHudSilence { internal static bool Prefix() { return !DynamicTeleportAreasPlugin.SuppressNotifications; } } [HarmonyPatch(typeof(Chat), "AddString")] internal static class PatchChatSilence { internal static bool Prefix() { return !DynamicTeleportAreasPlugin.SuppressNotifications; } } }