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 ClientLoadSpeedupByViper v1.0.1
plugins/ClientLoadSpeedup.dll
Decompiled 3 days agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; 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: AssemblyCompany("ClientLoadSpeedup")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ClientLoadSpeedup")] [assembly: AssemblyTitle("ClientLoadSpeedup")] [assembly: AssemblyVersion("1.0.0.0")] [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 ClientLoadSpeedup { [BepInPlugin("local.reinaldomoreira.clientloadspeedup", "ClientLoadSpeedup", "1.0.1")] public class ClientLoadSpeedupPlugin : BaseUnityPlugin { public const string ModGUID = "local.reinaldomoreira.clientloadspeedup"; public const string ModName = "ClientLoadSpeedup"; public const string ModVersion = "1.0.1"; private static readonly FieldRef<Minimap, string> SaveDirectoryRef = AccessTools.FieldRefAccess<Minimap, string>("m_saveDirectory"); private static readonly FieldRef<Minimap, string> CachedMaskRef = AccessTools.FieldRefAccess<Minimap, string>("m_cachedMinimapMaskTexturePath"); private static readonly FieldRef<Minimap, string> CachedBiomeRef = AccessTools.FieldRefAccess<Minimap, string>("m_cachedMinimapBiomeTexturePath"); private static readonly FieldRef<Minimap, string> CachedHeightRef = AccessTools.FieldRefAccess<Minimap, string>("m_cachedMinimapHeightTexturePath"); private static readonly FieldRef<Minimap, string> CachedMetaRef = AccessTools.FieldRefAccess<Minimap, string>("m_cachedMinimapMetaPath"); private Harmony _harmony; public static ManualLogSource ModLogger { get; private set; } public static ConfigEntry<bool> EnableMinimapCache { get; private set; } public static ConfigEntry<float> RespawnLoadDuration { get; private set; } private void Awake() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown ModLogger = ((BaseUnityPlugin)this).Logger; EnableMinimapCache = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap", "EnableMultiplayerMinimapCache", true, "Enables disk caching of the 2048x2048 world map on dedicated servers to eliminate the 5s freeze on join."); RespawnLoadDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn", "RespawnLoadDuration", 4f, "Minimum seconds to display loading tips before spawning (vanilla is 8.0s). Safety checks for ground height and chunks remain active."); _harmony = new Harmony("local.reinaldomoreira.clientloadspeedup"); _harmony.PatchAll(); ModLogger.LogInfo((object)"ClientLoadSpeedup 1.0.1 loaded successfully."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } public static void EnsureMinimapCachePaths(Minimap minimap, int seed) { //IL_002d: 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) if (!EnableMinimapCache.Value) { return; } World val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetWorld() : null); if (val == null) { return; } if ((int)val.m_worldVersion == 0) { val.m_worldVersion = (World)41; } if (string.IsNullOrEmpty(SaveDirectoryRef.Invoke(minimap))) { string text = val.m_name; if (string.IsNullOrEmpty(text) && (Object)(object)ZNet.instance != (Object)null) { text = ZNet.instance.GetWorldName(); } if (string.IsNullOrEmpty(text)) { text = "Dedicated"; } char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { text = text.Replace(oldChar, '_'); } int num = ((seed != 0) ? seed : val.m_seed); string text2 = Path.Combine(Paths.CachePath, "Minimap", $"{text}_{num}"); if (!Directory.Exists(text2)) { Directory.CreateDirectory(text2); } SaveDirectoryRef.Invoke(minimap) = text2; CachedMaskRef.Invoke(minimap) = Path.Combine(text2, "cacheMinimapMask.bin"); CachedBiomeRef.Invoke(minimap) = Path.Combine(text2, "cacheMinimapBiome.bin"); CachedHeightRef.Invoke(minimap) = Path.Combine(text2, "cacheMinimapHeight.bin"); CachedMetaRef.Invoke(minimap) = Path.Combine(text2, "cacheMinimapMeta.bin"); ModLogger.LogInfo((object)("Minimap cache paths configured at: " + text2)); } } } [HarmonyPatch(typeof(Minimap), "TryLoadMinimapTextureData")] public static class MinimapTryLoadPatch { [HarmonyPrefix] public static void Prefix(Minimap __instance, int worldSeed) { ClientLoadSpeedupPlugin.EnsureMinimapCachePaths(__instance, worldSeed); } } [HarmonyPatch(typeof(Minimap), "GenerateWorldMap")] public static class MinimapGeneratePatch { [HarmonyPrefix] public static void Prefix(Minimap __instance) { int seed = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetWorld() : null)?.m_seed ?? 0; ClientLoadSpeedupPlugin.EnsureMinimapCachePaths(__instance, seed); } } [HarmonyPatch(typeof(Game), "Awake")] public static class GameAwakePatch { [HarmonyPostfix] public static void Postfix(Game __instance) { float value = ClientLoadSpeedupPlugin.RespawnLoadDuration.Value; if (value >= 0f) { __instance.m_respawnLoadDuration = value; ClientLoadSpeedupPlugin.ModLogger.LogInfo((object)$"Spawn wait duration set to {value:F1}s (vanilla: 8.0s)."); } } } [HarmonyPatch(typeof(Game), "FindSpawnPoint")] public static class GameFindSpawnPointPatch { [HarmonyPrefix] public static void Prefix(Game __instance) { float value = ClientLoadSpeedupPlugin.RespawnLoadDuration.Value; if (value >= 0f && Math.Abs(__instance.m_respawnLoadDuration - value) > 0.01f) { __instance.m_respawnLoadDuration = value; } } } }