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 FpsProtector v1.0.2
FPSProtector.dll
Decompiled 5 hours agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("FPSProtector")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FPSProtector")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("22648583-abaa-4c2a-b94d-a7c56c4dd87b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace ZNetSceneNREFix; [BepInPlugin("com.shaya.nrefix", "FPSProtector", "1.0.2")] public class NREFixPlugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.shaya.fpsprotector"); private void Awake() { harmony.PatchAll(); Debug.Log((object)"FPSProtector loaded. Shielding framerate from ghost objects."); } } [HarmonyPatch(typeof(ZNetScene), "RemoveObjects")] public class ZNetScene_RemoveObjects_Patch { private static void Prefix(ZNetScene __instance, ref Dictionary<ZDOID, ZNetView> ___m_instances) { //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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || ___m_instances == null) { return; } bool flag = false; foreach (KeyValuePair<ZDOID, ZNetView> ___m_instance in ___m_instances) { if ((Object)(object)___m_instance.Value == (Object)null) { flag = true; break; } } if (!flag) { return; } List<KeyValuePair<ZDOID, ZNetView>> list = new List<KeyValuePair<ZDOID, ZNetView>>(); int num = 0; foreach (KeyValuePair<ZDOID, ZNetView> ___m_instance2 in ___m_instances) { if ((Object)(object)___m_instance2.Value == (Object)null || ___m_instance2.Key == ZDOID.None) { num++; continue; } try { ((object)___m_instance2.Key/*cast due to .constrained prefix*/).GetHashCode(); list.Add(___m_instance2); } catch { num++; } } ___m_instances.Clear(); foreach (KeyValuePair<ZDOID, ZNetView> item in list) { ___m_instances[item.Key] = item.Value; } Debug.LogWarning((object)$"[FpsProtector] Cleaned active network dictionary. Safely removed {num} corrupted entities."); } } [HarmonyPatch(typeof(ZNetScene), "CreateObject")] public class ZNetScene_CreateObject_Patch { private static readonly HashSet<int> missingHashes = new HashSet<int>(); private static bool Prefix(ZNetScene __instance, ref GameObject __result, ZDO zdo) { int prefab = zdo.GetPrefab(); if (prefab == 0) { return true; } if (missingHashes.Contains(prefab)) { __result = null; return false; } if ((Object)(object)__instance.GetPrefab(prefab) == (Object)null) { missingHashes.Add(prefab); Debug.LogWarning((object)$"[FPSProtector] Prefab hash {prefab} is missing. Blacklisting to protect FPS."); __result = null; return false; } return true; } }