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 SmoothSync v1.4.0
plugins/SmoothSync.dll
Decompiled 13 hours agousing System; using System.Diagnostics; 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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("SmoothSync")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: AssemblyProduct("SmoothSync")] [assembly: AssemblyTitle("SmoothSync")] [assembly: AssemblyVersion("1.3.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 SmoothSync { internal static class ConnectionGuard { internal static bool Active; private static float _since; private static float _lastMsg; internal static void Tick() { float value = Plugin.GuardSeconds.Value; bool flag = false; float num = 0f; ZNet instance = ZNet.instance; Player localPlayer = Player.m_localPlayer; if (value > 0f && (Object)(object)instance != (Object)null && !instance.IsServer() && (Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsTeleporting()) { ZRpc serverRPC = instance.GetServerRPC(); if (serverRPC != null) { num = serverRPC.GetTimeSinceLastPing(); flag = (Active ? (num > 1.5f) : (num > value)); } } if (flag != Active) { Active = flag; if (flag) { _since = Time.unscaledTime; if ((Object)(object)InventoryGui.instance != (Object)null && InventoryGui.IsVisible()) { InventoryGui.instance.Hide(); } Show("Sunucu bağlantısı yanıt vermiyor — işlemler durduruldu"); Plugin.Log.LogWarning((object)$"connection guard: no ping from the server for {num:0.0} s, world actions paused"); } else { Show("Sunucu bağlantısı geri geldi"); Plugin.Log.LogInfo((object)$"connection guard: pings back after {Time.unscaledTime - _since:0.0} s, actions resumed"); } } else if (Active && Time.unscaledTime - _lastMsg > 4f) { Show("Sunucu bağlantısı yanıt vermiyor — işlemler durduruldu"); } } private static void Show(string text) { _lastMsg = Time.unscaledTime; if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false, true); } } internal static bool Local(Humanoid h) { if (Active && (Object)(object)h != (Object)null) { return (Object)(object)h == (Object)(object)Player.m_localPlayer; } return false; } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class GuardInput { private static void Postfix(Player __instance, ref bool __result) { if (ConnectionGuard.Local((Humanoid)(object)__instance)) { __result = false; } } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] internal static class GuardAttack { [HarmonyPriority(800)] private static bool Prefix(Humanoid __instance, ref bool __result) { if (!ConnectionGuard.Local(__instance)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Player), "AutoPickup")] internal static class GuardAutoPickup { private static bool Prefix(Player __instance) { return !ConnectionGuard.Local((Humanoid)(object)__instance); } } [HarmonyPatch(typeof(Humanoid), "Pickup")] internal static class GuardPickup { private static bool Prefix(Humanoid __instance, ref bool __result) { if (!ConnectionGuard.Local(__instance)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Humanoid), "DropItem")] internal static class GuardDrop { private static bool Prefix(Humanoid __instance, ref bool __result) { if (!ConnectionGuard.Local(__instance)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(InventoryGui), "Show")] internal static class GuardInventory { private static bool Prefix() { return !ConnectionGuard.Active; } } [BepInPlugin("nuckflare.smoothsync", "SmoothSync", "1.4.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "nuckflare.smoothsync"; internal static ManualLogSource Log; internal static ConfigEntry<float> GuardSeconds; private void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; GuardSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("6 - Connection", "Connection guard (s)", 3f, new ConfigDescription("When no ping has arrived from the server for this many seconds, mining, building, picking up, using items, containers and crafting pause until the connection answers again (Valheim itself only notices a dead connection after 30 s, and everything done in between is lost). 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); new Harmony("nuckflare.smoothsync").PatchAll(typeof(Plugin).Assembly); } private void Update() { ConnectionGuard.Tick(); } } }