Please disclose if your mod was created primarily 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 Scenic v1.5.0
Scenic.dll
Decompiled 11 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Scenic")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Scenic")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("95c8d063-19e8-40b7-a28e-cf885f8dac6b")] [assembly: AssemblyFileVersion("1.5.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.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 Scenic { public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static void BindConfig(ConfigFile config) { IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod."); } } public static class ZNetSceneManager { private static readonly List<ZDO> _zdosToRemove = new List<ZDO>(); public static void RemoveObjects(ZNetScene netScene, List<ZDO> currentNearObjects, List<ZDO> currentDistantObjects) { //IL_0178: Unknown result type (might be due to invalid IL or missing references) byte b = (byte)((uint)Time.frameCount & 0xFFu); int i = 0; for (int count = currentNearObjects.Count; i < count; i++) { currentNearObjects[i].TempRemoveEarmark = b; } int j = 0; for (int count2 = currentDistantObjects.Count; j < count2; j++) { currentDistantObjects[j].TempRemoveEarmark = b; } ZDOMan s_instance = ZDOMan.s_instance; Dictionary<ZDO, ZNetView> instances = netScene.m_instances; List<ZNetView> tempRemoved = netScene.m_tempRemoved; tempRemoved.Clear(); _zdosToRemove.Clear(); foreach (KeyValuePair<ZDO, ZNetView> item in instances) { ZDO key = item.Key; if (key != null) { ZNetView value = item.Value; if (!Object.op_Implicit((Object)(object)value)) { _zdosToRemove.Add(key); } else if (key.TempRemoveEarmark != b) { tempRemoved.Add(value); } } } int k = 0; for (int count3 = tempRemoved.Count; k < count3; k++) { ZNetView val = tempRemoved[k]; _zdosToRemove.Add(val.m_zdo); val.m_zdo.Created = false; val.m_zdo = null; Object.Destroy((Object)(object)((Component)val).gameObject); } int l = 0; for (int count4 = _zdosToRemove.Count; l < count4; l++) { ZDO val2 = _zdosToRemove[l]; if (!val2.Persistent && val2.Owner) { s_instance.m_destroySendList.Add(val2.m_uid); } instances.Remove(val2); } tempRemoved.Clear(); _zdosToRemove.Clear(); } } [HarmonyPatch(typeof(ZNetScene))] internal static class ZNetScenePatch { [HarmonyPrefix] [HarmonyPatch("RemoveObjects")] private static bool RemoveObjectsPrefix(ZNetScene __instance, List<ZDO> currentNearObjects, List<ZDO> currentDistantObjects) { if (PluginConfig.IsModEnabled.Value) { ZNetSceneManager.RemoveObjects(__instance, currentNearObjects, currentDistantObjects); return false; } return true; } } [BepInPlugin("redseiko.valheim.scenic", "Scenic", "1.5.0")] public sealed class Scenic : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.scenic"; public const string PluginName = "Scenic"; public const string PluginVersion = "1.5.0"; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.scenic"); } } }